summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2006-09-30 19:15:21 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2006-09-30 19:15:21 (GMT)
commit95ad00a6876e7f285593ef426f2b86df76115ae7 (patch)
tree3b9bcfc712689745ebfc3cbd67c935741d70c25b
parent25eaf268205e1fd47ec88e2323b0c8806f1b617a (diff)
downloadtcl-95ad00a6876e7f285593ef426f2b86df76115ae7.zip
tcl-95ad00a6876e7f285593ef426f2b86df76115ae7.tar.gz
tcl-95ad00a6876e7f285593ef426f2b86df76115ae7.tar.bz2
* generic/tclUtil.c (Tcl_SplitList): optimisation, [Patch 1344747]
by dgp.
-rw-r--r--ChangeLog3
-rw-r--r--generic/tclUtil.c21
2 files changed, 19 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 6adf911..b8f186a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2006-09-30 Miguel Sofer <msofer@users.sf.net>
+ * generic/tclUtil.c (Tcl_SplitList): optimisation, [Patch 1344747]
+ by dgp.
+
* generic/tclInt.decls:
* generic/tclInt.h:
* generic/tclIntDecls.h:
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 2a1c1dc..ab6c0c8 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUtil.c,v 1.70 2006/09/21 21:11:50 dgp Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.71 2006/09/30 19:15:21 msofer Exp $
*/
#include "tclInt.h"
@@ -427,15 +427,26 @@ Tcl_SplitList(
* 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;