Skip to content
Permalink
Browse files

Revert "o" format to Perl 5 / C / Ruby behaviour

Which I think is wrong, but here you go.
  • Loading branch information...
lizmat committed Apr 9, 2019
1 parent 972a242 commit 1cad10b76e97d777a8096132b50592eb4c236716
Showing with 11 additions and 5 deletions.
  1. +11 −5 src/core/Rakudo/Internals/Sprintf.pm6
@@ -121,10 +121,10 @@ class Rakudo::Internals::Sprintf {
sub has_zero($/) { $<flags>.contains("0") }

# helper sub for processing formats for integer values
sub handle-integer-numeric($/, $base) {
sub handle-integer-numeric($/, Int:D $base, Str:D $hash) {
# set up any prefixes
my str $prefix = has_plus($/) ?? "+" !! "";
$prefix = $prefix ~ "0$<sym>" if has_hash($/);
$prefix = $prefix ~ $hash if has_hash($/);

# handle precision / zero filling
my int $size = +$<size>;
@@ -150,7 +150,9 @@ class Rakudo::Internals::Sprintf {
}

# show numeric value in binary
method directive:sym<b>($/) { handle-integer-numeric($/, 2) }
method directive:sym<b>($/) {
handle-integer-numeric($/, 2, "0$<sym>")
}

# show character representation of codepoint value
method directive:sym<c>($/) {
@@ -197,7 +199,9 @@ class Rakudo::Internals::Sprintf {
}

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

# show string
method directive:sym<s>($/) {
@@ -240,7 +244,9 @@ class Rakudo::Internals::Sprintf {
}

# show numeric value in octal
method directive:sym<x>($/) { handle-integer-numeric($/, 16) }
method directive:sym<x>($/) {
handle-integer-numeric($/, 16, "0$<sym>")
}
}

# RUNTIME number of arguments checker

0 comments on commit 1cad10b

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