Fix this. *Everything* should work now.
p4raw-id: //depot/perl@23730
t/run/switchd.t Test the -d switch
t/run/switches.t Tests for the other switches (-0, -l, -c, -s, -M, -m, -V, -v, -h, -z, -i)
t/run/switchF.t Test the -F switch
+t/run/switchF1.t Pathological tests for the -F switch
t/run/switchI.t Test the -I switch
t/run/switchn.t Test the -n switch
t/run/switchp.t Test the -p switch
--- /dev/null
+#!perl -w
+print "1..5\n";
+
+my $file = "F-Pathological.pl";
+
+open F, ">$file" or die "Open $file: $!";
+
+my $prog = <<'EOT';
+#!./perl -anF[~#QQ\\xq']
+
+BEGIN {
+ *ARGV = *DATA;
+}
+print "@F";
+
+__DATA__
+okx1
+okq2
+ok\3
+ok'4
+EOT
+
+# 2 of the characters toke.c used to use to quote the split parameter:
+$prog =~ s/QQ/\x01\x80/;
+# These 2 plus ~ # and ' were enough to make perl choke
+print F $prog;
+close F or die "Close $file: $!";
+
+print system ($^X, $file) ? "not ok 5\n" : "ok 5\n";
+
+unlink $file or die "Unlink $file: $!";
else {
/* "q\0${splitstr}\0" is legal perl. Yes, even NUL
bytes can be used as quoting characters. :-) */
- Perl_sv_catpvf(aTHX_ PL_linestr,
- "our @F=split(q%c%s%c);",
- 0, PL_splitstr, 0);
+ /* The count here deliberately includes the NUL
+ that terminates the C string constant. This
+ embeds the opening NUL into the string. */
+ Perl_sv_catpvn(aTHX_ PL_linestr,
+ "our @F=split(q", 15);
+ s = PL_splitstr;
+ do {
+ /* Need to \ \s */
+ if (*s == '\\')
+ sv_catpvn(PL_linestr, s, 1);
+ sv_catpvn(PL_linestr, s, 1);
+ } while (*s++);
+ /* This loop will embed the trailing NUL of
+ PL_linestr as the last thing it does before
+ terminating. */
+ Perl_sv_catpvn(aTHX_ PL_linestr, ");", 2);
}
}
else