summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-10-10 13:14:31 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-10-10 13:15:14 -0700
commit451f421fe4742646fa2efbed0f45a19f0713d00f (patch)
tree7d78530b99142d67abb214536f34b6a944658656 /toke.c
parent73f2c082cce3e45af05f993af5e9294bb30e6ee5 (diff)
downloadperl-451f421fe4742646fa2efbed0f45a19f0713d00f.tar.gz
[perl #114658] Fix line numbers at the end of string eval
$ perl -e 'eval "{;"; print $@' Missing right curly or square bracket at (eval 1) line 1, at end of line syntax error at (eval 1) line 1, at EOF $ perl -e 'eval "{"; print $@' Missing right curly or square bracket at (eval 1) line 2, at end of line syntax error at (eval 1) line 2, at EOF Notice how the line number goes up when there is no semicolon. What happens is that eval tacks "\n;" on to the end of the string if it does not already end with a semicolon. I actually changed this in blead in commit 11076590 to tack "\n;" on to the end all the time, to make eval "q;;" and eval "return #comment;" work. This caused the line number to increase for eval "{;". This commit fixes both examples above by modifying S_incline to account for the "\n;" at the end of a string eval. Existing tests had to be modified, as they were testing for the wrong line number.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/toke.c b/toke.c
index e9a06eb423..1079e943db 100644
--- a/toke.c
+++ b/toke.c
@@ -1559,6 +1559,12 @@ S_incline(pTHX_ const char *s)
PERL_ARGS_ASSERT_INCLINE;
COPLINE_INC_WITH_HERELINES;
+ if (!PL_rsfp && !PL_parser->filtered && PL_lex_state == LEX_NORMAL
+ && s+1 == PL_bufend && *s == ';') {
+ /* fake newline in string eval */
+ CopLINE_dec(PL_curcop);
+ return;
+ }
if (*s++ != '#')
return;
while (SPACE_OR_TAB(*s))