Skip to content
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

Implementation of Str.sprintf. #140

Closed
p6rt opened this issue Jun 22, 2008 · 5 comments
Closed

Implementation of Str.sprintf. #140

p6rt opened this issue Jun 22, 2008 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 22, 2008

Migrated from rt.perl.org#56208 (status was 'resolved')

Searchable as RT56208$

@p6rt
Copy link
Author

p6rt commented Jun 22, 2008

From @bacek

Hello.

There is implementation of sprintf. Only src/classes/Str.pir affected.

BTW, '%p' works in parrot, but according to S29 shouldn't.

--
Bacek.

@p6rt
Copy link
Author

p6rt commented Jun 22, 2008

From @bacek

str.diff
diff --git a/languages/perl6/src/classes/Str.pir b/languages/perl6/src/classes/Str.pir
index 0bd0d95..6195989 100644
--- a/languages/perl6/src/classes/Str.pir
+++ b/languages/perl6/src/classes/Str.pir
@@ -213,6 +213,14 @@ as the Perl 6 C<Str> class.
     .return(retv)
 .end
 
+.sub 'sprintf' :method
+    .param pmc args :slurpy
+    .local pmc retv
+    
+    retv = new 'Perl6Str'
+    retv = sprintf self, args
+    .return (retv)
+.end
 
 =item perl()
 
@@ -427,6 +435,23 @@ Returns string with one Char removed from the end.
     .return s.'chop'()
 .end
 
+=item sprintf
+
+ our Str multi method sprintf ( Str $format: *@args ) is export
+
+This function is mostly identical to the C library sprintf function.
+
+=cut
+
+.sub 'sprintf'
+    .param pmc format
+    .param pmc args :slurpy
+    .local pmc s
+    s = new 'Perl6Str'
+    s = format
+    .return s.'sprintf'(args :flat)
+.end
+
 =back
 
 =head2 TODO Functions
@@ -480,8 +505,6 @@ Needs to be in terms of StrPos, not Int.
 
 Needs to be in terms of StrPos, not Int.
 
-=item sprintf
-
 =item unpack
 
 =item vec

@p6rt
Copy link
Author

p6rt commented Jun 22, 2008

From @pmichaud

Applied in r28627, with modifications to avoid the duplicate function sub.

Thanks!

Pm

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jun 22, 2008

From @pmichaud

Applied in r28627, with modifications to avoid the duplicate function sub.

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Jun 22, 2008

@pmichaud - Status changed from 'new' to 'resolved'

@p6rt p6rt closed this as completed Jun 22, 2008
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant