From: Zefram Date: Wed, 9 Dec 2009 22:40:05 +0000 (-0500) Subject: Fix for [perl #70910] wrong line number in syntax error message X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=85613cabfd8d8a9b6b36082819bd6c38e1bb21c7;p=p5sagit%2Fp5-mst-13.2.git Fix for [perl #70910] wrong line number in syntax error message --- diff --git a/MANIFEST b/MANIFEST index a85d318..43e9a49 100644 --- a/MANIFEST +++ b/MANIFEST @@ -4187,6 +4187,7 @@ t/comp/bproto.t See if builtins conform to their prototypes t/comp/cmdopt.t See if command optimization works t/comp/colon.t See if colons are parsed correctly t/comp/decl.t See if declarations work +t/comp/final_line_num.t See if line numbers are correct at EOF t/comp/fold.t See if constant folding works t/comp/hints.aux Auxillary file for %^H test t/comp/hints.t See if %^H works diff --git a/t/comp/final_line_num.t b/t/comp/final_line_num.t new file mode 100644 index 0000000..bb06847 --- /dev/null +++ b/t/comp/final_line_num.t @@ -0,0 +1,13 @@ +#!./perl + +BEGIN { print "1..1\n"; } + +BEGIN { $SIG{__DIE__} = sub { + $_[0] =~ /\Asyntax error at [^ ]+ line ([0-9]+), at EOF/ or exit 1; + my $error_line_num = $1; + print $error_line_num == $last_line_num ? "ok 1\n" : "not ok 1\n"; + exit 0; +}; } + +# the next line causes a syntax error at end of file, to be caught above +BEGIN { $last_line_num = __LINE__; } print 1+ diff --git a/toke.c b/toke.c index d498a34..2ec5f2d 100644 --- a/toke.c +++ b/toke.c @@ -4363,7 +4363,8 @@ Perl_yylex(pTHX) PL_doextract = FALSE; } } - incline(s); + if (PL_rsfp) + incline(s); } while (PL_doextract); PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = s; PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr);