From 4d9cb21634d0a078496241552088df96626f0f65 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 12 Jun 2006 09:34:08 +0200 Subject: [PATCH] string.c: fix split_args() If the submitted command started with a newline, the number of arguments was calculated as zero. --- string.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/string.c b/string.c index 78b862c9..2bdc7e89 100644 --- a/string.c +++ b/string.c @@ -389,14 +389,19 @@ __must_check unsigned split_args(char *args, char ***argv_ptr, const char *delim char **argv; size_t n = 0, i, j; - while ((i = strcspn(p, delim)) && (p += i)) { - p += strspn(p, delim); + p = args + strspn(args, delim); + for (;;) { + i = strcspn(p, delim); + if (!i) + break; + p += i; n++; + p += strspn(p, delim); } *argv_ptr = para_malloc((n + 1) * sizeof(char *)); argv = *argv_ptr; i = 0; - p = args; + p = args + strspn(args, delim); while (p) { argv[i] = p; j = strcspn(p, delim); -- 2.39.5