From: Florian Ragwitz Date: Sun, 11 May 2008 07:51:18 +0000 (+0200) Subject: Handle PL_minus_E before PL_minus_{n,p}. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9f6397285900782ac168be55e879a6ac4fab7094;p=p5sagit%2Fp5-mst-13.2.git Handle PL_minus_E before PL_minus_{n,p}. Message-Id: <1210485078-19640-1-git-send-email-rafl@debian.org> p4raw-id: //depot/perl@33822 --- diff --git a/t/run/switches.t b/t/run/switches.t index b3fd934..e5ac5d1 100644 --- a/t/run/switches.t +++ b/t/run/switches.t @@ -11,7 +11,7 @@ BEGIN { BEGIN { require "./test.pl"; } -plan(tests => 68); +plan(tests => 69); use Config; @@ -346,3 +346,9 @@ $r = runperl( switches => [ '-E', '"given(undef) {when(undef) { say q(Hello, world!)"}}'] ); is( $r, "Hello, world!\n", "-E given" ); + +$r = runperl( + switches => [ '-nE', q('} END { say q/affe/') ], + stdin => 'zomtek', +); +is( $r, "affe\n", '-E works outside of the block created by -n' ); diff --git a/toke.c b/toke.c index 431938f..abdc54d 100644 --- a/toke.c +++ b/toke.c @@ -3688,6 +3688,9 @@ Perl_yylex(pTHX) sv_free((SV*)PL_preambleav); PL_preambleav = NULL; } + if (PL_minus_E) + sv_catpvs(PL_linestr, + "use feature ':5." STRINGIFY(PERL_VERSION) "';"); if (PL_minus_n || PL_minus_p) { sv_catpvs(PL_linestr, "LINE: while (<>) {"); if (PL_minus_l) @@ -3719,9 +3722,6 @@ Perl_yylex(pTHX) sv_catpvs(PL_linestr,"our @F=split(' ');"); } } - if (PL_minus_E) - sv_catpvs(PL_linestr, - "use feature ':5." STRINGIFY(PERL_VERSION) "';"); sv_catpvs(PL_linestr, "\n"); PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = SvPVX(PL_linestr); PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr);