This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
authorArtur Bergman <sky@nanisky.com>
Thu, 30 Oct 2003 22:01:35 +0000 (22:01 +0000)
committerNicholas Clark <nick@ccl4.org>
Thu, 30 Oct 2003 22:40:29 +0000 (22:40 +0000)
[ 21582]
Subject: Fix for the orange lion bug - aka empty sub bug
Message-Id: <A10EEA90-0B24-11D8-93CD-000A95A2734C@nanisky.com>
p4raw-link: @21582 on //depot/perl: 2d981f2701e9f92843f194f91d9b984eefa4793e

p4raw-id: //depot/maint-5.8/perl@21584
p4raw-branched: from //depot/perl@21582 'branch in' t/op/sub.t
p4raw-integrated: from //depot/perl@21581 'merge in' op.c (@21433..)
MANIFEST (@21550..)

MANIFEST
op.c
t/op/sub.t [new file with mode: 0644]

index 96070f6..4c7e25c 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -2792,6 +2792,7 @@ t/op/srand.t                      See if srand works
 t/op/stash.t                   See if %:: stashes work
 t/op/stat.t                    See if stat works
 t/op/study.t                   See if study works
+t/op/sub.t                     See if subroutines work
 t/op/sub_lval.t                        See if lvalue subroutines work
 t/op/subst_amp.t               See if $&-related substitution works
 t/op/substr.t                  See if substr works
diff --git a/op.c b/op.c
index 48e71b2..2c4ae5c 100644 (file)
--- a/op.c
+++ b/op.c
@@ -6369,6 +6369,17 @@ Perl_peep(pTHX_ register OP *o)
            o->op_seq = PL_op_seqmax++;
            break;
        case OP_STUB:
+           if(!oldop &&
+              o->op_next &&
+              o->op_next->op_type == OP_LEAVESUB) {
+             OP* newop = newSTATEOP(0, Nullch, 0);
+              newop->op_next = o->op_next;
+              o->op_next = 0;
+                      op_free(o);
+              o = newop;
+                      ((UNOP*)o->op_next)->op_first = newop;   
+              CvSTART(PL_compcv) = newop;      
+           }
            if ((o->op_flags & OPf_WANT) != OPf_WANT_LIST) {
                o->op_seq = PL_op_seqmax++;
                break; /* Scalar stub must produce undef.  List stub is noop */
diff --git a/t/op/sub.t b/t/op/sub.t
new file mode 100644 (file)
index 0000000..b76d34c
--- /dev/null
@@ -0,0 +1,19 @@
+#!./perl
+
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+    require Config; import Config;
+}
+
+use Test::More tests => 4;
+
+sub empty_sub {}
+
+is(empty_sub,undef,"Is empty");
+is(empty_sub(1,2,3),undef,"Is still empty");
+@test = empty_sub();
+is(scalar(@test), 0, 'Didnt return anything');
+@test = empty_sub(1,2,3);
+is(scalar(@test), 0, 'Didnt return anything');
+