summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclCompExpr.c33
2 files changed, 32 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c133296..7d351ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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);
}
}