diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tclScan.c | 9 | ||||
-rw-r--r-- | tests/scan.test | 15 |
3 files changed, 26 insertions, 3 deletions
@@ -1,5 +1,10 @@ 2002-02-06 Jeff Hobbs <jeffh@ActiveState.com> + * tests/scan.test: + * generic/tclScan.c (Tcl_ScanObjCmd): corrected scan 0x... %x + handling that didn't accept the 0x as a prelude to a base 16 + number. [Bug #495213] + * generic/tclCompCmds.c (TclCompileRegexpCmd): made early check for bad RE to stop checking further. diff --git a/generic/tclScan.c b/generic/tclScan.c index 23483e7..4dea57a 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -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: tclScan.c,v 1.8 2001/09/20 01:03:08 hobbs Exp $ + * RCS: @(#) $Id: tclScan.c,v 1.9 2002/02/07 01:50:46 hobbs Exp $ */ #include "tclInt.h" @@ -855,12 +855,19 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv) * a number. If we are unsure of the base, it * indicates that we are in base 8 or base 16 (if it is * followed by an 'x'). + * + * 8.1 - 8.3.4 incorrectly handled 0x... base-16 + * cases for %x by not reading the 0x as the + * auto-prelude for base-16. [Bug #495213] */ case '0': if (base == 0) { base = 8; flags |= SCAN_XOK; } + if (base == 16) { + flags |= SCAN_XOK; + } if (flags & SCAN_NOZERO) { flags &= ~(SCAN_SIGNOK | SCAN_NODIGITS | SCAN_NOZERO); diff --git a/tests/scan.test b/tests/scan.test index d7204a9..d3d8c96 100644 --- a/tests/scan.test +++ b/tests/scan.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: scan.test,v 1.11 2000/12/10 03:27:04 hobbs Exp $ +# RCS: @(#) $Id: scan.test,v 1.12 2002/02/07 01:50:46 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -231,9 +231,20 @@ test scan-4.39 {Tcl_ScanObjCmd, base-16 integer scanning} { list [scan {+1238 -123a 0123} {%x%x%x} x y z] $x $y $z } {3 4664 -4666 291} test scan-4.40 {Tcl_ScanObjCmd, base-16 integer scanning} { + # The behavior changed in 8.4a4/8.3.4cvs (6 Feb) to correctly + # return '1' for 0x1 scanned via %x, to comply with 8.0 and C scanf. + # Bug #495213 set x {} list [scan {aBcDeF AbCdEf 0x1} {%x%x%x} x y z] $x $y $z -} {3 11259375 11259375 0} +} {3 11259375 11259375 1} +test scan-4.40.1 {Tcl_ScanObjCmd, base-16 integer scanning} { + set x {} + list [scan {0xF 0x00A0B 0X0XF} {%x %x %x} x y z] $x $y $z +} {3 15 2571 0} +test scan-4.40.2 {Tcl_ScanObjCmd, base-16 integer scanning} { + catch {unset x} + list [scan {xF} {%x} x] [info exists x] +} {0 0} test scan-4.41 {Tcl_ScanObjCmd, base-unknown integer scanning} { set x {} list [scan {10 010 0x10} {%i%i%i} x y z] $x $y $z |