ref: 9930411eb53445ca7d1f1d98d85d79c646890cc2
parent: f000461027b34e34b6e9bfdc54a5cce2a058f705
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jun 9 20:18:08 EDT 2015
use '{' and '}' for format args.
--- a/libstd/fmt2.myr
+++ b/libstd/fmt2.myr
@@ -130,29 +130,28 @@
while fmt.len != 0
(c, fmt) = striter(fmt)
match c
- | '%':
- params = ""
- 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:])
+ | '{':
+ if decode(fmt) == '{'
+ (c, fmt) = striter(fmt)
+ sbputc(sb, '{')
+ else
+ (params, fmt) = f2getparams(fmt)
+ nfmt++
+ if nfmt > nparams
+ die("too few params for fmt\n")
;;
- ;;
- nfmt++
- if nfmt > nparams
- die("too few params for fmt\n")
+ ty = vatype(ap)
+ match htget(fmtmap, ty)
+ | `Some func:
+ func(sb, ap, params)
+ | `None:
+ fallbackfmt(sb, params, ty, ap)
+ ;;
;;
-
- ty = vatype(ap)
- match htget(fmtmap, ty)
- | `Some func:
- func(sb, ap, params)
- | `None:
- fallbackfmt(sb, params, ty, ap)
+ | '}':
+ if decode(fmt) == '}'
+ sbputc(sb, '}')
;;
| chr:
sbputc(sb, chr)