diff options
author | aspect <aspect+tclcore@abstracted-spleen.org> | 2015-02-19 02:42:13 (GMT) |
---|---|---|
committer | aspect <aspect+tclcore@abstracted-spleen.org> | 2015-02-19 02:42:13 (GMT) |
commit | b8674e42d217b1b7ed6d7a1d89dc42a59902b108 (patch) | |
tree | 0a15cfa1e8417cc5fa66669fa9cc1d9d5f6fab88 | |
parent | 48650316e3373be33455bab6db0a33546169c906 (diff) | |
download | tcl-b8674e42d217b1b7ed6d7a1d89dc42a59902b108.zip tcl-b8674e42d217b1b7ed6d7a1d89dc42a59902b108.tar.gz tcl-b8674e42d217b1b7ed6d7a1d89dc42a59902b108.tar.bz2 |
handle [lreplace l x y ...] where y<x
-rw-r--r-- | generic/tclCompCmdsGR.c | 7 | ||||
-rw-r--r-- | tests/lreplace.test | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index 5220576..e7f6473 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. */ @@ -1524,9 +1528,6 @@ TclCompileLreplaceCmd( tmpObj = Tcl_NewIntObj(idx1); Tcl_IncrRefCount(tmpObj); } - if(idx2 < idx1) { - idx2 = idx1-1; - } goto dropRange; } } diff --git a/tests/lreplace.test b/tests/lreplace.test index 44f3ac2..d5c51ae 100644 --- a/tests/lreplace.test +++ b/tests/lreplace.test @@ -143,6 +143,9 @@ test lreplace-4.3 {lreplace edge case} { 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} |