develooper Front page | perl.perl5.porters | Postings from September 2013

Re: [perl #119823] LABEL<newline>: only works in string eval

Thread Previous | Thread Next
Brian Fraser
September 15, 2013 21:31
Re: [perl #119823] LABEL<newline>: only works in string eval
Message ID:
On Sun, Sep 15, 2013 at 5:45 PM, Father Chrysostomos <> wrote:

> # New Ticket Created by  Father Chrysostomos
> # Please include the string:  [perl #119823]
> # in the subject line of all future correspondence about this issue.
> # <URL: >
> $ ./perl -Ilib -MO=Deparse -e 'foo:bar'
> foo: '???';
> -e syntax OK
> $ ./perl -Ilib -MO=Deparse -e 'foo' -e ':bar'
> syntax error at -e line 2, near "foo
> :"
> -e had compilation errors.
> $ ./perl -Ilib -e 'warn eval "foo\n:bar";'
> bar at -e line 1.
> The colon search does not like newlines, except in string eval, where it
> is fine.

This probably happens because the code that skips whitespace preceding the
colon search is 'while (d < PL_bufend && isSPACE(*d)) d++;', which is wrong
if there can be a newline between the end of the current token and the
start of the next, since for the non-eval case we're reading from a file
and PL_bufend will point to the next \n.
Ideally we should be using PEEKSPACE() there, but that calls
lex_read_space, which swallows up # and anything following it, and that
would break s#foo#bar#.
So the groundwork to get this and similar bugs fixed would be, I think,
adding a LEX_NO_SWALLOW_COMMENTS-style flag for

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About