ref: e024022f35c31fa7f9dd85eaeb6719c57d817aba
parent: 4f57d78598daddaab2b204fe418cf217b541b70e
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jun 6 17:54:47 EDT 2015
Add support for '%%' to do a literal '%'.
--- a/libstd/fmt2.myr
+++ b/libstd/fmt2.myr
@@ -93,19 +93,27 @@
(c, fmt) = striter(fmt)
match c
| '%':
+ if fmt.len > 1
+ if fmt[0] == '%' castto(byte)
+ sbputc(sb, '%')
+ fmt = fmt[1:]
+ goto fmtdone
+ elif fmt[0] == '{' castto(byte)
+ (params, fmt) = f2getparams(fmt[1:])
+ ;;
+ ;;
+
nfmt++
if nfmt > nparams
die("too few params for fmt\n")
;;
- if fmt.len > 1 && fmt[0] == '{' castto(byte)
- (params, fmt) = f2getparams(fmt[1:])
- ;;
ap = fallbackfmt(sb, params, vatype(ap), ap)
| chr:
sbputc(sb, chr)
;;
+:fmtdone
;;
if nfmt != nparams
die("too many params for fmt\n")
@@ -290,7 +298,6 @@
var base
base = opts.base castto(uint64)
- std.put("base = %l\n", base)
if signed && bits < 0
val = -bits castto(uint64)
isneg = true