diff options
author | dgp <dgp@users.sourceforge.net> | 2015-02-20 20:19:48 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2015-02-20 20:19:48 (GMT) |
commit | 8104f5f53df16c73196450563e867f62798448e1 (patch) | |
tree | fceedeb62daad56de804bfeb4e00743a314037f0 | |
parent | b3e202713717d0928e8fd3b5cc1fedc60abedf9b (diff) | |
parent | bb005f26e422eead94be19f7b3a781bb64828aee (diff) | |
download | tcl-8104f5f53df16c73196450563e867f62798448e1.zip tcl-8104f5f53df16c73196450563e867f62798448e1.tar.gz tcl-8104f5f53df16c73196450563e867f62798448e1.tar.bz2 |
[32b6159246] Accept aspect patch for broken [lreplace] bytecode.
No more [lreplace {1 2 3} 2 0] => 1 2 2 3
-rw-r--r-- | generic/tclCompCmdsGR.c | 4 | ||||
-rw-r--r-- | tests/lreplace.test | 9 |
2 files changed, 13 insertions, 0 deletions
diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index e2fb43d..b77c43c 100644 --- a/generic/tclCompCmdsGR.c +++ b/generic/tclCompCmdsGR.c @@ -1501,6 +1501,10 @@ TclCompileLreplaceCmd( return TCL_ERROR; } + if(idx2 != INDEX_END && idx2 < idx1) { + idx2 = idx1-1; + } + /* * Work out what this [lreplace] is actually doing. */ diff --git a/tests/lreplace.test b/tests/lreplace.test index b976788..d5c51ae 100644 --- a/tests/lreplace.test +++ b/tests/lreplace.test @@ -137,6 +137,15 @@ test lreplace-4.1 {Bug ccc2c2cc98: lreplace edge case} { test lreplace-4.2 {Bug ccc2c2cc98: lreplace edge case} { lreplace { } 1 1 } {} +test lreplace-4.3 {lreplace edge case} { + lreplace {1 2 3} 2 0 +} {1 2 3} +test lreplace-4.4 {lreplace edge case} { + lreplace {1 2 3 4 5} 3 1 +} {1 2 3 4 5} +test lreplace-4.4 {lreplace edge case} { + lreplace {1 2 3 4 5} 3 0 _ +} {1 2 3 _ 4 5} # cleanup catch {unset foo} |