ref: 05f6c77db23d5387751e832de578afcfea703478
parent: 2c5db83da78a650e5dd01740e28946d682b23604
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jun 28 11:06:22 EDT 2016
Don't double install formats.
--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -9,8 +9,10 @@
use "htab"
use "intparse"
use "introspect"
+use "memops"
use "option"
use "result"
+use "sldup"
use "sleq"
use "slpush"
use "strbuf"
@@ -79,7 +81,10 @@
var fmtmap : htab(byte[:], fmtdesc)#
const fmtinstall = {ty, fn, optdesc
- htput(fmtmap, ty, [.fn=fn, .optdesc=optdesc])
+ match std.htget(fmtmap, ty)
+ | `std.Some _: std.fatal("doubly installed format\n")
+ | `std.None: htput(fmtmap, ty, [.fn=fn, .optdesc=sldup(optdesc)])
+ ;;
}
const put = {fmt, args