Change 34876 by [EMAIL PROTECTED] on 2008/11/17 22:54:17

        S_save_lines() was using strchr() when it should have been using
        memchr(). Result - eval""ed source with embedded NULs was not split
        correctly into lines for the debugger. Obscure. But still a bug.
        Maybe the Campaign for the Elimination of strlen() needs to take a long
        hard stare at every strchr() too. And strmp() while we're looking.

Affected files ...

... //depot/perl/pp_ctl.c#713 edit
... //depot/perl/t/comp/retainedlines.t#2 edit

Differences ...

==== //depot/perl/pp_ctl.c#713 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#712~34874~    2008-11-17 14:31:07.000000000 -0800
+++ perl/pp_ctl.c       2008-11-17 14:54:17.000000000 -0800
@@ -2764,7 +2764,7 @@
        const char *t;
        SV * const tmpstr = newSV_type(SVt_PVMG);
 
-       t = strchr(s, '\n');
+       t = (const char *)memchr(s, '\n', send - s);
        if (t)
            t++;
        else

==== //depot/perl/t/comp/retainedlines.t#2 (text) ====
Index: perl/t/comp/retainedlines.t
--- perl/t/comp/retainedlines.t#1~34873~        2008-11-17 14:04:56.000000000 
-0800
+++ perl/t/comp/retainedlines.t 2008-11-17 14:54:17.000000000 -0800
@@ -10,16 +10,19 @@
 
 use strict;
 
-plan( tests => 10 );
+plan( tests => 19 );
 
 my @before = grep { /eval/ } keys %::;
 
 is (@before, 0, "No evals");
 
-for my $sep (' ') {
+my %seen;
+my $name = 'foo';
+
+for my $sep (' ', "\0") {
     $^P = 0xA;
 
-    my $prog = "sub foo {
+    my $prog = "sub $name {
     'Perl${sep}Rules'
 };
 1;
@@ -29,9 +32,9 @@
     # Is there a more efficient way to write this?
     my @expect_lines = (undef, map ({"$_\n"} split "\n", $prog), "\n", ';');
 
-    my @keys = grep { /eval/ } keys %::;
+    my @keys = grep {!$seen{$_}} grep { /eval/ } keys %::;
 
-    is (@keys, 1, "1 eval");
+    is (@keys, 1, "1 new eval");
 
     my @got_lines = @{$::{$keys[0]}};
 
@@ -40,4 +43,6 @@
     for (0..$#expect_lines) {
        is ($got_lines[$_], $expect_lines[$_], "Line $_ is correct");
     }
+    $seen{$keys[0]}++;
+    $name++;
 }
End of Patch.

Reply via email to