summaryrefslogtreecommitdiff
path: root/libstd
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-06-06 21:54:47 -0700
committerOri Bernstein <ori@eigenstate.org>2015-06-06 21:54:47 -0700
commite024022f35c31fa7f9dd85eaeb6719c57d817aba (patch)
tree975ce9612040f2947ef5c1ed31fbb83c8183d9c0 /libstd
parent4f57d78598daddaab2b204fe418cf217b541b70e (diff)
downloadmc-e024022f35c31fa7f9dd85eaeb6719c57d817aba.tar.gz
Add support for '%%' to do a literal '%'.
Diffstat (limited to 'libstd')
-rw-r--r--libstd/fmt2.myr15
1 files changed, 11 insertions, 4 deletions
diff --git a/libstd/fmt2.myr b/libstd/fmt2.myr
index b97052e..732e1c9 100644
--- a/libstd/fmt2.myr
+++ b/libstd/fmt2.myr
@@ -93,19 +93,27 @@ const f2sbfmtv = {sb, fmt, ap -> size
(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 @@ generic intfmt = {sb, opts, signed, bits : @a::(integral,numeric)
var base
base = opts.base castto(uint64)
- std.put("base = %l\n", base)
if signed && bits < 0
val = -bits castto(uint64)
isneg = true