Skip to content

Commit

Permalink
Introduce "O" format for Perl 5 semantics
Browse files Browse the repository at this point in the history
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 4ae023c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/Rakudo/Internals/Sprintf.pm6
Expand Up @@ -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>
}
Expand Down Expand Up @@ -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")
}

Expand Down

0 comments on commit 4ae023c

Please sign in to comment.