From 67d8dc7641971626aa4e341ecbb5b911971f139c Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Thu, 8 Jun 2023 14:30:11 +0200 Subject: [PATCH] zprintf: Fix %0c formatting and type object handling --- src/core.e/Formatter.pm6 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core.e/Formatter.pm6 b/src/core.e/Formatter.pm6 index 255825aaa11..5976c0215ce 100644 --- a/src/core.e/Formatter.pm6 +++ b/src/core.e/Formatter.pm6 @@ -406,17 +406,17 @@ class Formatter { # show character representation of codepoint value method directive:sym($/ --> 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 ); @@ -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) {