summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2003-02-27 16:01:46 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2003-02-27 16:01:46 (GMT)
commitc1eba82515c8db80a9098d7325d5940c203264e7 (patch)
treebefea6f4d22586dd3a2966059d784f1154032975
parent4873c79487937794dde949506edacf8e5372b9f0 (diff)
downloadtcl-c1eba82515c8db80a9098d7325d5940c203264e7.zip
tcl-c1eba82515c8db80a9098d7325d5940c203264e7.tar.gz
tcl-c1eba82515c8db80a9098d7325d5940c203264e7.tar.bz2
Stop [lsearch -start 0 {} x] from crashing. [Bug #694232]
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclCmdIL.c7
-rw-r--r--tests/lsearch.test6
3 files changed, 15 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 14286db..5b41e88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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