diff --git a/basis/formatting/formatting.factor b/basis/formatting/formatting.factor index 5abcb12916..c7e51581ad 100644 --- a/basis/formatting/formatting.factor +++ b/basis/formatting/formatting.factor @@ -11,7 +11,7 @@ IN: formatting [[ second ]] pad-char = (zero|char)? => [[ CHAR: \s or ]] pad-align = ("-")? => [[ \ pad-tail \ pad-head ? ]] pad-width = ([0-9])* => [[ >digits ]] -pad = pad-align pad-char pad-width => [[ reverse >quotation dup first 0 = [ drop [ ] ] when ]] +pad = pad-align pad-char pad-width => [[ >quotation dup first 0 = [ drop [ ] ] when ]] sign = ("+")? => [[ [ dup CHAR: - swap index [ "+" prepend ] unless ] [ ] ? ]] @@ -70,7 +70,7 @@ fmt-X = "X" => [[ [ >hex >upper ] ]] unknown = (.)* => [[ unknown-printf-directive ]] strings_ = fmt-c|fmt-C|fmt-s|fmt-S -strings = pad width strings_ => [[ reverse compose-all ]] +strings = pad width strings_ => [[ compose-all ]] numbers_ = fmt-d|fmt-e|fmt-E|fmt-f|fmt-x|fmt-X numbers = sign pad numbers_ => [[ unclip-last prefix compose-all [ fix-sign ] append ]] @@ -85,14 +85,15 @@ formats = "%" (types|fmt-%|lists|assocs|unknown) => [[ second '[ _ dip ] ]] plain-text = (!("%").)+ => [[ >string '[ _ swap ] ]] -text = (formats|plain-text)* => [[ reverse [ [ [ push ] keep ] append ] map ]] +text = (formats|plain-text)* => [[ [ [ [ push ] keep ] append ] map ]] ;EBNF PRIVATE> MACRO: printf ( format-string -- ) - parse-printf [ length ] keep compose-all '[ _ @ reverse [ write ] each ] ; + parse-printf [ length ] keep compose-all + '[ _ @ [ write ] each ] ; : sprintf ( format-string -- result ) [ printf ] with-string-writer ; inline