From fb3057c4a82b8cead5f45c319b4256eb2f6c8dba Mon Sep 17 00:00:00 2001 From: aspect Date: Tue, 16 Jun 2015 00:41:39 +0000 Subject: fix for a4cb3f06c4fe - bug introduced in 32b61592465 --- generic/tclCompCmdsGR.c | 2 +- tests/lreplace.test | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index b77c43c..8d8f2cc 100644 --- a/generic/tclCompCmdsGR.c +++ b/generic/tclCompCmdsGR.c @@ -1501,7 +1501,7 @@ TclCompileLreplaceCmd( return TCL_ERROR; } - if(idx2 != INDEX_END && idx2 < idx1) { + if(idx2 != INDEX_END && idx2 >= 0 && idx2 < idx1) { idx2 = idx1-1; } diff --git a/tests/lreplace.test b/tests/lreplace.test index d1319c6..cf0ae51 100644 --- a/tests/lreplace.test +++ b/tests/lreplace.test @@ -146,6 +146,9 @@ test lreplace-4.4 {lreplace edge case} { test lreplace-4.5 {lreplace edge case} { lreplace {1 2 3 4 5} 3 0 _ } {1 2 3 _ 4 5} +test lreplace-4.6 {lreplace end-x: bug a4cb3f06c4} { + lreplace {0 1 2 3 4} 0 end-2 +} {3 4} # cleanup catch {unset foo} -- cgit v0.12