[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH v3 1/2] lib/ukargparse: Fix argparse.c
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |