Change 29975 by [EMAIL PROTECTED] on 2007/01/25 17:22:40

        Subject: split by " \0" (const string staring with a SPACE followed by 
NULL)
        From: SADAHIRO Tomoyuki <[EMAIL PROTECTED]>
        Date: Fri, 19 Jan 2007 22:21:48 +0900
        Message-Id: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/op.c#878 edit
... //depot/perl/t/op/split.t#38 edit

Differences ...

==== //depot/perl/op.c#878 (text) ====
Index: perl/op.c
--- perl/op.c#877~29830~        2007-01-15 06:38:58.000000000 -0800
+++ perl/op.c   2007-01-25 09:22:40.000000000 -0800
@@ -3254,7 +3254,7 @@
        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) {

==== //depot/perl/t/op/split.t#38 (xtext) ====
Index: perl/t/op/split.t
--- perl/t/op/split.t#37~29887~ 2007-01-19 13:11:40.000000000 -0800
+++ perl/t/op/split.t   2007-01-25 09:22:40.000000000 -0800
@@ -6,7 +6,7 @@
     require './test.pl';
 }
 
-plan tests => 130;
+plan tests => 135;
 
 $FS = ':';
 
@@ -347,3 +347,14 @@
         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));
+}
End of Patch.

Reply via email to