summaryrefslogtreecommitdiff
path: root/t/base
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-08-20 18:06:41 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-08-21 14:11:02 -0700
commit62abd0d789549020431af511c02492ac374cf355 (patch)
tree4578713d6306b9700793165386a9f786ccf79fbf /t/base
parentf35fca86375876704f26fde951b763c2bb533608 (diff)
downloadperl-62abd0d789549020431af511c02492ac374cf355.tar.gz
Don’t use strchr when scanning for newline after <<foo
The code that uses this is specifically for parsing <<foo inside a quote-like operator inside a string eval. This prints bar: eval "s//<<foo/e bar foo "; print $_ || $@; This prints Can't find string terminator blah blah blah: eval "s//<<foo/e #\0 bar foo "; print $_ || $@; Nulls in comments are allowed elsewhere. This prints bar: eval "\$_ = <<foo #\0 bar foo "; print $_ || $@; The problem with strchr is that it is specifically for scanning null- terminated strings. If embedded nulls are permitted (and should be in this case), memchr should be used. This code was added by 0244c3a403.
Diffstat (limited to 't/base')
-rw-r--r--t/base/lex.t9
1 files changed, 8 insertions, 1 deletions
diff --git a/t/base/lex.t b/t/base/lex.t
index 559cc30021..2baa5dacff 100644
--- a/t/base/lex.t
+++ b/t/base/lex.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..59\n";
+print "1..60\n";
$x = 'x';
@@ -288,3 +288,10 @@ END
|e
';
print $_ || "not ok 59\n";
+
+$_ = "";
+eval "s/(?:)/<<foo/e #\0
+ok 60 - null on same line as heredoc in s/// in eval
+foo
+";
+print $_ || "not ok 60\n";