From: Gurusamy Sarathy Date: Sun, 28 Mar 1999 02:28:20 +0000 (+0000) Subject: fix bogus OPf_REF context for the BLOCK in C X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fd3835b3e90ede5576a7ad392beef86bf933ce15;p=p5sagit%2Fp5-mst-13.2.git fix bogus OPf_REF context for the BLOCK in C (sometimes caused bizarreness in the BLOCK) p4raw-id: //depot/perl@3180 --- diff --git a/MANIFEST b/MANIFEST index af10ce8..2b69bc2 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1177,6 +1177,7 @@ t/op/glob.t See if <*> works t/op/goto.t See if goto works t/op/goto_xs.t See if "goto &sub" works on XSUBs t/op/grent.t See if getgr*() functions work +t/op/grep.t See if grep() and map() work t/op/groups.t See if $( works t/op/gv.t See if typeglobs work t/op/hashwarn.t See if warnings for bad hash assignments work diff --git a/op.c b/op.c index f22a5d2..d5af3c9 100644 --- a/op.c +++ b/op.c @@ -4306,7 +4306,7 @@ newAVREF(OP *o) OP * newGVREF(I32 type, OP *o) { - if (type == OP_MAPSTART) + if (type == OP_MAPSTART || type == OP_GREPSTART) return newUNOP(OP_NULL, 0, o); return ref(newUNOP(OP_RV2GV, OPf_REF, o), type); } diff --git a/t/op/grep.t b/t/op/grep.t new file mode 100755 index 0000000..45d0e25 --- /dev/null +++ b/t/op/grep.t @@ -0,0 +1,31 @@ +#!./perl + +# +# grep() and map() tests +# + +print "1..3\n"; + +$test = 1; + +sub ok { + my ($got,$expect) = @_; + print "# expected [$expect], got [$got]\nnot " if $got ne $expect; + print "ok $test\n"; +} + +{ + my @lol = ([qw(a b c)], [], [qw(1 2 3)]); + my @mapped = map {scalar @$_} @lol; + ok "@mapped", "3 0 3"; + $test++; + + my @grepped = grep {scalar @$_} @lol; + ok "@grepped", "$lol[0] $lol[2]"; + $test++; + + @grepped = grep { $_ } @mapped; + ok "@grepped", "3 3"; + $test++; +} +