From: SADAHIRO Tomoyuki Date: Fri, 19 Jan 2007 22:21:48 +0000 (+0900) Subject: split by " \0" (const string staring with a SPACE followed by NULL) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ede8ac17cc8980652fa00e4d3b33ce031d6bbd24;p=p5sagit%2Fp5-mst-13.2.git split by " \0" (const string staring with a SPACE followed by NULL) Message-Id: <20070119221905.D162.BQW10602@nifty.com> p4raw-id: //depot/perl@29975 --- diff --git a/op.c b/op.c index 9e565fe..6a0fa66 100644 --- a/op.c +++ b/op.c @@ -3254,7 +3254,7 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, bool isreg) STRLEN plen; SV * const pat = ((SVOP*)expr)->op_sv; const char *p = SvPV_const(pat, plen); - if ((o->op_flags & OPf_SPECIAL) && (*p == ' ' && p[1] == '\0')) { + if ((o->op_flags & OPf_SPECIAL) && (plen == 1 && *p == ' ')) { U32 was_readonly = SvREADONLY(pat); if (was_readonly) { diff --git a/t/op/split.t b/t/op/split.t index b6d7570..025327f 100755 --- a/t/op/split.t +++ b/t/op/split.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 130; +plan tests => 135; $FS = ':'; @@ -347,3 +347,14 @@ ok(@ary == 3 && ok(@r3 == 3 && join('-', @r3) eq "-:A:-:B", "$msg - /\\s+/ No.2"); } } + +{ + my $src = "ABC \0 FOO \0 XYZ"; + my @s = split(" \0 ", $src); + my @r = split(/ \0 /, $src); + is(scalar(@s), 3); + is($s[0], "ABC"); + is($s[1], "FOO"); + is($s[2]," XYZ"); + is(join(':',@s), join(':',@r)); +}