[asterisk-commits] tilghman: branch 1.4 r124395 - /branches/1.4/main/app.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 20 17:02:56 CDT 2008


Author: tilghman
Date: Fri Jun 20 17:02:55 2008
New Revision: 124395

URL: http://svn.digium.com/view/asterisk?view=rev&rev=124395
Log:
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:
    branches/1.4/main/app.c

Modified: branches/1.4/main/app.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/app.c?view=diff&rev=124395&r1=124394&r2=124395
==============================================================================
--- branches/1.4/main/app.c (original)
+++ branches/1.4/main/app.c Fri Jun 20 17:02:55 2008
@@ -955,7 +955,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)
@@ -982,14 +982,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 asterisk-commits mailing list