summaryrefslogtreecommitdiffstats
path: root/generic/tclParse.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclParse.c')
-rw-r--r--generic/tclParse.c66
1 files changed, 23 insertions, 43 deletions
diff --git a/generic/tclParse.c b/generic/tclParse.c
index 9f10e76..be66a60 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -12,7 +12,6 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclParse.c,v 1.75 2008/11/19 00:00:20 ferrieux Exp $
*/
#include "tclInt.h"
@@ -435,7 +434,7 @@ Tcl_ParseCommand(
}
if (isLiteral) {
- int elemCount = 0, code = TCL_OK;
+ int elemCount = 0, code = TCL_OK, nakedbs = 0;
const char *nextElem, *listEnd, *elemStart;
/*
@@ -457,20 +456,36 @@ Tcl_ParseCommand(
*/
while (nextElem < listEnd) {
+ int size,brace;
+
code = TclFindElement(NULL, nextElem, listEnd - nextElem,
- &elemStart, &nextElem, NULL, NULL);
+ &elemStart, &nextElem, &size, &brace);
if (code != TCL_OK) break;
+ if (!brace)
+ {
+ const char *s;
+
+ for(s=elemStart;size>0;s++,size--)
+ {
+ if ((*s)=='\\')
+ {
+ nakedbs=1;
+ break;
+ }
+ }
+ }
if (elemStart < listEnd) {
elemCount++;
}
}
- if (code != TCL_OK) {
+ if ((code != TCL_OK) || nakedbs) {
/*
- * Some list element could not be parsed. This means the
- * literal string was not in fact a valid list. Defer the
- * handling of this to compile/eval time, where code is
- * already in place to report the "attempt to expand a
+ * Some list element could not be parsed, or contained
+ * naked backslashes. This means the literal string was
+ * not in fact a valid nor canonical list. Defer the
+ * handling of this to compile/eval time, where code is
+ * already in place to report the "attempt to expand a
* non-list" error.
*/
@@ -532,29 +547,6 @@ Tcl_ParseCommand(
tokenPtr[-1].size += (isspace(UCHAR(
tokenPtr->start[tokenPtr->size])) == 0);
}
- if (tokenPtr[-1].start[0]!='{')
- {
- const char *s;
- int n;
-
- for(n=tokenPtr->size,s=tokenPtr->start;n>0;n--,s++)
- {
- if ((*s)=='\\') {
- tokenPtr->type = TCL_TOKEN_UNCOLLAPSED_TEXT;
- /*
- * In this case we also demote the
- * enclosing token from
- * SIMPLE_WORD to WORD in order to
- * preserve the simplicity of all
- * shortcuts made on SIMPLE_WORDs
- * in clients.
- */
- tokenPtr[-1].type = TCL_TOKEN_WORD;
- break;
- }
- }
- }
-
tokenPtr++;
}
}
@@ -2156,7 +2148,6 @@ TclSubstTokens(
{
Tcl_Obj *result;
int code = TCL_OK;
- char *collapsed = NULL;
/*
* Each pass through this loop will substitute one token, and its
@@ -2181,15 +2172,6 @@ TclSubstTokens(
appendByteLength = tokenPtr->size;
break;
- case TCL_TOKEN_UNCOLLAPSED_TEXT:
- if (collapsed)
- collapsed=ckrealloc(collapsed,tokenPtr->size);
- else
- collapsed=ckalloc(tokenPtr->size);
- appendByteLength=TclCopyAndCollapse(tokenPtr->size,tokenPtr->start,collapsed);
- append=collapsed;
- break;
-
case TCL_TOKEN_BS:
appendByteLength = Tcl_UtfBackslash(tokenPtr->start, NULL,
utfCharBytes);
@@ -2302,8 +2284,6 @@ TclSubstTokens(
}
}
}
- if (collapsed) ckfree(collapsed);
-
if (code != TCL_ERROR) { /* Keep error message in result! */
if (result != NULL) {
Tcl_SetObjResult(interp, result);