Got rid of "tempstr" and now returns the entire string on a non-match.
Index: src/builtins/any-str.pir =================================================================== --- src/builtins/any-str.pir (revision 31220) +++ src/builtins/any-str.pir (working copy) @@ -71,7 +71,42 @@ .return(retv) .end +=item split() +Splits something on a regular expresion + +=cut + +.sub 'split' :method :multi(_, 'Sub') + .param pmc regex + .local pmc match + .local pmc retv + .local int start_pos + .local int end_pos + + $S0 = self + retv = new 'List' + start_pos = 0 + + match = regex($S0) + if match goto loop + retv.'push'($S0) + goto done + + loop: + match = regex($S0, 'continue' => start_pos) + end_pos = match.'from'() + end_pos -= start_pos + $S1 = substr $S0, start_pos, end_pos + retv.'push'($S1) + unless match goto done + start_pos = match.'to'() + goto loop + + done: + .return(retv) +.end + =item index() =cut
split.p6
Description: Binary data