diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclCmdIL.c | 7 | ||||
-rw-r--r-- | tests/lsearch.test | 6 |
3 files changed, 15 insertions, 4 deletions
@@ -1,3 +1,9 @@ +2003-02-27 Donal K. Fellows <fellowsd@cs.man.ac.uk> + + * tests/lsearch.test (lsearch-10.7): + * generic/tclCmdIL.c (Tcl_LsearchObjCmd): Stopped -start option + from causing an option when used with an empty list. [Bug #694232] + 2003-02-26 Chengye Mao <chengye.geo@yahoo.com> * win/tclWinInit.c: fixed a bug in TclpSetVariables by initializing diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 4bbe241..2c77649 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -15,7 +15,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdIL.c,v 1.46 2003/02/11 23:59:39 hobbs Exp $ + * RCS: @(#) $Id: tclCmdIL.c,v 1.47 2003/02/27 16:01:55 dkf Exp $ */ #include "tclInt.h" @@ -2928,10 +2928,11 @@ Tcl_LsearchObjCmd(clientData, interp, objc, objv) if (result != TCL_OK) { return result; } + if (offset > listc-1) { + offset = listc-1; + } if (offset < 0) { offset = 0; - } else if (offset > listc-1) { - offset = listc-1; } } diff --git a/tests/lsearch.test b/tests/lsearch.test index da6dce6..1beaaab 100644 --- a/tests/lsearch.test +++ b/tests/lsearch.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: lsearch.test,v 1.9 2003/02/11 21:54:48 hobbs Exp $ +# RCS: @(#) $Id: lsearch.test,v 1.10 2003/02/27 16:02:00 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -289,6 +289,10 @@ test lsearch-10.6 {binary search with offset} { } set res } [concat -1 -1 [lrange $increasingIntegers 2 end]] +test lsearch-10.7 {offset searching with an empty list} { + # Stop bug #694232 from reocurring + lsearch -start 0 {} x +} -1 test lsearch-11.1 {negated searches} { lsearch -not {a a a b a a a} a |