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
Patch implementing printf #172
Comments
From @masak...both as a global function and as a method on IO. |
From @masakprintf.patchIndex: src/builtins/io.pir
===================================================================
--- src/builtins/io.pir (revision 29560)
+++ src/builtins/io.pir (working copy)
@@ -35,6 +35,24 @@
.end
+=item printf
+
+Parses a format string and prints formatted output according to it.
+
+=cut
+
+.sub 'printf' :method
+ .param pmc args :slurpy
+
+ args.'!flatten'()
+ $P0 = new 'Str'
+ sprintf $P0, self, args
+
+ print $P0
+ .return (1)
+.end
+
+
.sub 'use'
.param pmc module
.param pmc args :slurpy
Index: src/classes/IO.pir
===================================================================
--- src/classes/IO.pir (revision 29560)
+++ src/classes/IO.pir (working copy)
@@ -62,6 +62,26 @@
.end
+=item printf
+
+Parses a format string and prints formatted output according to it.
+
+=cut
+
+.sub 'printf' :method
+ .param pmc args :slurpy
+ .local pmc PIO
+ PIO = getattribute self, "$!PIO"
+
+ args.'!flatten'()
+ $P0 = new 'Str'
+ sprintf $P0, self, args
+
+ print PIO, $P0
+ .return (1)
+.end
+
+
=item readline
Reads a line from the file handle.
|
From @moritzApplied as r29857, thank you. |
The RT System itself - Status changed from 'new' to 'open' |
@moritz - Status changed from 'open' to 'resolved' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Migrated from rt.perl.org#57068 (status was 'resolved')
Searchable as RT57068$
The text was updated successfully, but these errors were encountered: