Author: moritz
Date: Tue Jul 29 11:24:10 2008
New Revision: 29857

Modified:
   trunk/languages/perl6/src/builtins/io.pir
   trunk/languages/perl6/src/classes/IO.pir

Log:
[rakudo] implement sprintf. Patch courtesy of Carl Mäsak <cmasak at gmail.com>
masak++


Modified: trunk/languages/perl6/src/builtins/io.pir
==============================================================================
--- trunk/languages/perl6/src/builtins/io.pir   (original)
+++ trunk/languages/perl6/src/builtins/io.pir   Tue Jul 29 11:24:10 2008
@@ -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

Modified: trunk/languages/perl6/src/classes/IO.pir
==============================================================================
--- trunk/languages/perl6/src/classes/IO.pir    (original)
+++ trunk/languages/perl6/src/classes/IO.pir    Tue Jul 29 11:24:10 2008
@@ -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.

Reply via email to