Attached is a patch that changes the split opcode to use an Array instead of a PerlArray.

It also updates the documentation to note this.

All the tests still pass, and a grep in the languages/ directory shows that no language implementations are effected.

- James

Will Coleda (via RT) wrote:

# New Ticket Created by Will Coleda # Please include the string: [perl #32545]
# in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=32545 >



The split opcode currently uses a PerlArray to house its result. It should use a non-language specific class.



? classes/.array.pmc.swp
Index: ops/string.ops
===================================================================
RCS file: /cvs/public/parrot/ops/string.ops,v
retrieving revision 1.28
diff -u -r1.28 string.ops
--- ops/string.ops	28 Sep 2004 11:26:49 -0000	1.28
+++ ops/string.ops	6 Dec 2004 19:16:59 -0000
@@ -561,7 +561,7 @@
 
 =item B<split>(out PMC, in STR, in STR)
 
-Create a new PerlArray PMC $1 by splitting the string $3 with
+Create a new Array PMC $1 by splitting the string $3 with
 regexp $2. Currently implemented only for the empty string $2.
 
 =cut
@@ -589,7 +589,7 @@
 }
 
 op split(out PMC, in STR, in STR) :base_core {
-    PMC *res = $1 = pmc_new(interpreter, enum_class_PerlArray);
+    PMC *res = $1 = pmc_new(interpreter, enum_class_Array);
     STRING *r = $2;
     STRING *s = $3;
     int slen = string_length(interpreter, s);
@@ -599,6 +599,7 @@
 	goto NEXT();
     if (string_length(interpreter, r))
 	internal_exception(1, "Unimplemented split by regex");
+    VTABLE_set_integer_native(interpreter, res, slen);
     for (i = 0; i < slen; ++i) {
 	STRING *p = string_substr(interpreter, s, i, 1, NULL, 0);
 	/* TODO first set empty string, then replace */

Reply via email to