summaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/bigint.myr2
-rw-r--r--lib/std/bitset.myr2
-rw-r--r--lib/std/bytealloc.myr3
-rw-r--r--lib/std/dial+posixy.myr1
-rw-r--r--lib/std/env+posixy.myr4
-rw-r--r--lib/std/execvp.myr4
-rw-r--r--lib/std/fltbits.myr10
-rw-r--r--lib/std/fmt.myr16
-rw-r--r--lib/std/intparse.myr2
-rw-r--r--lib/std/optparse.myr8
-rw-r--r--lib/std/pathjoin.myr2
-rw-r--r--lib/std/resolve+posixy.myr6
-rw-r--r--lib/std/slpush.myr6
-rw-r--r--lib/std/test/bitset.myr4
-rw-r--r--lib/std/test/bytealloc.myr4
-rw-r--r--lib/std/test/fmt.myr2
-rw-r--r--lib/std/test/ipparse.myr4
-rw-r--r--lib/std/test/iterutil.myr6
-rw-r--r--lib/std/test/striter.myr4
19 files changed, 46 insertions, 44 deletions
diff --git a/lib/std/bigint.myr b/lib/std/bigint.myr
index f66659e..45170dd 100644
--- a/lib/std/bigint.myr
+++ b/lib/std/bigint.myr
@@ -252,7 +252,7 @@ const bigparse = {str
fit in one digit.
*/
v = mkbigint(1)
- for c in std.bychar(str)
+ for c : std.bychar(str)
if c == '_'
continue
;;
diff --git a/lib/std/bitset.myr b/lib/std/bitset.myr
index 937e65b..1d846da 100644
--- a/lib/std/bitset.myr
+++ b/lib/std/bitset.myr
@@ -67,7 +67,7 @@ const bscount = {bs
var n
n = 0
- for v in bybsvalue(bs)
+ for v : bybsvalue(bs)
n++
;;
-> n
diff --git a/lib/std/bytealloc.myr b/lib/std/bytealloc.myr
index 6c5d94c..654aa88 100644
--- a/lib/std/bytealloc.myr
+++ b/lib/std/bytealloc.myr
@@ -56,7 +56,8 @@ type slab = struct
nfree : size /* the number of free nodes */
;;
-type chunk = struct /* NB: must be smaller than sizeof(slab) */
+/* NB: must be smaller than sizeof(slab) */
+type chunk = struct
next : chunk# /* the next chunk in the free list */
;;
diff --git a/lib/std/dial+posixy.myr b/lib/std/dial+posixy.myr
index 15fc58f..386dac5 100644
--- a/lib/std/dial+posixy.myr
+++ b/lib/std/dial+posixy.myr
@@ -22,6 +22,7 @@ pkg std =
a map from service name to a list of (port,proto)
pairs in order of preference
*/
+
/* FIXME: implement
var services : htab(byte[:], [int, byte[:]][:])#
var inited = false
diff --git a/lib/std/env+posixy.myr b/lib/std/env+posixy.myr
index 3919388..fe73c7e 100644
--- a/lib/std/env+posixy.myr
+++ b/lib/std/env+posixy.myr
@@ -26,7 +26,7 @@ const getenv = {name
var n, env
envinit()
- for envp in environ
+ for envp : environ
env = cstrconvp(envp)
n = min(name.len, env.len)
if sleq(name, env[:n]) && sleq(env[n:n+1], "=")
@@ -48,7 +48,7 @@ const setenv = {name, val
envdup()
idx = 0
- for envp in environ
+ for envp : environ
env = cstrconvp(envp)
n = min(name.len, env.len)
if sleq(name, env[:n]) && sleq(env[n:n+1], "=")
diff --git a/lib/std/execvp.myr b/lib/std/execvp.myr
index c719e5c..f6696e3 100644
--- a/lib/std/execvp.myr
+++ b/lib/std/execvp.myr
@@ -21,7 +21,7 @@ const execvp = {cmd, args
-> execv(cmd, args)
| `None:
paths = getpaths()
- for p in paths
+ for p : paths
binpath = bfmt(buf[:], "{}/{}", p, cmd)
execv(binpath, args)
;;
@@ -39,7 +39,7 @@ const execvpe = {cmd, args, env
-> execve(cmd, args, env)
| `None:
paths = getpaths()
- for p in paths
+ for p : paths
binpath = bfmt(buf[:], "{}/{}", p, cmd)
execve(binpath, args, env)
;;
diff --git a/lib/std/fltbits.myr b/lib/std/fltbits.myr
index 2a9e8cf..f9afd7a 100644
--- a/lib/std/fltbits.myr
+++ b/lib/std/fltbits.myr
@@ -24,9 +24,9 @@ const flt64explode = {flt
var bits, isneg, mant, exp
bits = flt64bits(flt)
- isneg = (bits >> 63) != 0 /* msb is sign bit */
+ isneg = (bits >> 63) != 0 /* msb is sign bit */
exp = (bits >> 52) & 0x7ff /* exp is in bits [52..63] */
- mant = bits & ((1l << 52) - 1) /* msb is in bits [..51] */
+ mant = bits & ((1l << 52) - 1) /* msb is in bits [..51] */
/* add back the implicit bit if this is not a denormal */
if exp != 0
@@ -47,9 +47,9 @@ const flt32explode = {flt
var bits, isneg, mant, exp
bits = flt32bits(flt)
- isneg = (bits >> 31) != 0 /* msb is sign bit */
- exp = (bits >> 22) & 0xff /* exp is in bits [23..30] */
- mant = bits & ((1 << 22) - 1) /* msb is in bits [0..22] */
+ isneg = (bits >> 31) != 0 /* msb is sign bit */
+ exp = (bits >> 22) & 0xff /* exp is in bits [23..30] */
+ mant = bits & ((1 << 22) - 1) /* msb is in bits [0..22] */
/* add back the implicit bit if this is not a denormal */
if exp != 0
diff --git a/lib/std/fmt.myr b/lib/std/fmt.myr
index 794218a..e405075 100644
--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -216,7 +216,7 @@ const parseparams = {paramstr, optdesc
std.fatal("invalid format options {}\n")
;;
params = strsplit(paramstr, ",")
- for p in params
+ for p : params
/* parse out the key/value pair */
match std.strfind(p, "=")
| `std.Some idx:
@@ -231,7 +231,7 @@ const parseparams = {paramstr, optdesc
found = false
/* verify and add the arg */
- for (opt, hasarg) in optdesc
+ for (opt, hasarg) : optdesc
if !std.sleq(opt, o)
continue
;;
@@ -245,7 +245,7 @@ const parseparams = {paramstr, optdesc
;;
if !found
std.put("options: \n")
- for (opt, hasarg) in optdesc
+ for (opt, hasarg) : optdesc
std.put("\t'{}', hasarg={}\n", opt, hasarg)
;;
std.fatal("invalid option '{}' ", o)
@@ -427,7 +427,7 @@ const fmtslice = {sb, subap, params
][:])
join = ", "
joined = false
- for o in opts
+ for o : opts
match o
| ("j", j):
joined = true
@@ -483,7 +483,7 @@ const intparams = {params
("x", false),
("w", true),
("p", true)][:])
- for o in opts
+ for o : opts
match o
| ("x", ""): ip.base = 16
| ("w", wid): ip.padto = getint(wid, "fmt: width must be integer")
@@ -511,7 +511,7 @@ const strfmt = {sb, str, params
("e", false),
][:])
- for o in opts
+ for o : opts
match o
| ("w", wid): w = getint(wid, "fmt: width must be integer")
| ("p", pad): p = decode(pad)
@@ -523,14 +523,14 @@ const strfmt = {sb, str, params
iassert(p >= 0, "pad must be >= 0")
std.slfree(opts)
if raw
- for b in str
+ for b : str
if esc
sbputs(sb, "\\x")
;;
intfmt(sb, [.padto=2, .padfill='0', .base=16], false, b)
;;
elif esc
- for b in str
+ for b : str
if isprint(b)
sbputb(sb, b)
else
diff --git a/lib/std/intparse.myr b/lib/std/intparse.myr
index e9686b3..18cc478 100644
--- a/lib/std/intparse.myr
+++ b/lib/std/intparse.myr
@@ -52,7 +52,7 @@ generic doparse = {s, isneg, base -> option(@a::(integral,numeric))
var cv : int32
v = 0
- for c in std.bychar(s)
+ for c : std.bychar(s)
if c == '_'
continue
;;
diff --git a/lib/std/optparse.myr b/lib/std/optparse.myr
index a2cf06c..0569dfc 100644
--- a/lib/std/optparse.myr
+++ b/lib/std/optparse.myr
@@ -153,7 +153,7 @@ const optdone = {ctx
}
const optinfo = {ctx, opt
- for o in ctx.optdef.opts
+ for o : ctx.optdef.opts
if o.opt == opt
-> `Some (o.arg.len != 0, !o.optional, o.dest)
;;
@@ -189,13 +189,13 @@ const optusage = {prog, def
sb = mksb()
std.sbfmt(sb, "usage: {} [-h?", prog)
- for o in def.opts
+ for o : def.opts
if o.arg.len == 0
std.sbfmt(sb, "{}", o.opt)
;;
;;
std.sbfmt(sb, "] ")
- for o in def.opts
+ for o : def.opts
if o.arg.len != 0
std.sbfmt(sb, "[-{} {}] ", o.opt, o.arg)
;;
@@ -203,7 +203,7 @@ const optusage = {prog, def
std.sbfmt(sb, "{}\n", def.argdesc)
std.sbfmt(sb, "\t-h\tprint this help message\n")
std.sbfmt(sb, "\t-?\tprint this help message\n")
- for o in def.opts
+ for o : def.opts
std.sbfmt(sb, "\t-{}{}{}\t{}\n", o.opt, sep(o.arg), o.arg, o.desc)
;;
s = sbfin(sb)
diff --git a/lib/std/pathjoin.myr b/lib/std/pathjoin.myr
index 2cc2340..eb5e6fd 100644
--- a/lib/std/pathjoin.myr
+++ b/lib/std/pathjoin.myr
@@ -42,7 +42,7 @@ const pathnorm = {p
/*
"." is a no-op component, so we drop it. In order
to drop a component, we set it to the empty string,
- and remove it later on in the code.
+ and remove it later on.
*/
for i = 0; i < comps.len; i++
if sleq(comps[i], ".")
diff --git a/lib/std/resolve+posixy.myr b/lib/std/resolve+posixy.myr
index 50962a7..06250d5 100644
--- a/lib/std/resolve+posixy.myr
+++ b/lib/std/resolve+posixy.myr
@@ -123,7 +123,7 @@ const loadhosts = {
;;
lines = strsplit(h, "\n")
- for l in lines
+ for l : lines
/* trim comment */
match strfind(l, "#")
| `Some idx: l = l[:idx]
@@ -190,7 +190,7 @@ const loadresolv = {
;;
lines = strsplit(h, "\n")
- for l in lines
+ for l : lines
match strfind(l, "#")
| `Some _idx: l = l[:_idx]
| `None:
@@ -247,7 +247,7 @@ const dnsresolve = {host, rt
-> `Err (`Badhost)
;;
/* FIXME: Assumption: nameservers is not modified by other threads */
- for ns in nameservers
+ for ns : nameservers
nsrv = dnsconnect(ns)
if nsrv >= 0
r = dnsquery(nsrv, host, rt)
diff --git a/lib/std/slpush.myr b/lib/std/slpush.myr
index 1790073..b09069c 100644
--- a/lib/std/slpush.myr
+++ b/lib/std/slpush.myr
@@ -10,9 +10,9 @@ generic slpush = {sl, elt
slpush relies on implementation details
of slgrow for efficiency. Because bucket
sizes come in powers of two for all buckets
- <= 32k, and we only reallocate when we hit
- a bucket boundary, this is effectively
- growing the slice by powers of two.
+ <= 32k, and by powers of 1.5 for larger
+ slices, this is effectively growing the
+ slice by powers of two.
*/
slgrow(sl, sl#.len + 1)
sl#[sl#.len - 1] = elt
diff --git a/lib/std/test/bitset.myr b/lib/std/test/bitset.myr
index 0415be8..13706a6 100644
--- a/lib/std/test/bitset.myr
+++ b/lib/std/test/bitset.myr
@@ -36,7 +36,7 @@ const main = {
std.bsput(bs, 16)
std.bsput(bs, 7)
std.bsput(bs, 3)
- for e in std.bybsvalue(bs)
+ for e : std.bybsvalue(bs)
testr.check(ctx, e == expected[i], "expected[{}] ({}) != {}", i, e, expected[i])
i++
;;
@@ -63,7 +63,7 @@ const mkset = {elts
var bs
bs = std.mkbs()
- for e in elts
+ for e : elts
std.bsput(bs, e)
;;
-> bs
diff --git a/lib/std/test/bytealloc.myr b/lib/std/test/bytealloc.myr
index e6d87d6..7da7de8 100644
--- a/lib/std/test/bytealloc.myr
+++ b/lib/std/test/bytealloc.myr
@@ -3,9 +3,9 @@ use std
const main = {
var a : byte#[1000]
- for sz in [10, 100, 1000, 10000, 10000]
+ for sz : [10, 100, 1000, 10000, 10000]
std.put("sz: {}\n", sz)
- for cnt in [1, 10, 100]
+ for cnt : [1, 10, 100]
std.put("cnt: {}\n", cnt)
/* alloc forwards, dealloc forwards */
for var i = 0; i < cnt; i++
diff --git a/lib/std/test/fmt.myr b/lib/std/test/fmt.myr
index e8e3f22..67ba2e4 100644
--- a/lib/std/test/fmt.myr
+++ b/lib/std/test/fmt.myr
@@ -154,7 +154,7 @@ const pairfmt = {sb, ap, opts
x = std.vanext(ap)
std.sbfmt(sb, "formatted a pair: [{}, {}]", x.x, x.y)
- for opt in opts
+ for opt : opts
std.sbputc(sb, ' ')
match opt
| ("x", val): std.sbfmt(sb, "x={}", val)
diff --git a/lib/std/test/ipparse.myr b/lib/std/test/ipparse.myr
index 1ea14db..fd6140a 100644
--- a/lib/std/test/ipparse.myr
+++ b/lib/std/test/ipparse.myr
@@ -69,11 +69,11 @@ const eq = {ip, expected
if !std.sleq(p, e)
std.fput(1, "misparsed ip {}\n", ip)
std.put("parsed: ")
- for b in p
+ for b : p
std.put("{x}, ", b)
;;
std.put("\nexpected: ")
- for b in e
+ for b : e
std.put("{x}, ", b)
;;
std.put("\n")
diff --git a/lib/std/test/iterutil.myr b/lib/std/test/iterutil.myr
index dfa46fa..1d45a4d 100644
--- a/lib/std/test/iterutil.myr
+++ b/lib/std/test/iterutil.myr
@@ -4,21 +4,21 @@ const main = {
var n
n = 0
- for (x, i) in std.byenum([1,3,5,7,9][:])
+ for (x, i) : std.byenum([1,3,5,7,9][:])
std.assert(x == n, "invalid enum idx {}", x)
std.assert(i == n*2 + 1, "invalid enum val {}", i)
n++
;;
n = 0
- for (a, b) in std.byzip([0,2,4,6,8][:], [2,4][:])
+ for (a, b) : std.byzip([0,2,4,6,8][:], [2,4][:])
std.assert(a == n*2, "invalid val from a: {}", a)
std.assert(b == n*2 + 2, "invalid val from b: {}", b)
n++
;;
n = 0
- for x in std.byreverse([3, 2, 1, 0][:])
+ for x : std.byreverse([3, 2, 1, 0][:])
std.assert(x == n, "invalid reversed value {}, expected {}", x, n)
n++
;;
diff --git a/lib/std/test/striter.myr b/lib/std/test/striter.myr
index 2684f8d..90b38ed 100644
--- a/lib/std/test/striter.myr
+++ b/lib/std/test/striter.myr
@@ -6,13 +6,13 @@ const main = {
var i
i = 0
- for c in std.bychar("abc")
+ for c : std.bychar("abc")
std.assert(chars[i++] == c, "wrong char")
;;
std.assert(i == chars.len, "wrong split count")
i = 0
- for sp in std.bysplit("foo+++bar", "++")
+ for sp : std.bysplit("foo+++bar", "++")
std.assert(std.streq(splits[i++], sp), "wrong split {}", sp)
;;
std.assert(i == splits.len, "wrong split count")