Re: [perl #21765] $s = ""; $n = @a = split(/,/, $s); results in undef $n
authorYitzchak Scott-Thoennes <sthoenna@efn.org>
Tue, 1 Apr 2003 16:32:46 +0000 (08:32 -0800)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 2 Apr 2003 18:42:50 +0000 (18:42 +0000)
Message-ID: <u+ii+gzkgqkV092yn@efn.org>

p4raw-id: //depot/perl@19135

pp.c
t/op/split.t

diff --git a/pp.c b/pp.c
index 7985599..1bbe895 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -4778,12 +4778,10 @@ PP(pp_split)
        if (gimme == G_ARRAY)
            RETURN;
     }
-    if (iters || !pm->op_pmreplroot) {
-       GETTARGET;
-       PUSHi(iters);
-       RETURN;
-    }
-    RETPUSHUNDEF;
+
+    GETTARGET;
+    PUSHi(iters);
+    RETURN;
 }
 
 PP(pp_lock)
index 55b2839..17ab1e6 100755 (executable)
@@ -6,7 +6,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 52;
+plan tests => 54;
 
 $FS = ':';
 
@@ -279,6 +279,13 @@ ok(@ary == 3 &&
 {
     $p="a,b";
     utf8::upgrade $p;
-    @a=split(/[, ]+/,$p);
+    eval { @a=split(/[, ]+/,$p) };
     is ("$@-@a-", '-a b-', '#20912 - split() to array with /[]+/ and utf8');
 }
+
+{
+    is (\@a, \@{"a"}, '@a must be global for following test');
+    $p="";
+    $n = @a = split /,/,$p;
+    is ($n, 0, '#21765 - pmreplroot hack used to return undef for 0 iters');
+}