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

Re: [perl #3643] compiler miscounts lines in s/.../.../e

Thread Previous | Thread Next
From:
Chip Salzenberg
Date:
August 31, 2010 12:47
Subject:
Re: [perl #3643] compiler miscounts lines in s/.../.../e
Message ID:
4C7D5C2B.5060504@pobox.com


> On Fri Aug 04 18:10:13 2000, jfriedl@yahoo-inc.com wrote:
>> With versions since 5.004, this program (with line numbers shown)
>>
>>        1|    $_ = "foo";
>>        2|    s{
>>        3|
>>        4|	    f
>>        5|	    o
>>        6|	    o
>>        7|
>>        8|    }{
>>        9|
>>       10|	  warn "now";
>>       11|	  warn "now";
>>       12|	  warn "now";
>>       13|
>>       14|	  "FOO";
>>       15|    }gex;
>>       16|
>>       17|    warn "now";
>>
>> prints:
>>
>>     now at /tmp/t3 line 4.
>>     now at /tmp/t3 line 5.
>>     now at /tmp/t3 line 6.
>>     now at /tmp/t3 line 17.
>>
>> Perl 5.003 prints what I would consider to be correct:
>>
>>     now at /tmp/t3 line 10.
>>     now at /tmp/t3 line 11.
>>     now at /tmp/t3 line 12.
>>     now at /tmp/t3 line 17.
> This was an apparently intentional change in perl-5.003_26 (4fdae800)
> from Chip Salzenbrg titled "Refine 'runaway string' heuristic". 'Fixing'
> it is as simple as commenting out the line "PL_multi_start =
> first_start;" in toke.c, although "first_start" can be removed
> completely then. No tests fail as a result, although in a way I wish
> there were.
>
> I would prefer "warn" have the exact line, although there may be more
> cases it changes.
>
> Opinions?
>

I just noticed this.

The purpose of the patch was to fix the "runaway string" warning for
substitutions.  Try removing the final "}" in the test code.  I'll bet
5.003 says that there's a runaway substituion starting at line 8, rather
than line 2.  I had no idea that PL_multi_start would affect the line
number diagnostics in s///e.

I'm inclined to remove my old patch to fix the above problem.  A more
complete fix would be duplicating PL_multi_start to PL_multi_startwarn
(e.g.) and only reset one of them.

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