develooper Front page | perl.perl5.porters | Postings from August 2012

[perl #70836] nested heredoc gets bad error message

From:
Father Chrysostomos via RT
Date:
August 21, 2012 14:41
Subject:
[perl #70836] nested heredoc gets bad error message
Message ID:
rt-3.6.HEAD-11172-1345585285-1341.70836-15-0@perl.org
On Thu Nov 26 03:21:59 2009, zefram@fysh.org wrote:
> 
> This is a bug report for perl from zefram@fysh.org,
> generated with the help of perlbug 1.36 running under perl 5.10.0.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> Found this behaviour while investigating the current -Dmad failure:
> 
> $ perl -e $'print <<E1;\n@{[ <<E2 ]}\nE1'
> Can't find string terminator "
> E2" anywhere before EOF at -e line 1.
> 
> Not a great error message.  The prefix newline comes from the inner
> workings of scan_heredoc: it's correct for it to be in PL_tokenbuf,
> but it shouldn't go through to the error message.  This patch fixes
>    it:
> 
> PATCH
> --- a/toke.c
> +++ b/toke.c
> @@ -560,8 +560,10 @@ S_missingterm(pTHX_ char *s)
>      char tmpbuf[3];
>      char q;
>      if (s) {
> -	char * const nl = strrchr(s,'\n');
> -	if (nl)
> +	char *nl;
> +	if (*s == '\n')
> +	    s++;
> +	if ((nl = strrchr(s,'\n')))
>  	    *nl = '\0';
>      }
>      else if (isCNTRL(PL_multi_close)) {
> PATCH

I don’t think that’s the best place to do that.  Just don’t pass the
initial \n to missingterm to begin with.  I fixed it that way in
5af08aedbe3.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=70836



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