Ok, here it is without the change to "split on a string", and the test passes. Please apply this one and in the meantime I will see how we can get the method signature right for split on a strong + not break reverse.
On Thu, Sep 18, 2008 at 1:57 AM, Moritz Lenz <[EMAIL PROTECTED]>wrote: > Chris Davaz (via RT) wrote: > > # New Ticket Created by "Chris Davaz" > > # Please include the string: [perl #58970] > > # in the subject line of all future correspondence about this issue. > > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=58970 > > > > > > > I say "initial" because it didn't pass one of my tests. > > More importantly it introduces a regression in t/spec/S29-list/reverse.t > (Str.reverse is implemented in terms of split-into-characters -> list > reverse -> join; the split failed with your patch, thus causing a test > failure in 'make spectest_regression') > > > This might be due to > > regular expressions not being fully implemented, so if this is the case > > please let me know. > > That's unlikely (but not impossible, of course), the regular rexpression > engine is quite good and well-tested. I'll take a look into it later. > > Anyway, nice patch, and if Str.reverse is fixed it'll certainly be applied. > > Moritz > > -- > Moritz Lenz > http://moritz.faui2k3.org/ | http://perl-6.de/ >
Index: src/classes/Str.pir =================================================================== --- src/classes/Str.pir (revision 31220) +++ src/classes/Str.pir (working copy) @@ -76,6 +76,50 @@ .return(retv) .end +# split a string on a regex +.sub 'split' :method :multi(_, 'Sub') + .param pmc regex + .local pmc match + .local pmc tmpstr + .local pmc retv + .local int start_pos + .local int end_pos + + retv = new 'List' + + match = regex.'ACCEPTS'(self) + unless match goto done + + start_pos = 0 + end_pos = match.'from'() + + loop: + tmpstr = new 'Perl6Str' + $S0 = substr self, start_pos, end_pos + tmpstr = $S0 + retv.'push'(tmpstr) + + start_pos = match.'to'() + + match.'next'() + + end_pos = match.'from'() + end_pos -= start_pos + + $S1 = match.'text'() + if $S1 == '' goto last + goto loop + + last: + tmpstr = new 'Perl6Str' + $S0 = substr self, start_pos, end_pos + tmpstr = $S0 + retv.'push'(tmpstr) + + done: + .return(retv) +.end + .sub lc :method .local string tmps .local pmc retv