Revert "toke.c: PL_in_eval purge"
authorFather Chrysostomos <sprout@cpan.org>
Fri, 31 Aug 2012 16:52:53 +0000 (09:52 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 31 Aug 2012 19:31:27 +0000 (12:31 -0700)
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.

toke.c

diff --git a/toke.c b/toke.c
index ec633c4..2b6cf61 100644 (file)
--- 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 {
@@ -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) {