In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/62e4c90a271e4c9a7e8d172f3d36399885df56bc?hp=94814ff57ebcea3e481c1e790e0fbce3453704ae>
- Log ----------------------------------------------------------------- commit 62e4c90a271e4c9a7e8d172f3d36399885df56bc Author: Father Chrysostomos <[email protected]> Date: Fri Aug 31 09:52:53 2012 -0700 Revert "toke.c: PL_in_eval purge" This reverts commit 5c49e90fd624f3ab1cdb1f1d8e4f0525d7881b99. This change broke line numbers under mad when the last statement in the main program lacks a semicolon. I was mistaken in thinking that PL_rsfp would always be true when PL_in_eval is false. But the use of PL_in_eval is still wrong. Under a mad build, we get this inconsistency in line numbers: $ perl -e 'print "\n-e undef\n"' > foo $ ./miniperl foo Use of uninitialized value in -e at foo line 2. $ ./miniperl -we 'require "foo"' Use of uninitialized value in -e at foo line 3. foo did not return a true value at -e line 1. M toke.c commit 09b6b4fbab78d77d855f401bf6adba60e3032aa0 Author: Father Chrysostomos <[email protected]> Date: Fri Aug 31 09:40:40 2012 -0700 test.pl:run_multiple_progs: Document cmdline switches M t/test.pl commit 90a536e1429209983a0eb4bcdfe728d82726b3e9 Author: Father Chrysostomos <[email protected]> Date: Fri Aug 31 09:29:21 2012 -0700 s/${foo#}//e should be an error See also the previous commit. This one was caused by 9c74ccc. Again, we canât just check whether PL_lex_repl has the SvEVALED flag set (which means we are in s///e), but must also check whether PL_lex_repl == PL_linestr (which means we are in the replacement part of s///e). M t/base/lex.t M toke.c commit f777953f1a27fe4a456b4dc3acb1ea6332e12ced Author: Father Chrysostomos <[email protected]> Date: Fri Aug 31 09:27:25 2012 -0700 Commit 6b00f562ed broke s/${\%x}{3}//e It was meant to check whether it was inside the replacement part of s///e, but it only checked that it was inside s///e. PL_lex_repl is set on both sides, but is only equal to PL_linestr on the rhs. M t/base/lex.t M toke.c ----------------------------------------------------------------------- Summary of changes: t/base/lex.t | 11 ++++++++++- t/test.pl | 3 ++- toke.c | 12 ++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/t/base/lex.t b/t/base/lex.t index 1201436..93985e7 100644 --- a/t/base/lex.t +++ b/t/base/lex.t @@ -1,6 +1,6 @@ #!./perl -print "1..72\n"; +print "1..74\n"; $x = 'x'; @@ -358,3 +358,12 @@ print "ok 71 - s//'#' . <<END/e\n"; eval "s//3}->{3/e"; print "not " unless $@; print "ok 72 - s//3}->{3/e\n"; + +$_ = "not ok 73"; +$x{3} = "not "; +eval 's/${\%x}{3}//e'; +print "$_ - s//\${\\%x}{3}/e\n"; + +eval 's/${foo#}//e'; +print "not " unless $@; +print "ok 74 - s/\${foo#}//e\n"; diff --git a/t/test.pl b/t/test.pl index aee1d24..8a810f0 100644 --- a/t/test.pl +++ b/t/test.pl @@ -905,7 +905,8 @@ sub fresh_perl_like { # Each program is source code to run followed by an "EXPECT" line, followed # by the expected output. # -# The code to run may contain (note the '# ' on each): +# The code to run may begin with a command line switch such as -w or -0777 +# (alphanumerics only), and may contain (note the '# ' on each): # # TODO reason for todo # # SKIP reason for skip # # SKIP ?code to test if this should be skipped diff --git a/toke.c b/toke.c index 933503b..2b6cf61 100644 --- a/toke.c +++ b/toke.c @@ -5250,8 +5250,8 @@ Perl_yylex(pTHX) PL_faketokens = 0; #endif if (PL_lex_state != LEX_NORMAL || - (!PL_rsfp && !PL_parser->filtered)) { - if (*s == '#' && s == PL_linestart + (PL_in_eval && !PL_rsfp && !PL_parser->filtered)) { + if (*s == '#' && s == PL_linestart && PL_in_eval && !PL_rsfp && !PL_parser->filtered) { /* handle eval qq[#line 1 "foo"\n ...] */ CopLINE_dec(PL_curcop); @@ -5259,7 +5259,7 @@ Perl_yylex(pTHX) } if (PL_madskills && !PL_lex_formbrack && !PL_in_eval) { s = SKIPSPACE0(s); - if (PL_rsfp || PL_parser->filtered) + if (!PL_in_eval || PL_rsfp || PL_parser->filtered) incline(s); } else { @@ -5279,7 +5279,7 @@ Perl_yylex(pTHX) s = d; if (in_comment && d == PL_bufend && PL_lex_state == LEX_INTERPNORMAL - && PL_lex_inwhat == OP_SUBST && PL_lex_repl + && PL_lex_inwhat == OP_SUBST && PL_lex_repl == PL_linestr && SvEVALED(PL_lex_repl) && d[-1] == '}') s--; else incline(s); } @@ -5932,7 +5932,7 @@ Perl_yylex(pTHX) #endif return yylex(); /* ignore fake brackets */ } - if (PL_lex_inwhat == OP_SUBST && PL_lex_repl + if (PL_lex_inwhat == OP_SUBST && PL_lex_repl == PL_linestr && SvEVALED(PL_lex_repl)) PL_lex_state = LEX_INTERPEND; else if (*s == '-' && s[1] == '>') @@ -6047,7 +6047,7 @@ Perl_yylex(pTHX) if (PL_expect == XSTATE && isALPHA(tmp) && (s == PL_linestart+1 || s[-2] == '\n') ) { - if ((!PL_rsfp && !PL_parser->filtered) + if ((PL_in_eval && !PL_rsfp && !PL_parser->filtered) || PL_lex_state != LEX_NORMAL) { d = PL_bufend; while (s < d) { -- Perl5 Master Repository
