Skip to content

Commit

Permalink
zprintf: Fix %0c formatting and type object handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Jun 8, 2023
1 parent a54b99b commit 67d8dc7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/core.e/Formatter.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,17 @@ class Formatter {

# show character representation of codepoint value
method directive:sym<c>($/ --> Nil) {
my $size := size($/);

# parameter.chr
my $ast := ast-call-method(parameter($/), 'chr');
# chrify(parameter)
my $ast := ast-call-sub('chrify', parameter($/));

if $size {
if size($/) -> $size {
# str-(left|right)-justified($size, $ast)
$ast := ast-call-sub(
has_minus($/)
?? "str-left-justified"
!! "str-right-justified",
!! has_zero($/)
?? "pad-zeroes-str"
!! "str-right-justified",
$size,
$ast
);
Expand Down Expand Up @@ -705,6 +705,9 @@ class Formatter {
!! $string
}

# RUNTIME create .chr of given value
sub chrify($value) { $value.Numeric.chr }

# RUNTIME set up value for scientific notation
proto sub scientify(|) {*}
multi sub scientify($letter, $positions, Str:D $value --> Str:D) {
Expand Down

0 comments on commit 67d8dc7

Please sign in to comment.