[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH] lib/ukargparse: Fix argparse.c
Ouh, I just noticed that we weren't handling the maxlen argument in the new left_shift operation. We will produce a v2. Thanks, Simon On 29.06.19 11:59, 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 */ _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |