diff options
author | dgp <dgp@users.sourceforge.net> | 2002-12-11 20:30:11 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2002-12-11 20:30:11 (GMT) |
commit | 0ebb8899a331886beaa24f4ff1ab19b68fd590d9 (patch) | |
tree | 24cdd62ccfa260026ac3007e038023c261238bd0 | |
parent | 2946cae4563a26a948d74ef19280df5da4b3ee9f (diff) | |
download | tcl-0ebb8899a331886beaa24f4ff1ab19b68fd590d9.zip tcl-0ebb8899a331886beaa24f4ff1ab19b68fd590d9.tar.gz tcl-0ebb8899a331886beaa24f4ff1ab19b68fd590d9.tar.bz2 |
* generic/tclParseExpr.c (TclParseInteger): Return 1 for the
string "0x" (recognize leading "0" as an integer). [Bug 648441].
* tests/parseExpr.test (parseExpr-19.1): Test for Bug 648441.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclParseExpr.c | 6 | ||||
-rw-r--r-- | tests/parseExpr.test | 9 |
3 files changed, 18 insertions, 3 deletions
@@ -1,3 +1,9 @@ +2002-12-11 Don Porter <dgp@users.sourceforge.net> + + * generic/tclParseExpr.c (TclParseInteger): Return 1 for the + string "0x" (recognize leading "0" as an integer). [Bug 648441]. + * tests/parseExpr.test (parseExpr-19.1): Test for Bug 648441. + 2002-12-09 Jeff Hobbs <jeffh@ActiveState.com> * win/tclWinThrd.c (TclpMasterUnlock): diff --git a/generic/tclParseExpr.c b/generic/tclParseExpr.c index 077dddb..85be0cd 100644 --- a/generic/tclParseExpr.c +++ b/generic/tclParseExpr.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclParseExpr.c,v 1.15 2002/08/05 03:24:41 dgp Exp $ + * RCS: @(#) $Id: tclParseExpr.c,v 1.16 2002/12/11 20:30:16 dgp Exp $ */ #include "tclInt.h" @@ -1918,7 +1918,9 @@ TclParseInteger(string, numBytes) if (scanned) { return scanned + 2; } - return 0; + + /* Recognize the 0 as valid integer, but x is left behind */ + return 1; } while (numBytes && isdigit(UCHAR(*p))) { /* INTL: digit */ numBytes--; p++; diff --git a/tests/parseExpr.test b/tests/parseExpr.test index 489e6d2..ad5bd17 100644 --- a/tests/parseExpr.test +++ b/tests/parseExpr.test @@ -8,7 +8,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: parseExpr.test,v 1.8 2002/08/05 03:24:41 dgp Exp $ +# RCS: @(#) $Id: parseExpr.test,v 1.9 2002/12/11 20:30:16 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -637,6 +637,13 @@ test parseExpr-18.1 {LogSyntaxError procedure, error in expr longer than 60 char list [catch {testexprparser {(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)/} -1} msg] $msg } {1 {syntax error in expression "(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+012...": premature end of expression}} +test parseExpr-19.1 {TclParseInteger: [Bug 648441]} { + # Should see this as integer "0" followed by incomplete function "x" + # Thus, syntax error. + # If Bug 648441 is not fixed, "0x" will be seen as floating point 0.0 + list [catch {expr 0x} result] $result +} [list 1 {syntax error in expression "0x": extra tokens at end of expression}] + # cleanup ::tcltest::cleanupTests return |