# New Ticket Created by Ahmad Zawawi # Please include the string: [perl #59560] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=59560 >
Hello, Here is the p5chomp patch that makes the first four tests to pass. To test it, please use the following command: ./perl6 t/spec/S29-str/p5chomp.t 2>&1 | head Thanks, Ahmad Zawawi Index: src/builtins/any-str.pir =================================================================== --- src/builtins/any-str.pir (revision 31564) +++ src/builtins/any-str.pir (working copy) @@ -21,7 +21,7 @@ .namespace [] .sub 'onload' :anon :init :load $P0 = get_hll_namespace ['Any'] - '!EXPORT'('capitalize chop chars index lc lcfirst rindex ord substr uc ucfirst', 'from'=>$P0) + '!EXPORT'('capitalize chop p5chomp chars index lc lcfirst rindex ord substr uc ucfirst', 'from'=>$P0) .end @@ -99,7 +99,33 @@ .return(retv) .end +=item p5chomp + our Int multi P5emul::Str::p5chomp ( Str $string is rw ) + our Int multi P5emul::Str::p5chomp ( Str [EMAIL PROTECTED] = ($+_) is rw ) + + Related to C<p5chop>, only removes trailing chars that match C</\n/>. In + either case, it returns the number of chars removed. + +=cut + +.sub 'p5chomp' :method :multi(_) + .local string tmps + .local string lastchar + .local pmc retv + + tmps = self + retv = new 'Int' + retv = 0 + lastchar = substr tmps,-1 + if lastchar != "\n" goto done + chopn tmps, 1 + self = tmps + retv += 1 + done: + .return(retv) +.end + =item comb() Partial implementation for now, returns a list of strings