diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-20 22:04:37 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-20 22:04:37 +0000 |
commit | b45e8e7d4332cf6190f2a24e2a3f487740974849 (patch) | |
tree | 467a330aa0d836b194867df056196e4294c0d7bd /main | |
parent | 6897b73f3ecf6a39fc9a672b3ef20e41a2788dfb (diff) |
Merged revisions 124395 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r124395 | tilghman | 2008-06-20 17:02:55 -0500 (Fri, 20 Jun 2008) | 3 lines
If the last character in a string to be parsed is the delimiter, then we should
count that final empty string as an additional argument.
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@124396 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/app.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/main/app.c b/main/app.c index ebdd237b3..852e3b88e 100644 --- a/main/app.c +++ b/main/app.c @@ -1026,7 +1026,7 @@ int ast_app_group_list_unlock(void) unsigned int ast_app_separate_args(char *buf, char delim, char **array, int arraylen) { int argc; - char *scan; + char *scan, *wasdelim = NULL; int paren = 0, quote = 0; if (!buf || !array || !arraylen) @@ -1053,14 +1053,18 @@ unsigned int ast_app_separate_args(char *buf, char delim, char **array, int arra /* Literal character, don't parse */ memmove(scan, scan + 1, strlen(scan)); } else if ((*scan == delim) && !paren && !quote) { + wasdelim = scan; *scan++ = '\0'; break; } } } - if (*scan) + /* If the last character in the original string was the delimiter, then + * there is one additional argument. */ + if (*scan || (scan > buf && (scan - 1) == wasdelim)) { array[argc++] = scan; + } return argc; } |