summaryrefslogtreecommitdiff
path: root/lib/std/fmt.myr
diff options
context:
space:
mode:
authorS. Gilles <sgilles@math.umd.edu>2019-09-07 15:41:56 -0400
committerS. Gilles <sgilles@math.umd.edu>2019-09-07 15:41:56 -0400
commitd58df01f3ea2de8d41e10d5387445027e59a6c4e (patch)
treecc3428f8cb927ba8202a521d42aab9c6ec695c44 /lib/std/fmt.myr
parent3b5584581a79cec899c7f6a5233529a64a22ab5f (diff)
downloadmc-d58df01f3ea2de8d41e10d5387445027e59a6c4e.tar.gz
Allow padding for fltXY formatting
Diffstat (limited to 'lib/std/fmt.myr')
-rw-r--r--lib/std/fmt.myr5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/std/fmt.myr b/lib/std/fmt.myr
index 540d6d8..51dc36e 100644
--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -454,10 +454,14 @@ const fltparams = {params
fp = [
.mode = MNormal,
.prec = 0,
+ .padfill = ' ',
+ .padto = 0,
]
for p : params
match p
+ | ("w", wid): fp.padto = getint(wid, "fmt: width must be integer")
+ | ("p", pad): fp.padfill = decode(pad)
| (opt, arg):
std.write(2, "fmt: ")
std.write(2, opt)
@@ -466,6 +470,7 @@ const fltparams = {params
std.die("\nunreachable\n")
;;
;;
+ iassert(fp.padto >= 0, "pad must be >= 0")
-> fp
}