summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdIL.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclCmdIL.c')
-rw-r--r--generic/tclCmdIL.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 4c83b5f..e61a42d 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -16,7 +16,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.85 2005/11/29 10:32:56 dkf Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.86 2005/12/09 14:13:00 dkf Exp $
*/
#include "tclInt.h"
@@ -3454,12 +3454,26 @@ Tcl_LsearchObjCmd(clientData, interp, objc, objv)
}
return result;
}
- if (offset > listc-1) {
- offset = listc-1;
- }
if (offset < 0) {
offset = 0;
}
+
+ /*
+ * If the search started past the end of the list, we just return a
+ * "did not match anything at all" result straight away. [Bug 1374778]
+ */
+
+ if (offset > listc-1) {
+ if (sortInfo.indexc > 1) {
+ ckfree((char *) sortInfo.indexv);
+ }
+ if (allMatches || inlineReturn) {
+ Tcl_ResetResult(interp);
+ } else {
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(-1));
+ }
+ return TCL_OK;
+ }
}
patObj = objv[objc - 1];