summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--generic/tclCmdMZ.c8
-rw-r--r--tests/string.test5
3 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ac67a3d..1c467a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-05-14 Donal K. Fellows <fellowsd@cs.man.ac.uk>
+
+ * generic/tclCmdMZ.c (Tcl_StringObjCmd):
+ * tests/string.test (string-4.14): Negative string indices should
+ not be added as offsets to the result of [string first] but
+ instead be treated as referring to the start of the string.
+ [Bug: 423581]
+
2001-05-11 Mo DeJong <mdejong@redhat.com>
* unix/Makefile.in: Add a LDFLAGS variable to the
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 54c1878..6d6939e 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.36 2001/04/24 20:59:17 kennykb Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.37 2001/05/14 08:57:26 dkf Exp $
*/
#include "tclInt.h"
@@ -1267,6 +1267,12 @@ Tcl_StringObjCmd(dummy, interp, objc, objv)
} else if (start > 0) {
ustring2 += start;
length2 -= start;
+ } else if (start < 0) {
+ /*
+ * Invalid start index mapped to string start;
+ * Bug #423581
+ */
+ start = 0;
}
}
diff --git a/tests/string.test b/tests/string.test
index aad463e..b869206 100644
--- a/tests/string.test
+++ b/tests/string.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: string.test,v 1.28 2001/04/06 10:50:00 dkf Exp $
+# RCS: @(#) $Id: string.test,v 1.29 2001/05/14 08:57:26 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -197,6 +197,9 @@ test string-4.12 {string first, start index} {
test string-4.13 {string first, start index} {
string first \u7266 abc\u7266x end-2
} 3
+test string-4.14 {string first, negative start index} {
+ string first b abc -1
+} 1
test string-5.1 {string index} {
list [catch {string index} msg] $msg