From: Gurusamy Sarathy Date: Tue, 17 Nov 1998 09:41:10 +0000 (+0000) Subject: allow C X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c6e96bcb406bc8b8d8610606459ff606ad6883aa;p=p5sagit%2Fp5-mst-13.2.git allow C p4raw-id: //depot/perl@2246 --- diff --git a/op.c b/op.c index e52aa4f..a64b435 100644 --- a/op.c +++ b/op.c @@ -5053,6 +5053,8 @@ ck_sort(OP *o) kid->op_next = k; o->op_flags |= OPf_SPECIAL; } + else if (kid->op_type == OP_RV2SV || kid->op_type == OP_PADSV) + null(cLISTOPo->op_first->op_sibling); } return o; diff --git a/t/op/sort.t b/t/op/sort.t index 70341b9..aca99a6 100755 --- a/t/op/sort.t +++ b/t/op/sort.t @@ -1,8 +1,6 @@ #!./perl -# $RCSfile: sort.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:24 $ - -print "1..21\n"; +print "1..27\n"; sub backwards { $a lt $b ? 1 : $a gt $b ? -1 : 0 } @@ -125,3 +123,28 @@ eval <<'CODE'; my @result = sort 'one', 'two'; CODE print $@ ? "not ok 21\n# $@" : "ok 21\n"; + +{ + my $sortsub = \&backwards; + my $sortglob = *backwards; + my $sortname = 'backwards'; + @b = sort $sortsub 4,1,3,2; + print ("@b" eq '4 3 2 1' ? "ok 22\n" : "not ok 22 |@b|\n"); + @b = sort $sortglob 4,1,3,2; + print ("@b" eq '4 3 2 1' ? "ok 23\n" : "not ok 23 |@b|\n"); + @b = sort $sortname 4,1,3,2; + print ("@b" eq '4 3 2 1' ? "ok 24\n" : "not ok 24 |@b|\n"); +} + +{ + local $sortsub = \&backwards; + local $sortglob = *backwards; + local $sortname = 'backwards'; + @b = sort $sortsub 4,1,3,2; + print ("@b" eq '4 3 2 1' ? "ok 25\n" : "not ok 22 |@b|\n"); + @b = sort $sortglob 4,1,3,2; + print ("@b" eq '4 3 2 1' ? "ok 26\n" : "not ok 23 |@b|\n"); + @b = sort $sortname 4,1,3,2; + print ("@b" eq '4 3 2 1' ? "ok 27\n" : "not ok 24 |@b|\n"); +} + diff --git a/t/pragma/overload.t b/t/pragma/overload.t index da85771..c013a7c 100755 --- a/t/pragma/overload.t +++ b/t/pragma/overload.t @@ -778,8 +778,8 @@ test($c, "bareword"); # 135 test "@sorted", '22 11 5 2 1'; # 189 # Scalar test $$deref, 123; # 190 - # Glob - @sorted = sort $deref 11, 2, 5, 1, 22; + # Code + @sorted = sort $srt 11, 2, 5, 1, 22; test "@sorted", '22 11 5 2 1'; # 191 # Array test "@$deref", '11 12 13'; # 192