Chopn is broken for n < 0, here a fix and tests. Alex Gough -- To have the reputation of possessing the most perfect social tact, talk to every woman as if you loved her, and to every man as if he bored you.
################## Index: string.c =================================================================== RCS file: /home/perlcvs/parrot/string.c,v retrieving revision 1.10 diff -u -r1.10 string.c --- string.c 2001/10/02 14:01:30 1.10 +++ string.c 2001/10/02 14:14:48 @@ -143,6 +143,7 @@ if (n > s->strlen) { n = s->strlen; } + if (n < 0) n = 0; return (ENC_VTABLE(s)->chopn)(s, n); } Index: t/op/string.t =================================================================== RCS file: /home/perlcvs/parrot/t/op/string.t,v retrieving revision 1.5 diff -u -r1.5 string.t --- t/op/string.t 2001/09/25 09:12:57 1.5 +++ t/op/string.t 2001/10/02 14:14:49 @@ -1,6 +1,6 @@ #! perl -w -use Parrot::Test tests => 10; +use Parrot::Test tests => 11; output_is( <<'CODE', <<OUTPUT, "set_s_sc" ); set S4, "JAPH\n" @@ -33,6 +33,27 @@ CODE JAPH japh +OUTPUT + +output_is(<<'CODE', <<OUTPUT, "chopn, OOB values"); + set S1, "A string of length 21" + chopn S1, 0 + print S1 + print "\n" + chopn S1, 4 + print S1 + print "\n" + chopn S1, -4 + print S1 + print "\n" + chopn S1, 1000 + print S1 + print "** nothing **\n" +CODE +A string of length 21 +A string of lengt +A string of lengt +** nothing ** OUTPUT output_is( <<'CODE', 'JAPH', "substr_s_s_i_i" );