summaryrefslogtreecommitdiffstats
path: root/generic/tclCompExpr.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-08-27 14:56:38 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-08-27 14:56:38 (GMT)
commitd679f070dcc31cea4f7fa392c47a081d7d926476 (patch)
treeda7f2bebe9b27e81c054f3a9913f53ee2b52d85c /generic/tclCompExpr.c
parentdf755e81a521c38045bdcd30af94708803a9bc3e (diff)
downloadtcl-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.
Diffstat (limited to 'generic/tclCompExpr.c')
-rw-r--r--generic/tclCompExpr.c33
1 files changed, 26 insertions, 7 deletions
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);
}
}