split by " \0" (const string staring with a SPACE followed by NULL)
authorSADAHIRO Tomoyuki <BQW10602@nifty.com>
Fri, 19 Jan 2007 22:21:48 +0000 (07:21 +0900)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Thu, 25 Jan 2007 17:22:40 +0000 (17:22 +0000)
Message-Id: <20070119221905.D162.BQW10602@nifty.com>

p4raw-id: //depot/perl@29975

op.c
t/op/split.t

diff --git a/op.c b/op.c
index 9e565fe..6a0fa66 100644 (file)
--- 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) {
index b6d7570..025327f 100755 (executable)
@@ -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));
+}