From fc5ae1303256736570c487af3878721224de2afc Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 24 Nov 2000 15:29:51 +0000 Subject: Logical negation "!" can now handle string booleans, provided those values are placed in variables. Resolves bug #119153 as most people will experience it. --- ChangeLog | 6 +++++- generic/tclExecute.c | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 69595c6..da6496c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,11 @@ 2000-11-24 Donal K. Fellows + * generic/tclExecute.c (TclExecuteByteCode): Logical negation "!" + can now handle string booleans, provided those values are placed + in variables. + * tests/expr.test (expr-13.17): Check that [expr {!$var}] can - negate the string-versions of booleans "yes", "false", etc. + negate the string-versions of booleans "yes", "false", etc. * library/tcltest/tcltest.tcl (getMatchingFiles, getMatchingDirectories): diff --git a/generic/tclExecute.c b/generic/tclExecute.c index e9e3ebb..cdc0724 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.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: tclExecute.c,v 1.15 2000/09/06 16:59:27 hobbs Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.16 2000/11/24 15:29:51 dkf Exp $ */ #include "tclInt.h" @@ -2512,6 +2512,7 @@ TclExecuteByteCode(interp, codePtr) */ double d; + int boolvar; Tcl_ObjType *tPtr; valuePtr = POP_OBJECT(); @@ -2530,6 +2531,11 @@ TclExecuteByteCode(interp, codePtr) result = Tcl_GetDoubleFromObj((Tcl_Interp *) NULL, valuePtr, &d); } + if (result == TCL_ERROR && *pc == INST_LNOT) { + result = Tcl_GetBooleanFromObj((Tcl_Interp *)NULL, + valuePtr, &boolvar); + i = (long)boolvar; /* i is long, not int! */ + } if (result != TCL_OK) { TRACE(("\"%.20s\" => ILLEGAL TYPE %s\n", s, (tPtr? tPtr->name : "null"))); -- cgit v0.12