Tcl Source Code

Artifact [44be5bd678]
Login

Artifact 44be5bd6788d51f1e2856663662c88de16916033:

Attachment "1344747.patch" to ticket [1344747fff] added by dgp 2006-06-21 19:53:34.
Index: generic/tclUtil.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclUtil.c,v
retrieving revision 1.36.2.6
diff -u -r1.36.2.6 tclUtil.c
--- generic/tclUtil.c	5 Apr 2005 16:40:16 -0000	1.36.2.6
+++ generic/tclUtil.c	21 Jun 2006 12:47:26 -0000
@@ -436,15 +436,26 @@
      * the number of space characters in the list.
      */
 
-    for (size = 1, l = list; *l != 0; l++) {
+    for (size = 2, l = list; *l != 0; l++) {
 	if (isspace(UCHAR(*l))) { /* INTL: ISO space. */
 	    size++;
+	    /* Consecutive space can only count as a single list delimiter */
+	    while (1) {
+		char next = *(l + 1);
+		if (next == '\0') {
+		    break;
+		}
+		++l;
+		if (isspace(UCHAR(next))) {
+		    continue;
+		}
+		break;
+	    }
 	}
     }
-    size++;			/* Leave space for final NULL pointer. */
+    length = l - list;
     argv = (CONST char **) ckalloc((unsigned)
-	    ((size * sizeof(char *)) + (l - list) + 1));
-    length = strlen(list);
+	    ((size * sizeof(char *)) + length + 1));
     for (i = 0, p = ((char *) argv) + size*sizeof(char *);
 	    *list != 0;  i++) {
 	CONST char *prevList = list;