diff options
author | dgp <dgp@users.sourceforge.net> | 2007-08-27 14:56:38 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2007-08-27 14:56:38 (GMT) |
commit | d679f070dcc31cea4f7fa392c47a081d7d926476 (patch) | |
tree | da7f2bebe9b27e81c054f3a9913f53ee2b52d85c | |
parent | df755e81a521c38045bdcd30af94708803a9bc3e (diff) | |
download | tcl-d679f070dcc31cea4f7fa392c47a081d7d926476.zip tcl-d679f070dcc31cea4f7fa392c47a081d7d926476.tar.gz tcl-d679f070dcc31cea4f7fa392c47a081d7d926476.tar.bz2 |
* generic/tclCompExpr.c: Force numeric and boolean literals
in expressions to register with their intreps intact, even if that
means overwriting existing intreps in already registered literals.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclCompExpr.c | 33 |
2 files changed, 32 insertions, 7 deletions
@@ -1,3 +1,9 @@ +2007-08-27 Don Porter <dgp@users.sourceforge.net> + + * generic/tclCompExpr.c: Force numeric and boolean literals + in expressions to register with their intreps intact, even if that + means overwriting existing intreps in already registered literals. + 2007-08-25 Kevin B. Kenny <kennykb@acm.org> * generic/tclExecute.c (TclExecuteByteCode): Added code to handle diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index 942f82a..b0c9755 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCompExpr.c,v 1.80 2007/08/24 21:34:19 dgp Exp $ + * RCS: @(#) $Id: tclCompExpr.c,v 1.81 2007/08/27 14:56:39 dgp Exp $ */ #include "tclInt.h" @@ -764,15 +764,34 @@ ParseExpr( case BOOLEAN: { if (interp) { int new; - LiteralEntry *lePtr; + /* LiteralEntry *lePtr; */ Tcl_Obj *objPtr = TclCreateLiteral((Interp *)interp, (char *)start, scanned, /* hash */ (unsigned int) -1, &new, - /* nsPtr */ NULL, /* flags */ 0, &lePtr); - if (new) { - lePtr->objPtr = literal; - Tcl_IncrRefCount(literal); - Tcl_DecrRefCount(objPtr); + /* nsPtr */ NULL, /* flags */ 0, + NULL /* &lePtr */); + if (objPtr->typePtr != literal->typePtr) { + /* + * What we would like to do is this: + * + * lePtr->objPtr = literal; + * Tcl_IncrRefCount(literal); + * Tcl_DecrRefCount(objPtr); + * + * However, the design of the "global" and "local" * LiteralTable does not permit the value of + * lePtr->objPtr to be changed. So rather than + * replace lePtr->objPtr, we do surgery to transfer + * the intrep of literal into it. Ugly stuff here + * that's generally unsafe, but ok here since we know + * the Tcl_ObjTypes literal might possibly have. + */ + Tcl_Obj *toFree = literal; + literal = objPtr; + TclFreeIntRep(literal); + literal->typePtr = toFree->typePtr; + literal->internalRep = toFree->internalRep; + toFree->typePtr = NULL; + Tcl_DecrRefCount(toFree); } } |