[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH v3 1/2] lib/ukargparse: Fix argparse.c



Hi Andrei,

The patch looks good. The only issue is that the commit message doesn't do a 
good job of explaining what the original problem was; I'll fix this on upstream.

Thanks,

-- Felipe

 Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>

On 01.07.19, 10:10, "Minios-devel on behalf of andrei.gogonea09@xxxxxxxxx" 
<minios-devel-bounces@xxxxxxxxxxxxxxxxxxxx on behalf of 
andrei.gogonea09@xxxxxxxxx> wrote:

    From: Andrei Gogonea <andrei.gogonea09@xxxxxxxxx>
    
    Modify argparse.c to parse correctly arguments stored within quotes.
    
    Signed-off-by: Andrei Gogonea <andrei.gogonea09@xxxxxxxxx>
    Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
    ---
     lib/ukargparse/argparse.c | 25 +++++++++++++++++++++----
     1 file changed, 21 insertions(+), 4 deletions(-)
    
    diff --git a/lib/ukargparse/argparse.c b/lib/ukargparse/argparse.c
    index 20fd9445..b9e28f18 100644
    --- a/lib/ukargparse/argparse.c
    +++ b/lib/ukargparse/argparse.c
    @@ -36,6 +36,15 @@
     #include <uk/argparse.h>
     #include <uk/assert.h>
     
    +
    +static void left_shift(char *buf) 
    +{
    +   while(*buf != '\0') {
    +           *buf = *(buf + 1);
    +           buf++;
    +   }
    +}
    +
     int uk_argnparse(char *argb, __sz maxlen, char *argv[], int maxcount)
     {
        int argc = 0;
    @@ -68,12 +77,20 @@ int uk_argnparse(char *argb, __sz maxlen, char *argv[], 
int maxcount)
                /* quotes */
                case '\'':
                case '"':
    -                   if (in_quote) {
    -                           if (in_quote == argb[i])
    -                                   in_quote = '\0';
    +                   if (!in_quote) {
    +                           in_quote = argb[i];
    +                           left_shift(&argb[i--]);
    +                           break;
    +                   }
    +                   if (in_quote == argb[i]) {
    +                           in_quote = '\0';
    +                           left_shift(&argb[i--]);
                                break;
                        }
    -                   in_quote = argb[i];
    +                           
    +                   
    +
    +                   
                        /* Fall through */
                default:
                        /* any character */
    -- 
    2.11.0
    
    
    _______________________________________________
    Minios-devel mailing list
    Minios-devel@xxxxxxxxxxxxxxxxxxxx
    https://lists.xenproject.org/mailman/listinfo/minios-devel

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.