New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
any-str.pir chomp implementation #352
Comments
From @azawawiHello, Here is the chomp patch that makes all chomp.t tests pass. ./perl6 t/spec/S29-str/chomp.t 2>&1 | head Thanks, Index: src/builtins/any-str.pir--- src/builtins/any-str.pir (revision 31564) @@ -99,7 +99,35 @@ +=item chomp +.sub 'chomp' :method :multi(_) Partial implementation for now, returns a list of strings |
From @azawawiAttaching the patch file |
From @azawawistr_chomp.patchIndex: 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 chomp chars index lc lcfirst rindex ord substr uc ucfirst', 'from'=>$P0)
.end
@@ -99,7 +99,35 @@
.return(retv)
.end
+=item chomp
+
+ our Str method Str::chomp ( Str $string: )
+
+ Returns string with newline removed from the end. An arbitrary
+ terminator can be removed if the input filehandle has marked the
+ string for where the "newline" begins. (Presumably this is stored
+ as a property of the string.) Otherwise a standard newline is removed.
+
+ Note: Most users should just let their I/O handles autochomp instead.
+ (Autochomping is the default.)
+
+=cut
+.sub 'chomp' :method :multi(_)
+ .local string tmps
+ .local string lastchar
+ .local pmc retv
+
+ tmps = self
+ lastchar = substr tmps,-1
+ if lastchar != "\n" goto done
+ chopn tmps, 1
+ done:
+ retv = new 'Perl6Str'
+ retv = tmps
+ .return (retv)
+.end
+
=item comb()
Partial implementation for now, returns a list of strings
|
@azawawi - Status changed from 'new' to 'open' |
From @moritzOn Thu Oct 02 06:06:47 2008, ahmadz wrote:
Probably not all, because chomp.t uses is_deeply, which is not Patch applied as r31573 (+tests; removed two lines of the copied POD), Moritz |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#59556 (status was 'resolved')
Searchable as RT59556$
The text was updated successfully, but these errors were encountered: