[svn-commits] tilghman: trunk r124396 - in /trunk: ./ main/app.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jun 20 17:04:37 CDT 2008


Author: tilghman
Date: Fri Jun 20 17:04:37 2008
New Revision: 124396

URL: http://svn.digium.com/view/asterisk?view=rev&rev=124396
Log:
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.

........

Modified:
    trunk/   (props changed)
    trunk/main/app.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/main/app.c
URL: http://svn.digium.com/view/asterisk/trunk/main/app.c?view=diff&rev=124396&r1=124395&r2=124396
==============================================================================
--- trunk/main/app.c (original)
+++ trunk/main/app.c Fri Jun 20 17:04:37 2008
@@ -1026,7 +1026,7 @@
 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 @@
 				/* 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;
 }




More information about the svn-commits mailing list