summaryrefslogtreecommitdiffstats
path: root/generic/tclParse.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2011-05-02 17:36:27 (GMT)
committerdgp <dgp@users.sourceforge.net>2011-05-02 17:36:27 (GMT)
commit18503cb00a32b1fcb0cb46b7b3649903f38c989a (patch)
tree6f65c0c47bdc92c47d2ef7ec544c6961aca11467 /generic/tclParse.c
parentef87219015417dcab0f3aae83834c2c00cdb5607 (diff)
downloadtcl-18503cb00a32b1fcb0cb46b7b3649903f38c989a.zip
tcl-18503cb00a32b1fcb0cb46b7b3649903f38c989a.tar.gz
tcl-18503cb00a32b1fcb0cb46b7b3649903f38c989a.tar.bz2
Revised TclFindElement() interface.
The final argument had been bracePtr, the address of a boolean var, where the caller can be told whether or not the parsed list element was enclosed in braces. In practice, no callers really care about that. What the callers really want to know is whether the list element value exists as a literal substring of the string being parsed, or whether a call to TclCopyAndCollpase() is needed to produce the list element value. Now the final argument is changed to do what callers actually need. This is a better fit for the calls in tclParse.c, where now a good deal of post-processing checking for "naked backslashes" is no longer necessary. ***POTENTIAL INCOMPATIBILITY*** For any callers calling in via the internal stubs table who really do use the final argument explicitly to check for the enclosing brace scenario. Simply looking for the braces where they must be is the revision available to those callers, and it will backport cleanly.
Diffstat (limited to 'generic/tclParse.c')
-rw-r--r--generic/tclParse.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/generic/tclParse.c b/generic/tclParse.c
index 4e1e8b0..c8d2012 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -433,7 +433,7 @@ Tcl_ParseCommand(
}
if (isLiteral) {
- int elemCount = 0, code = TCL_OK, nakedbs = 0;
+ int elemCount = 0, code = TCL_OK, literal = 1;
const char *nextElem, *listEnd, *elemStart;
/*
@@ -455,33 +455,24 @@ Tcl_ParseCommand(
*/
while (nextElem < listEnd) {
- int size, brace;
+ int size;
code = TclFindElement(NULL, nextElem, listEnd - nextElem,
- &elemStart, &nextElem, &size, &brace);
- if (code != TCL_OK) {
+ &elemStart, &nextElem, &size, &literal);
+ if ((code != TCL_OK) || !literal) {
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) || nakedbs) {
+ if ((code != TCL_OK) || !literal) {
/*
- * 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
+ * Some list element could not be parsed, or is not
+ * present as a literal substring of the script. The
+ * compiler cannot handle list elements that get generated
+ * by a call to TclCopyAndCollapse(). 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 or expand lists that require
@@ -525,7 +516,7 @@ Tcl_ParseCommand(
nextElem = tokenPtr[1].start;
while (nextElem < listEnd) {
- int quoted, brace;
+ int quoted;
tokenPtr->type = TCL_TOKEN_SIMPLE_WORD;
tokenPtr->numComponents = 1;
@@ -535,9 +526,10 @@ Tcl_ParseCommand(
tokenPtr->numComponents = 0;
TclFindElement(NULL, nextElem, listEnd - nextElem,
&(tokenPtr->start), &nextElem,
- &(tokenPtr->size), &brace);
+ &(tokenPtr->size), NULL);
- quoted = brace || tokenPtr->start[-1] == '"';
+ quoted = tokenPtr->start[-1] == '{'
+ || tokenPtr->start[-1] == '"';
tokenPtr[-1].start = tokenPtr->start - quoted;
tokenPtr[-1].size = tokenPtr->start + tokenPtr->size
- tokenPtr[-1].start + quoted;