aboutsummaryrefslogtreecommitdiffstats
path: root/main/app.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-20 22:02:55 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-20 22:02:55 +0000
commitc804d88e3b5998ea6d8e36cedadd0f1e824f3dcc (patch)
treee1d1cb6510778411d7f9034e72d561aee9de0626 /main/app.c
parentc5ecd704cc63edfc9ee9c448df8d24560a7b2f40 (diff)
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/branches/1.4@124395 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/app.c')
-rw-r--r--main/app.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/main/app.c b/main/app.c
index 5e7b98272..c9fdb4f0c 100644
--- a/main/app.c
+++ b/main/app.c
@@ -955,7 +955,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)
@@ -982,14 +982,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;
}