diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-03-03 15:48:12 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:48 +1000 |
commit | ec3d0d6cfddfa055d00c820a2ed99a7d6858aa82 (patch) | |
tree | f22d707fca94a4738dcaa2c1382e7c95d36e6437 | |
parent | ef6d52c15295a03e343a1ffc12452f7900bb94cd (diff) | |
download | jimtcl-ec3d0d6cfddfa055d00c820a2ed99a7d6858aa82.zip jimtcl-ec3d0d6cfddfa055d00c820a2ed99a7d6858aa82.tar.gz jimtcl-ec3d0d6cfddfa055d00c820a2ed99a7d6858aa82.tar.bz2 |
Fix lassign to work properly with an empty list
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | tclcompat.tcl | 6 | ||||
-rw-r--r-- | tests/misc.test | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/tclcompat.tcl b/tclcompat.tcl index 8669ed2..a1bc043 100644 --- a/tclcompat.tcl +++ b/tclcompat.tcl @@ -10,8 +10,10 @@ set env [env] # Tcl 8.5 lassign proc lassign {list args} { - uplevel 1 [list foreach $args [concat $list {}] break] - lrange $list [llength $args] end + # in case the list is empty... + lappend list {} + uplevel 1 [list foreach $args $list break] + lrange $list [llength $args] end-1 } # case var ?in? pattern action ?pattern action ...? diff --git a/tests/misc.test b/tests/misc.test index e44106c..6bd9477 100644 --- a/tests/misc.test +++ b/tests/misc.test @@ -34,6 +34,12 @@ test regr-1.4 "format double percent" { format (%d%%) 12 } {(12%)} +test regr-1.5 "lassign with empty list" { + unset -nocomplain a b c + lassign {} a b c + info exists c +} {1} + section "I/O Testing" test io-1.1 "Read last line with no newline" { |