From 75a24aeeddf75c00a068fffcf2ae042aebfcb44b Mon Sep 17 00:00:00 2001 From: hobbs Date: Tue, 30 Nov 1999 01:42:57 +0000 Subject: * tests/scan.test: * generic/tclScan.c: fixed scan where %[..] didn't match anything and added test case [Bug: 3700] --- ChangeLog | 6 ++++++ generic/tclScan.c | 8 +++++++- tests/scan.test | 6 +++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c2c0e4..1f747f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +1999-11-29 Jeff Hobbs + + * tests/scan.test: + * generic/tclScan.c: fixed scan where %[..] didn't match anything + and added test case [Bug: 3700] + 1999-11-24 Jeff Hobbs * doc/open.n: diff --git a/generic/tclScan.c b/generic/tclScan.c index 3d7b37e..bf238cf 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.5 1999/11/19 06:34:24 hobbs Exp $ + * RCS: @(#) $Id: tclScan.c,v 1.6 1999/11/30 01:42:59 hobbs Exp $ */ #include "tclInt.h" @@ -810,6 +810,12 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv) } ReleaseCharSet(&cset); + if (string == end) { + /* + * Nothing matched the range, stop processing + */ + goto done; + } if (!(flags & SCAN_SUPPRESS)) { objPtr = Tcl_NewStringObj(string, end-string); Tcl_IncrRefCount(objPtr); diff --git a/tests/scan.test b/tests/scan.test index 4957f9f..0d8d045 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.8 1999/11/19 06:35:01 hobbs Exp $ +# RCS: @(#) $Id: scan.test,v 1.9 1999/11/30 01:43:00 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -42,6 +42,10 @@ test scan-1.7 {BuildCharSet, CharInSet} { test scan-1.8 {BuildCharSet, CharInSet} { list [scan def-abc {%[^c-a]} x] $x } {1 def-} +test scan-1.9 {BuildCharSet, CharInSet no match} { + catch {unset x} + list [scan {= f} {= %[TF]} x] [info exists x] +} {0 0} test scan-2.1 {ReleaseCharSet} { list [scan abcde {%[abc]} x] $x -- cgit v0.12