summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
authorferrieux <ferrieux@users.sourceforge.net>2008-11-17 22:26:53 (GMT)
committerferrieux <ferrieux@users.sourceforge.net>2008-11-17 22:26:53 (GMT)
commitdee5b7a791b4b64cdfe7ae6c9981aff8d85848d5 (patch)
tree2feeafa4d0aa3b3a07938ff5db6643a4ee5dc488 /generic/tclCompile.c
parentdb2e6bf825388498ab5798bbeca26fce23d4286f (diff)
downloadtcl-dee5b7a791b4b64cdfe7ae6c9981aff8d85848d5.zip
tcl-dee5b7a791b4b64cdfe7ae6c9981aff8d85848d5.tar.gz
tcl-dee5b7a791b4b64cdfe7ae6c9981aff8d85848d5.tar.bz2
Fix [Bug 2251175]: missing backslash substitution on expanded literals.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c59
1 files changed, 54 insertions, 5 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index adaa38b..fe282d4 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.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: tclCompile.c,v 1.160 2008/10/26 18:34:04 dkf Exp $
+ * RCS: @(#) $Id: tclCompile.c,v 1.161 2008/11/17 22:26:53 ferrieux Exp $
*/
#include "tclInt.h"
@@ -1077,6 +1077,7 @@ TclWordKnownAtCompileTime(
{
int numComponents = tokenPtr->numComponents;
Tcl_Obj *tempPtr = NULL;
+ char *collapsed=NULL;
if (tokenPtr->type == TCL_TOKEN_SIMPLE_WORD) {
if (valuePtr != NULL) {
@@ -1100,6 +1101,17 @@ TclWordKnownAtCompileTime(
}
break;
+ case TCL_TOKEN_UNCOLLAPSED_TEXT:
+ if (tempPtr != NULL) {
+ if (collapsed)
+ collapsed=ckrealloc(collapsed,tokenPtr->size);
+ else
+ collapsed=ckalloc(tokenPtr->size);
+ Tcl_AppendToObj(tempPtr, collapsed, TclCopyAndCollapse(tokenPtr->size,tokenPtr->start,collapsed));
+ }
+ break;
+
+
case TCL_TOKEN_BS:
if (tempPtr != NULL) {
char utfBuf[TCL_UTF_MAX];
@@ -1110,12 +1122,14 @@ TclWordKnownAtCompileTime(
default:
if (tempPtr != NULL) {
+ if (collapsed) ckfree(collapsed);
Tcl_DecrRefCount(tempPtr);
}
return 0;
}
tokenPtr++;
}
+ if (collapsed) ckfree(collapsed);
if (valuePtr != NULL) {
Tcl_AppendObjToObj(valuePtr, tempPtr);
Tcl_DecrRefCount(tempPtr);
@@ -1447,8 +1461,20 @@ TclCompileScript(
* namespaces to reduce shimmering.
*/
- objIndex = TclRegisterNewNSLiteral(envPtr,
- tokenPtr[1].start, tokenPtr[1].size);
+ if (tokenPtr[1].type & TCL_TOKEN_UNCOLLAPSED_TEXT)
+ {
+ char *s;
+ int n;
+
+ s=ckalloc(tokenPtr[1].size);
+ n=TclCopyAndCollapse(tokenPtr[1].size,tokenPtr[1].start,s);
+ objIndex = TclRegisterLiteral(envPtr,s,n,LITERAL_NS_SCOPE|LITERAL_ON_HEAP);
+ }
+ else
+ {
+ objIndex = TclRegisterNewNSLiteral(envPtr,
+ tokenPtr[1].start, tokenPtr[1].size);
+ }
if (cmdPtr != NULL) {
TclSetCmdNameObj(interp,
envPtr->literalArrayPtr[objIndex].objPtr,cmdPtr);
@@ -1471,8 +1497,20 @@ TclCompileScript(
* unmodified. We care only if the we are in a context
* which already allows absolute counting.
*/
- objIndex = TclRegisterNewLiteral(envPtr,
- tokenPtr[1].start, tokenPtr[1].size);
+ if (tokenPtr[1].type & TCL_TOKEN_UNCOLLAPSED_TEXT)
+ {
+ char *s;
+ int n;
+
+ s=ckalloc(tokenPtr[1].size);
+ n=TclCopyAndCollapse(tokenPtr[1].size,tokenPtr[1].start,s);
+ objIndex = TclRegisterLiteral(envPtr,s,n,LITERAL_ON_HEAP);
+ }
+ else
+ {
+ objIndex = TclRegisterNewLiteral(envPtr,
+ tokenPtr[1].start, tokenPtr[1].size);
+ }
if (eclPtr->type == TCL_LOCATION_SOURCE) {
EnterCmdWordIndex(eclPtr,
@@ -1609,6 +1647,7 @@ TclCompileTokens(
int numObjsToConcat, nameBytes, localVarName, localVar;
int length, i;
unsigned char *entryCodeNext = envPtr->codeNext;
+ char *collapsed=NULL;
Tcl_DStringInit(&textBuffer);
numObjsToConcat = 0;
@@ -1618,6 +1657,14 @@ TclCompileTokens(
Tcl_DStringAppend(&textBuffer, tokenPtr->start, tokenPtr->size);
break;
+ case TCL_TOKEN_UNCOLLAPSED_TEXT:
+ if (collapsed)
+ collapsed=ckrealloc(collapsed,tokenPtr->size);
+ else
+ collapsed=ckalloc(tokenPtr->size);
+ Tcl_DStringAppend(&textBuffer, collapsed, TclCopyAndCollapse(tokenPtr->size,tokenPtr->start,collapsed));
+ break;
+
case TCL_TOKEN_BS:
length = Tcl_UtfBackslash(tokenPtr->start, NULL, buffer);
Tcl_DStringAppend(&textBuffer, buffer, length);
@@ -1733,6 +1780,8 @@ TclCompileTokens(
}
}
+ if (collapsed) ckfree(collapsed);
+
/*
* Push any accumulated characters appearing at the end.
*/