This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #79442] A #line "F" in a string eval doesn't update *{"_<F"}
authorFather Chrysostomos <sprout@cpan.org>
Sun, 27 Feb 2011 08:35:26 +0000 (00:35 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 27 Feb 2011 08:35:43 +0000 (00:35 -0800)
commit8818d4099a576554d990d17764107b1b1480bead
tree64a353765373e13a98ac86a0bbef26825fc6f603
parent4d919e5b5b77044f49e291c3d7df6a8cc423b9f5
[perl #79442] A #line "F" in a string eval doesn't update *{"_<F"}

There are two problems here.

String evals do not populate @{"_<..."} arrays the way parsed streams
do. The lines are all put into the array before the parse. Commit
e66cf94 added the code to copy (actually alias, but whatever) the
lines into the new array when a #line directive is encountered. Inte-
restingly, the following commit (8a5ee59) wrapped that code in an
#ifndef USE_ITHREADS block, because ‘[c]hange 25409 [e66cf94] wasn’t
necessary for threaded perls’. It seems it *was* necessary for
threaded perls after all, because the lines are simply not copied.

In non-threaded perls it wasn’t working properly either. The array
in the new glob was the same array as the old (aliased), so the line
numbers would be off if the #line directive contained a line number
that differed.

This commit does three things:
• It removes the #ifndef,
• It checks whether the line number has changed and aliases the indi-
  vidual elements of the array.
• The breakpoints hash is not copied if the line number differs, as
  setting a breakpoint on (eval 1):1 (warn 1) in
    eval qq{warn 1;\n#line 1 "foo"\nwarn 2;}
  should not also set a breakpoint on foo:1 (warn 2).
t/comp/retainedlines.t
toke.c