From 9db751daebe489baa4dd45c402a87af1428b439c Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 23 Oct 2018 19:01:55 +0000 Subject: End the deprecated practice of accepting "e" and "en" as valid index values. --- generic/tclUtil.c | 8 +++++--- tests/util.test | 8 ++++---- 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 -- cgit v0.12