From 1aa54c04958fb5a081acbd1440314021b21ca394 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 5 Apr 2006 15:17:37 +0000 Subject: * generic/tclIndexObj.c (Tcl_GetIndexFromObjStruct): Allow empty strings to be matched by the Tcl_GetIndexFromObj machinery, in the same manner as any other key. [Bug 1464039] --- ChangeLog | 4 ++-- generic/tclIndexObj.c | 10 +++------- tests/binary.test | 6 +++--- tests/clock.test | 6 +++--- tests/indexObj.test | 7 +++++-- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index f4cbca3..e6e77a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,8 @@ 2006-04-05 Donal K. Fellows * generic/tclIndexObj.c (Tcl_GetIndexFromObjStruct): Allow empty - strings to be matched by the Tcl_GetIndexFromObj machinery, but only - ever exactly. [Bug 1464039] + strings to be matched by the Tcl_GetIndexFromObj machinery, in + the same manner as any other key. [Bug 1464039] 2006-04-03 Andreas Kupries diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index bdd291c..be60517 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.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: tclIndexObj.c,v 1.29 2006/04/05 12:48:25 dkf Exp $ + * RCS: @(#) $Id: tclIndexObj.c,v 1.30 2006/04/05 15:17:39 dgp Exp $ */ #include "tclInt.h" @@ -223,14 +223,10 @@ Tcl_GetIndexFromObjStruct( } /* - * Check if we were instructed to disallow abbreviations. Note that we do - * not allow the empty string as an abbreviation of anything; it is only - * processed by this function as a non-error case if the table of strings - * has an entry in it that is itself an empty string. This only matters in - * the case where the table has a singleton entry. + * Check if we were instructed to disallow abbreviations. */ - if ((flags & TCL_EXACT) || (key[0] == '\0') || (numAbbrev != 1)) { + if ((flags & TCL_EXACT) || (numAbbrev != 1)) { goto error; } diff --git a/tests/binary.test b/tests/binary.test index 70dc044..a16cede 100644 --- a/tests/binary.test +++ b/tests/binary.test @@ -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: binary.test,v 1.27 2006/03/21 11:12:28 dkf Exp $ +# RCS: @(#) $Id: binary.test,v 1.28 2006/04/05 15:17:39 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -1435,9 +1435,9 @@ test binary-41.8 {ScanNumber: word alignment} littleEndian { } {2 1 1.6} test binary-42.1 {Tcl_BinaryObjCmd: bad arguments} {} { - catch {binary ""} result + catch {binary ?} result set result -} {bad option "": must be format or scan} +} {bad option "?": must be format or scan} # Wide int (guaranteed at least 64-bit) handling test binary-43.1 {Tcl_BinaryObjCmd: format wide int} {} { diff --git a/tests/clock.test b/tests/clock.test index d6c44ab..50892b6 100644 --- a/tests/clock.test +++ b/tests/clock.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: clock.test,v 1.61 2006/03/21 11:12:28 dkf Exp $ +# RCS: @(#) $Id: clock.test,v 1.62 2006/04/05 15:17:39 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -34907,8 +34907,8 @@ test clock-33.5a {clock tests, millisecond timing test} { "test should have taken 0-60 ms, actually took [expr $end - $start]"} } {ok} test clock-33.6 {clock clicks, milli with too much abbreviation} { - list [catch { clock clicks {} } msg] $msg -} {1 {bad option "": must be -milliseconds or -microseconds}} + list [catch { clock clicks ? } msg] $msg +} {1 {bad option "?": must be -milliseconds or -microseconds}} test clock-33.7 {clock clicks, milli with too much abbreviation} { list [catch { clock clicks - } msg] $msg } {1 {ambiguous option "-": must be -milliseconds or -microseconds}} diff --git a/tests/indexObj.test b/tests/indexObj.test index acffdcc..653275a 100644 --- a/tests/indexObj.test +++ b/tests/indexObj.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: indexObj.test,v 1.12 2006/04/05 13:18:25 dkf Exp $ +# RCS: @(#) $Id: indexObj.test,v 1.13 2006/04/05 15:17:39 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -67,8 +67,11 @@ test indexObj-2.7 {exact match of empty values} testindexobj { list [catch {testindexobj 1 1 {} a b c} msg] $msg } {1 {ambiguous token "": must be a, b, or c}} test indexObj-2.8 {exact match of empty values: singleton case} testindexobj { - list [catch {testindexobj 1 1 {} a} msg] $msg + list [catch {testindexobj 1 0 {} a} msg] $msg } {1 {bad token "": must be a}} +test indexObj-2.9 {non-exact match of empty values: singleton case} testindexobj { + testindexobj 1 1 {} a +} 0 test indexObj-3.1 {cache result to skip next lookup} testindexobj { testindexobj check 42 -- cgit v0.12