develooper Front page | perl.perl5.porters | Postings from December 2009

Re: [perl #70910] wrong line number in syntax error message

Thread Previous | Thread Next
From:
jesse
Date:
December 9, 2009 14:41
Subject:
Re: [perl #70910] wrong line number in syntax error message
Message ID:
20091209224112.GD22371@bestpractical.com
Thanks. Applied as 85613cabfd8d8a9b6b36082819bd6c38e1bb21c7


On Wed, Dec 09, 2009 at 10:08:33PM +0000, Zefram wrote:
> Frank Wiegand wrote:
> >  $ bleadperl -e '+'
> >  syntax error at -e line 2, at EOF
> 
> Fixed by the attached patch.
> 
> -zefram

> 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);


-- 

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About