mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-07 18:38:02 +00:00
Merged revisions 124396 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r124396 | tilghman | 2008-06-20 17:04:37 -0500 (Fri, 20 Jun 2008) | 11 lines 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: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@124397 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1012,7 +1012,7 @@ int ast_app_group_list_unlock(void)
|
|||||||
unsigned int ast_app_separate_args(char *buf, char delim, char **array, int arraylen)
|
unsigned int ast_app_separate_args(char *buf, char delim, char **array, int arraylen)
|
||||||
{
|
{
|
||||||
int argc;
|
int argc;
|
||||||
char *scan;
|
char *scan, *wasdelim = NULL;
|
||||||
int paren = 0, quote = 0;
|
int paren = 0, quote = 0;
|
||||||
|
|
||||||
if (!buf || !array || !arraylen)
|
if (!buf || !array || !arraylen)
|
||||||
@@ -1039,14 +1039,18 @@ unsigned int ast_app_separate_args(char *buf, char delim, char **array, int arra
|
|||||||
/* Literal character, don't parse */
|
/* Literal character, don't parse */
|
||||||
memmove(scan, scan + 1, strlen(scan));
|
memmove(scan, scan + 1, strlen(scan));
|
||||||
} else if ((*scan == delim) && !paren && !quote) {
|
} else if ((*scan == delim) && !paren && !quote) {
|
||||||
|
wasdelim = scan;
|
||||||
*scan++ = '\0';
|
*scan++ = '\0';
|
||||||
break;
|
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;
|
array[argc++] = scan;
|
||||||
|
}
|
||||||
|
|
||||||
return argc;
|
return argc;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user