Skip to content
Permalink
Browse files

Introduce "O" format for Perl 5 semantics

The "o" format conforms to the way "x" and "b" are rendered.  dogbert17++
for the suggestion.
  • Loading branch information...
lizmat committed Apr 9, 2019
1 parent 1cad10b commit 4ae023c717cee264a4d818600c80f1104517624d
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/core/Rakudo/Internals/Sprintf.pm6
@@ -75,6 +75,9 @@ class Rakudo::Internals::Sprintf {
token directive:sym<o> {
'%' <idx>? <flags>* <size>? [ '.' <precision=.size> ]? <sym>
}
token directive:sym<O> {
'%' <idx>? <flags>* <size>? [ '.' <precision=.size> ]? <sym>
}
token directive:sym<s> {
'%' <idx>? <flags>* <size>? [ '.' <precision=.size> ]? <sym>
}
@@ -198,8 +201,13 @@ class Rakudo::Internals::Sprintf {
make (~$<sym>, $value)
}

# show numeric value in octal
# show numeric value in octal with Perl 6 roundtrippability
method directive:sym<o>($/) {
handle-integer-numeric($/, 8, "0o")
}

# show numeric value in octal using Perl 5 semantics
method directive:sym<O>($/) {
handle-integer-numeric($/, 8, "0")
}

0 comments on commit 4ae023c

Please sign in to comment.
You can’t perform that action at this time.