summaryrefslogtreecommitdiff
path: root/libstd
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-06-10 00:18:08 -0400
committerOri Bernstein <ori@eigenstate.org>2015-06-10 00:18:08 -0400
commit9930411eb53445ca7d1f1d98d85d79c646890cc2 (patch)
treea781d7a5629ae19aacd3a01b9c246f1512f0bbcc /libstd
parentf000461027b34e34b6e9bfdc54a5cce2a058f705 (diff)
downloadmc-9930411eb53445ca7d1f1d98d85d79c646890cc2.tar.gz
use '{' and '}' for format args.
Diffstat (limited to 'libstd')
-rw-r--r--libstd/fmt2.myr39
1 files changed, 19 insertions, 20 deletions
diff --git a/libstd/fmt2.myr b/libstd/fmt2.myr
index 6ce93dd..5d3511f 100644
--- a/libstd/fmt2.myr
+++ b/libstd/fmt2.myr
@@ -130,29 +130,28 @@ const f2sbfmtv = {sb, fmt, ap -> size
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)