summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-10-23 19:01:55 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-10-23 19:01:55 (GMT)
commit9db751daebe489baa4dd45c402a87af1428b439c (patch)
tree11cfa63f00dc2afa763d4bdc44b4e3874a6c3177
parenta883ddbe3e214ba2ffa048e61a6f4641519c460b (diff)
downloadtcl-9db751daebe489baa4dd45c402a87af1428b439c.zip
tcl-9db751daebe489baa4dd45c402a87af1428b439c.tar.gz
tcl-9db751daebe489baa4dd45c402a87af1428b439c.tar.bz2
End the deprecated practice of accepting "e" and "en" as valid index values.
-rw-r--r--generic/tclUtil.c8
-rw-r--r--tests/util.test8
2 files changed, 9 insertions, 7 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 954caff..7996703 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -3935,12 +3935,14 @@ GetEndOffsetFromObj(
int length;
const char *bytes = TclGetStringFromObj(objPtr, &length);
- if ((*bytes != 'e') || (strncmp(bytes, "end",
- (size_t)((length > 3) ? 3 : length)) != 0)) {
+ if ((length < 3) || (length == 4)) {
+ return TCL_ERROR;
+ }
+ if ((*bytes != 'e') || (strncmp(bytes, "end", 3) != 0)) {
return TCL_ERROR;
}
- if (length <= 3) {
+ if (length == 3) {
offset = 0;
} else if ((length > 4) && ((bytes[3] == '-') || (bytes[3] == '+'))) {
/*
diff --git a/tests/util.test b/tests/util.test
index 9422fc3..5079a89 100644
--- a/tests/util.test
+++ b/tests/util.test
@@ -586,14 +586,14 @@ test util-9.2.1 {TclGetIntForIndex} -body {
test util-9.2.2 {TclGetIntForIndex} -body {
string index abcd {end }
} -returnCodes error -match glob -result *
-test util-9.3 {TclGetIntForIndex} {
+test util-9.3 {TclGetIntForIndex} -body {
# Deprecated
string index abcd en
-} d
-test util-9.4 {TclGetIntForIndex} {
+} -returnCodes error -match glob -result *
+test util-9.4 {TclGetIntForIndex} -body {
# Deprecated
string index abcd e
-} d
+} -returnCodes error -match glob -result *
test util-9.5.0 {TclGetIntForIndex} {
string index abcd end-1
} c