summaryrefslogtreecommitdiffstats
path: root/generic/tclUtil.c
diff options
context:
space:
mode:
authormsofer <msofer@noemail.net>2006-09-30 19:20:08 (GMT)
committermsofer <msofer@noemail.net>2006-09-30 19:20:08 (GMT)
commitc7e07160a04261429d3d336975df7287dd463706 (patch)
tree6b1abc484b3d5976f48dd311a66eb987d5afabe7 /generic/tclUtil.c
parent8bc2536ce744ac7e819a93776fbbcc89b7119f05 (diff)
downloadtcl-c7e07160a04261429d3d336975df7287dd463706.zip
tcl-c7e07160a04261429d3d336975df7287dd463706.tar.gz
tcl-c7e07160a04261429d3d336975df7287dd463706.tar.bz2
2006-09-30 Miguel Sofer <msofer@users.sf.net>
* generic/tclUtil.c (Tcl_SplitList): optimisation, [Patch 1344747] by dgp. FossilOrigin-Name: 3151fcb2e1bebd488c3fa299e9d532bcaca703ab
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r--generic/tclUtil.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 57fc6e0..d12ebe8 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.36.2.6 2005/04/05 16:40:16 dgp Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.36.2.7 2006/09/30 19:20:12 msofer Exp $
*/
#include "tclInt.h"
@@ -436,15 +436,26 @@ Tcl_SplitList(interp, list, argcPtr, argvPtr)
* 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;