Author: mdiep
Date: Fri Aug 5 19:57:27 2005
New Revision: 8829
Modified:
trunk/languages/tcl/lib/commands/linsert.pir
trunk/languages/tcl/lib/list.pir
trunk/languages/tcl/t/cmd_linsert.t
Log:
Fix linsert past the end of the list.
Modified: trunk/languages/tcl/lib/commands/linsert.pir
==============================================================================
--- trunk/languages/tcl/lib/commands/linsert.pir (original)
+++ trunk/languages/tcl/lib/commands/linsert.pir Fri Aug 5 19:57:27 2005
@@ -22,8 +22,9 @@
($I0,$P0,$I2) = list_index(the_list,position)
if $I0 != TCL_OK goto error
- if $I2 ==0 goto next
- inc $P0 #linsert treats "end" differently
+ #linsert treats "end" differently
+ if $I2 == 0 goto next
+ inc $P0
next:
.local int the_index
Modified: trunk/languages/tcl/lib/list.pir
==============================================================================
--- trunk/languages/tcl/lib/list.pir (original)
+++ trunk/languages/tcl/lib/list.pir Fri Aug 5 19:57:27 2005
@@ -24,6 +24,8 @@
.local pmc number_result
if position == "end" goto my_end
+ $I0 = the_list
+ if pmc_position > $I0 goto my_end
$S0 = substr position, 0, 4
if $S0 == "end-" goto has_end
Modified: trunk/languages/tcl/t/cmd_linsert.t
==============================================================================
--- trunk/languages/tcl/t/cmd_linsert.t (original)
+++ trunk/languages/tcl/t/cmd_linsert.t Fri Aug 5 19:57:27 2005
@@ -4,7 +4,6 @@ use strict;
use lib qw(tcl/t t . ../lib ../../lib ../../../lib);
use Parrot::Test tests => 5;
use Test::More;
-use vars qw($TODO);
language_output_is("tcl",<<'TCL',<<OUT,"insert beginning empty list");
set a [list]
@@ -13,15 +12,12 @@ TCL
a
OUT
-TODO: {
-local $TODO = "borked.";
language_output_is("tcl",<<'TCL',<<OUT,"insert beyond end of empty list");
set a [list]
puts [linsert $a 20 a]
TCL
a
OUT
-}
language_output_is("tcl",<<'TCL',<<OUT,"insert end single list");
set a [list a]