diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2003-02-16 01:36:32 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2003-02-16 01:36:32 (GMT) |
commit | 23889e745ac1e3ba5e76c3ffb94736a5c475de7e (patch) | |
tree | b9cac46b6b2fb5373a629e8d3758b7742b6a651c /generic/tclParse.c | |
parent | af570109241e78092cb2e80486e479b3a71524ef (diff) | |
download | tcl-23889e745ac1e3ba5e76c3ffb94736a5c475de7e.zip tcl-23889e745ac1e3ba5e76c3ffb94736a5c475de7e.tar.gz tcl-23889e745ac1e3ba5e76c3ffb94736a5c475de7e.tar.bz2 |
Don Porter's fix for bad parsing of nested scripts [Bug 681841].
Diffstat (limited to 'generic/tclParse.c')
-rw-r--r-- | generic/tclParse.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/generic/tclParse.c b/generic/tclParse.c index 7e8fced..ec8c9f0 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -13,7 +13,7 @@ * 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.24 2003/02/11 18:34:43 hobbs Exp $ + * RCS: @(#) $Id: tclParse.c,v 1.25 2003/02/16 01:36:32 msofer Exp $ */ #include "tclInt.h" @@ -306,6 +306,7 @@ Tcl_ParseCommand(interp, string, numBytes, nested, parsePtr) scanned = TclParseWhiteSpace(src, numBytes, parsePtr, &type); src += scanned; numBytes -= scanned; if (numBytes == 0) { + parsePtr->term = src; break; } if ((type & terminators) != 0) { @@ -376,6 +377,7 @@ Tcl_ParseCommand(interp, string, numBytes, nested, parsePtr) } if (numBytes == 0) { + parsePtr->term = src; break; } if ((type & terminators) != 0) { @@ -408,7 +410,7 @@ Tcl_ParseCommand(interp, string, numBytes, nested, parsePtr) if (parsePtr->commandStart == NULL) { parsePtr->commandStart = string; } - parsePtr->commandSize = parsePtr->term - parsePtr->commandStart; + parsePtr->commandSize = parsePtr->end - parsePtr->commandStart; return TCL_ERROR; } @@ -859,10 +861,24 @@ ParseTokens(src, numBytes, mask, parsePtr) } src = nested.commandStart + nested.commandSize; numBytes = parsePtr->end - src; + + /* + * This is equivalent to Tcl_FreeParse(&nested), but + * presumably inlined here for sake of runtime optimization + */ + if (nested.tokenPtr != nested.staticTokens) { ckfree((char *) nested.tokenPtr); } - if ((*nested.term == ']') && !nested.incomplete) { + + /* + * Check for the closing ']' that ends the command + * substitution. It must have been the last character of + * the parsed command. + */ + + if ((nested.term < parsePtr->end) && (*nested.term == ']') + && !nested.incomplete) { break; } if (numBytes == 0) { |