summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-09-12 09:01:39 -0700
committerOri Bernstein <ori@eigenstate.org>2015-09-15 23:01:09 -0700
commit610852e18629b8a9a4c4f4ed6e6fc7a336152511 (patch)
treeb69e2c8d29091b688115a499a50521d6d81cad1a
parentae9a74441cba3160943ad18bf500781143bff096 (diff)
downloadmc-610852e18629b8a9a4c4f4ed6e6fc7a336152511.tar.gz
Move to use 'for var i = ...' construct.
-rw-r--r--lib/bio/bio.myr13
-rw-r--r--lib/regex/compile.myr26
-rw-r--r--lib/regex/interp.myr7
-rw-r--r--lib/std/alloc.myr24
-rw-r--r--lib/std/bigint.myr21
-rw-r--r--lib/std/bitset.myr20
-rw-r--r--lib/std/cmp.myr3
-rw-r--r--lib/std/cstrconv.myr12
-rw-r--r--lib/std/env+plan9.myr3
-rw-r--r--lib/std/fmtfuncs.myr4
-rw-r--r--lib/std/htab.myr6
-rw-r--r--lib/std/ipparse.myr8
-rw-r--r--lib/std/mkpath.myr3
-rw-r--r--lib/std/putint.myr8
-rw-r--r--lib/std/rand.myr14
-rw-r--r--lib/std/resolve+posixy.myr8
-rw-r--r--lib/std/search.myr4
-rw-r--r--lib/std/slcp.myr5
-rw-r--r--lib/std/slfill.myr4
-rw-r--r--lib/std/strfind.myr8
-rw-r--r--lib/std/strjoin.myr5
-rw-r--r--lib/std/strstrip.myr3
-rw-r--r--lib/std/utf.myr6
23 files changed, 77 insertions, 138 deletions
diff --git a/lib/bio/bio.myr b/lib/bio/bio.myr
index 3ad9760..301822b 100644
--- a/lib/bio/bio.myr
+++ b/lib/bio/bio.myr
@@ -291,9 +291,7 @@ const ensurecodepoint = {f
little endian format
*/
generic putle = {f, v : @a::(numeric,integral)
- var i
-
- for i = 0; i < sizeof(@a); i++
+ for var i = 0; i < sizeof(@a); i++
putb(f, (v & 0xff) castto(byte))
v >>= 8
;;
@@ -305,9 +303,7 @@ generic putle = {f, v : @a::(numeric,integral)
big endian format
*/
generic putbe = {f, v : @a::(numeric,integral)
- var i
-
- for i = sizeof(@a); i != 0; i--
+ for var i = sizeof(@a); i != 0; i--
putb(f, ((v >> ((i-1)*8)) & 0xff) castto(byte))
;;
-> sizeof(@a)
@@ -360,7 +356,6 @@ const readln = {f
const readdelim = {f, delim, drop
var ret
- var i, j
ret = [][:]
while true
@@ -374,9 +369,9 @@ const readdelim = {f, delim, drop
-> `std.None
;;
;;
- for i = f.rstart; i < f.rend; i++
+ for var i = f.rstart; i < f.rend; i++
if f.rbuf[i] == delim[0]
- for j = 0; j < delim.len; j++
+ for var j = 0; j < delim.len; j++
if f.rbuf[i + j] != delim[j]
goto nextiterread
;;
diff --git a/lib/regex/compile.myr b/lib/regex/compile.myr
index 28d7ce8..f51f7d1 100644
--- a/lib/regex/compile.myr
+++ b/lib/regex/compile.myr
@@ -142,14 +142,14 @@ const genranges = {re, sl
}
const bound = {buf, len, fill
- var i, s
+ var s
if len == 1
buf[0] = 0x7f
else
s = len castto(byte)
buf[0] = (0xff << (8 - s)) | (fill >> (s + 1))
- for i = 1; i < len; i++
+ for var i = 1; i < len; i++
buf[i] = 0x80 | (fill >> 2)
;;
;;
@@ -163,12 +163,11 @@ type rangetrie = struct
;;
const rtdump = {rt, ind
- var i
var l, h
indent(ind)
std.put("Range (end = {}) {{\n", rt.end)
- for i = 0; i < rt.ranges.len; i++
+ for var i = 0; i < rt.ranges.len; i++
indent(ind + 1)
(l, h) = rt.ranges[i]
std.put("0x{x}-0x{x}: \n", l, h)
@@ -179,8 +178,7 @@ const rtdump = {rt, ind
}
const indent = {ind
- var i
- for i = 0; i < ind; i++
+ for var i = 0; i < ind; i++
std.put("\t")
;;
}
@@ -273,10 +271,9 @@ const rangeprogsize = {rt
/* calculates the forward jump distance for a utf8 character range */
const jmpdist = {n
var d
- var i
d = n - 1
- for i = n - 1; i > 0; i--
+ for var i = n - 1; i > 0; i--
d += i
;;
-> d
@@ -344,11 +341,10 @@ const genquest = {re, q
const genchar = {re, c
var b : byte[4]
var n
- var i
n = std.encode(b[:], c)
std.assert(n > 0 && n < 4, "non-utf character in regex\n")
- for i = 0; i < n; i++
+ for var i = 0; i < n; i++
append(re, `Ibyte b[i])
;;
-> re.proglen
@@ -366,12 +362,10 @@ const append = {re, insn
/* instruction dump */
const idump = {re
- var i
-
if !re.debug
->
;;
- for i = 0; i < re.proglen; i++
+ for var i = 0; i < re.proglen; i++
std.put("{}:\t", i)
match re.prog[i]
/* Char matching. Consume exactly one byte from the string. */
@@ -400,12 +394,10 @@ const idump = {re
/* AST dump */
const dump = {re, t, indent
- var i
-
if !re.debug
->
;;
- for i = 0; i < indent; i++
+ for var i = 0; i < indent; i++
std.put(" ")
;;
match t#
@@ -447,7 +439,7 @@ const dump = {re, t, indent
| `Ranges rl:
std.put("Ranges")
for r in rl
- for i = 0; i < indent + 1; i++
+ for var i = 0; i < indent + 1; i++
std.put(" ")
;;
std.put("\t({}-{})\n", r[0], r[1])
diff --git a/lib/regex/interp.myr b/lib/regex/interp.myr
index fc179c0..b6710a7 100644
--- a/lib/regex/interp.myr
+++ b/lib/regex/interp.myr
@@ -46,10 +46,9 @@ const cleanup = {re
const getmatches = {re, thr
var ret
- var i
ret = std.slalloc(re.nmatch)
- for i = 0; i < re.nmatch; i++
+ for var i = 0; i < re.nmatch; i++
if thr.mstart[i] != -1 && thr.mend[i] != -1
ret[i] = re.str[thr.mstart[i]:thr.mend[i]]
else
@@ -62,7 +61,7 @@ const getmatches = {re, thr
/* returns a matching thread, or Zthr if no threads matched */
const run = {re
- var i, ip
+ var ip
var consumed
var thr
var states
@@ -71,7 +70,7 @@ const run = {re
re.runq = mkthread(re, 0)
re.runq.mstart = std.slalloc(re.nmatch)
re.runq.mend = std.slalloc(re.nmatch)
- for i = 0; i < re.nmatch; i++
+ for var i = 0; i < re.nmatch; i++
re.runq.mstart[i] = -1
re.runq.mend[i] = -1
;;
diff --git a/lib/std/alloc.myr b/lib/std/alloc.myr
index ed3b023..ef0037b 100644
--- a/lib/std/alloc.myr
+++ b/lib/std/alloc.myr
@@ -80,9 +80,7 @@ type chunk = struct /* NB: must be smaller than sizeof(slab) */
;;
const __init__ = {
- var i
-
- for i = 0; i < buckets.len && (Align << i) <= Bktmax; i++
+ for var i = 0; i < buckets.len && (Align << i) <= Bktmax; i++
bktinit(&buckets[i], Align << i)
;;
}
@@ -162,7 +160,7 @@ generic slfree = {sl
/* Grows a slice */
generic slgrow = {sl : @a[:], len
- var i, n
+ var n
var new
/* if the slice doesn't need a bigger bucket, we don't need to realloc. */
@@ -172,7 +170,7 @@ generic slgrow = {sl : @a[:], len
new = slalloc(len)
n = min(len, sl.len)
- for i = 0; i < n; i++
+ for var i = 0; i < n; i++
new[i] = sl[i]
;;
if sl.len > 0
@@ -207,9 +205,7 @@ const zbytealloc = {sz
}
const zfill = {sl
- var i
-
- for i = 0; i < sl.len; i++
+ for var i = 0; i < sl.len; i++
sl[i] = 0
;;
}
@@ -258,7 +254,7 @@ const bktinit = {b, sz
/* Creates a slab for bucket 'bkt', and fills the chunk list */
const mkslab = {bkt
- var i, p, s
+ var p, s
var b, bnext
var off /* offset of chunk head */
@@ -287,7 +283,7 @@ const mkslab = {bkt
off = align(sizeof(slab), Align)
bnext = nextchunk(s castto(chunk#), off)
s.freehd = bnext
- for i = 0; i < bkt.nper; i++
+ for var i = 0; i < bkt.nper; i++
b = bnext
bnext = nextchunk(b, bkt.sz)
b.next = bnext
@@ -365,10 +361,10 @@ Finds the correct bucket index to allocate from
for allocations of size 'sz'
*/
const bktnum = {sz
- var i, bktsz
+ var bktsz
bktsz = Align
- for i = 0; bktsz <= Bktmax; i++
+ for var i = 0; bktsz <= Bktmax; i++
if bktsz >= sz
-> i
;;
@@ -382,11 +378,11 @@ returns the actual size we allocated for a given
size request
*/
const allocsz = {sz
- var i, bktsz
+ var bktsz
if sz <= Bktmax
bktsz = Align
- for i = 0; bktsz <= Bktmax; i++
+ for var i = 0; bktsz <= Bktmax; i++
if bktsz >= sz
-> bktsz
;;
diff --git a/lib/std/bigint.myr b/lib/std/bigint.myr
index 719fd69..120663c 100644
--- a/lib/std/bigint.myr
+++ b/lib/std/bigint.myr
@@ -229,12 +229,10 @@ const bigiszero = {v
}
const bigeq = {a, b
- var i
-
if a.sign != b.sign || a.dig.len != b.dig.len
-> false
;;
- for i = 0; i < a.dig.len; i++
+ for var i = 0; i < a.dig.len; i++
if a.dig[i] != b.dig[i]
-> false
;;
@@ -251,7 +249,6 @@ generic bigeqi = {a, b
}
const bigcmp = {a, b
- var i
var da, db, sa, sb
sa = a.sign castto(int64)
@@ -266,7 +263,7 @@ const bigcmp = {a, b
-> signedorder(sa)
else
/* otherwise, the one with the first larger digit is bigger */
- for i = a.dig.len; i > 0; i--
+ for var i = a.dig.len; i > 0; i--
da = a.dig[i - 1] castto(int64)
db = b.dig[i - 1] castto(int64)
-> signedorder(sa * (da - db))
@@ -647,7 +644,6 @@ generic bigdivi = {a, b
generic bigshli = {a, s : @a::(numeric,integral)
var off, shift
var t, carry
- var i
assert(s >= 0, "shift amount must be positive")
off = (s castto(uint64)) / 32
@@ -659,15 +655,15 @@ generic bigshli = {a, s : @a::(numeric,integral)
;;
a.dig = slzgrow(a.dig, 1 + a.dig.len + off castto(size))
/* blit over the base values */
- for i = a.dig.len; i > off; i--
+ for var i = a.dig.len; i > off; i--
a.dig[i - 1] = a.dig[i - 1 - off]
;;
- for i = 0; i < off; i++
+ for var i = 0; i < off; i++
a.dig[i] = 0
;;
/* and shift over by the remainder */
carry = 0
- for i = 0; i < a.dig.len; i++
+ for var i = 0; i < a.dig.len; i++
t = (a.dig[i] castto(uint64)) << shift
a.dig[i] = (t | carry) castto(uint32)
carry = t >> 32
@@ -679,22 +675,21 @@ generic bigshli = {a, s : @a::(numeric,integral)
generic bigshri = {a, s
var off, shift
var t, carry
- var i
assert(s >= 0, "shift amount must be positive")
off = (s castto(uint64)) / 32
shift = (s castto(uint64)) % 32
/* blit over the base values */
- for i = 0; i < a.dig.len - off; i++
+ for var i = 0; i < a.dig.len - off; i++
a.dig[i] = a.dig[i + off]
;;
- for i = a.dig.len - off; i < a.dig.len; i++
+ for var i = a.dig.len - off; i < a.dig.len; i++
a.dig[i] = 0
;;
/* and shift over by the remainder */
carry = 0
- for i = a.dig.len; i > 0; i--
+ for var i = a.dig.len; i > 0; i--
t = (a.dig[i - 1] castto(uint64))
a.dig[i - 1] = (carry | (t >> shift)) castto(uint32)
carry = t << (32 - shift)
diff --git a/lib/std/bitset.myr b/lib/std/bitset.myr
index 7843c7d..edf123e 100644
--- a/lib/std/bitset.myr
+++ b/lib/std/bitset.myr
@@ -89,37 +89,33 @@ generic bshas = {bs, v
}
const bsunion = {a, b
- var i
-
eqsz(a, b)
- for i = 0; i < b.bits.len; i++
+ for var i = 0; i < b.bits.len; i++
a.bits[i] |= b.bits[i]
;;
}
const bsintersect = {a, b
- var i, n
+ var n
n = min(a.bits.len, b.bits.len)
- for i = 0; i < n; i++
+ for var i = 0; i < n; i++
a.bits[i] &= b.bits[i]
;;
}
const bsdiff = {a, b
- var i, n
+ var n
n = min(b.bits.len, a.bits.len)
- for i = 0; i < n; i++
+ for var i = 0; i < n; i++
a.bits[i] &= ~b.bits[i]
;;
}
const bsissubset = {a, b
- var i
-
eqsz(a, b);
- for i = 0; i < a.bits.len; i++
+ for var i = 0; i < a.bits.len; i++
if (b.bits[i] & a.bits[i]) != b.bits[i]
-> false
;;
@@ -128,10 +124,8 @@ const bsissubset = {a, b
}
const bseq = {a, b
- var i
-
eqsz(a, b)
- for i = 0; i < a.bits.len; i++
+ for var i = 0; i < a.bits.len; i++
if a.bits[i] != b.bits[i]
-> false
;;
diff --git a/lib/std/cmp.myr b/lib/std/cmp.myr
index edc5fe3..8c01bfc 100644
--- a/lib/std/cmp.myr
+++ b/lib/std/cmp.myr
@@ -25,10 +25,9 @@ generic numcmp = {a, b
const strcmp = {a, b
var l
- var i
l = min(a.len, b.len)
- for i = 0; i < l; i++
+ for var i = 0; i < l; i++
if a[i] < b[i]
-> `Before
elif a[i] > b[i]
diff --git a/lib/std/cstrconv.myr b/lib/std/cstrconv.myr
index fa9e0bf..a517e19 100644
--- a/lib/std/cstrconv.myr
+++ b/lib/std/cstrconv.myr
@@ -7,9 +7,7 @@ pkg std =
;;
const cstrconv = {buf
- var i
-
- for i = 0; i < buf.len; i++
+ for var i = 0; i < buf.len; i++
if buf[i] == 0
-> buf[:i]
;;
@@ -29,12 +27,10 @@ const cstrconvp = {p
}
const cstrlen = {buf
- var i
-
- for i = 0; i < buf.len; i++
+ for var i = 0; i < buf.len; i++
if buf[i] == 0
- break
+ -> i
;;
;;
- -> i
+ -> 0
}
diff --git a/lib/std/env+plan9.myr b/lib/std/env+plan9.myr
index 4a95ed7..134aa75 100644
--- a/lib/std/env+plan9.myr
+++ b/lib/std/env+plan9.myr
@@ -21,8 +21,7 @@ var envkey : byte[:][:]
var envval : byte[:][:]
const envfind = {key
- var i
- for i = 0; i < envkey.len; i++
+ for var i = 0; i < envkey.len; i++
if std.sleq(envkey[i], key)
-> `Some envval[i]
;;
diff --git a/lib/std/fmtfuncs.myr b/lib/std/fmtfuncs.myr
index abe5e75..e20805e 100644
--- a/lib/std/fmtfuncs.myr
+++ b/lib/std/fmtfuncs.myr
@@ -38,12 +38,12 @@ const bigfmt = {sb, ap, opts
}
const bsfmt = {sb, ap, opts
- var i, bs, sep
+ var bs, sep
bs = vanext(ap)
sep = ""
sbputs(sb, "bitset{")
- for i = 0; i < bsmax(bs); i++
+ for var i = 0; i < bsmax(bs); i++
if bshas(bs, i)
sbfmt(sb, sep)
sbfmt(sb, "{}", i)
diff --git a/lib/std/htab.myr b/lib/std/htab.myr
index 500219d..0f7384d 100644
--- a/lib/std/htab.myr
+++ b/lib/std/htab.myr
@@ -45,7 +45,6 @@ generic resize = {ht, sz
var oldv
var oldh
var oldd
- var i
oldk = ht.keys
oldv = ht.vals
@@ -58,7 +57,7 @@ generic resize = {ht, sz
ht.nelt = 0
ht.ndead = 0
- for i = 0; i < oldk.len; i++
+ for var i = 0; i < oldk.len; i++
if oldh[i] != 0 && !oldd[i]
htput(ht, oldk[i], oldv[i])
;;
@@ -191,12 +190,11 @@ generic hthas = {ht, k
generic htkeys = {ht
var keys
- var i
var j
keys = slalloc(ht.nelt)
j = 0
- for i = 0; i < ht.keys.len; i++
+ for var i = 0; i < ht.keys.len; i++
if ht.hashes[i] != 0 && !ht.dead[i]
keys[j++] = ht.keys[i]
;;
diff --git a/lib/std/ipparse.myr b/lib/std/ipparse.myr
index 17bc6f0..8c6f7c7 100644
--- a/lib/std/ipparse.myr
+++ b/lib/std/ipparse.myr
@@ -35,14 +35,6 @@ const ipparse = {ip
const ip4parse = {ip
var a, b, c, d
var ok
- /*
- var addr
- var last : size
- var x : option(int32)
- var val : int32 /* need int32 to check for overflow */
- var i
- var j : size
- */
(a, ip, ok) = num(ip, 0, 255, 10, '.', true)
(ip, ok) = delim(ip, '.', ok)
diff --git a/lib/std/mkpath.myr b/lib/std/mkpath.myr
index b7e8e24..75c1b9c 100644
--- a/lib/std/mkpath.myr
+++ b/lib/std/mkpath.myr
@@ -7,9 +7,8 @@ pkg std =
const mkpath = {p
var st
- var i
- for i = 0; i < p.len; i++
+ for var i = 0; i < p.len; i++
if p[i] == '/' castto(byte) && i != 0
st = mkdir(p[:i], 0o777)
if st != 0 && (st castto(errno)) != Eexist
diff --git a/lib/std/putint.myr b/lib/std/putint.myr
index 711001d..9ff92dd 100644
--- a/lib/std/putint.myr
+++ b/lib/std/putint.myr
@@ -22,10 +22,10 @@ generic putle8 = {buf, v; -> putle(buf, v castto(uint64), 1)}
generic putbe8 = {buf, v; -> putbe(buf, v castto(uint64), 1)}
const putbe = {buf, val, n
- var i, k
+ var k
assert(buf.len >= n, "buffer too small")
- for i = 0; i < n; i++
+ for var i = 0; i < n; i++
k = val >> (8*(n-i-1))
buf[i] = (k & 0xff) castto(byte)
;;
@@ -33,10 +33,8 @@ const putbe = {buf, val, n
}
const putle = {buf, val, n
- var i
-
assert(buf.len >= n, "buffer too small")
- for i = 0; i < n; i++
+ for var i = 0; i < n; i++
buf[i] = (val & 0xff) castto(byte)
val >>= 8
;;
diff --git a/lib/std/rand.myr b/lib/std/rand.myr
index 2e8c73e..6ca23e6 100644
--- a/lib/std/rand.myr
+++ b/lib/std/rand.myr
@@ -75,13 +75,11 @@ const delrng = {rng
/* initializes a random number generator from the seed `seed`. */
const init = {rng, seed
- var i
-
- for i = 0; i < 624; i++
+ for var i = 0; i < 624; i++
rng.state[i] = seed
seed = 1812433253 * (seed ^ (seed >> 30)) + i + 1
;;
- rng.i = i
+ rng.i = 624
}
/*
@@ -117,10 +115,10 @@ generic rand = {rng, lo, hi -> @a::(integral,numeric)
may be negative, if the type is signed.
*/
generic randN = {rng -> @a::(integral,numeric)
- var i, val
+ var val
val = 0
- for i = 0; i < sizeof(@a)/4; i++
+ for var i = 0; i < sizeof(@a)/4; i++
val <<= 8*sizeof(@a)
val |= rand32(rng) castto(@a::(integral,numeric))
;;
@@ -147,10 +145,10 @@ const rand32 = {rng
}
const randbytes = {rng, buf
- var i, n, r
+ var n, r
n = 0
- for i = 0; i < buf.len/4; i++
+ for var i = 0; i < buf.len/4; i++
r = rand32(rng)
buf[n++] = (r >> 0 & 0xff) castto(byte)
buf[n++] = (r >> 8 & 0xff) castto(byte)
diff --git a/lib/std/resolve+posixy.myr b/lib/std/resolve+posixy.myr
index 185c9d7..f158eea 100644
--- a/lib/std/resolve+posixy.myr
+++ b/lib/std/resolve+posixy.myr
@@ -314,7 +314,6 @@ const rquery = {srv, id
const hosts = {pkt, id : uint16
var off
var v, q, a
- var i
var hinf : hostinfo[:]
off = 0
@@ -330,7 +329,7 @@ const hosts = {pkt, id : uint16
(v, off) = unpack16(pkt, off) /* arcount */
/* skip past query records */
- for i = 0; i < q; i++
+ for var i = 0; i < q; i++
off = skipname(pkt, off) /* name */
(v, off) = unpack16(pkt, off) /* type */
(v, off) = unpack16(pkt, off) /* class */
@@ -338,7 +337,7 @@ const hosts = {pkt, id : uint16
/* parse answer records */
hinf = slalloc(a castto(size))
- for i = 0; i < a; i++
+ for var i = 0; i < a; i++
off = skipname(pkt, off) /* name */
(v, off) = unpack16(pkt, off) /* type */
(v, off) = unpack16(pkt, off) /* class */
@@ -392,13 +391,12 @@ const unpack32 = {buf, off
}
const packname = {buf, off : size, host
- var i
var start
var last
start = off
last = 0
- for i = 0; i < host.len; i++
+ for var i = 0; i < host.len; i++
if host[i] == ('.' castto(byte))
off += addseg(buf, off, host[last:i])
last = i + 1
diff --git a/lib/std/search.myr b/lib/std/search.myr
index 725e419..fa2ae40 100644
--- a/lib/std/search.myr
+++ b/lib/std/search.myr
@@ -8,9 +8,7 @@ pkg std =
/* linear search over a list of values */
generic lsearch = {sl, val, cmp
- var i
-
- for i = 0; i < sl.len; i++
+ for var i = 0; i < sl.len; i++
match cmp(sl[i], val)
| `Equal:
-> `Some i
diff --git a/lib/std/slcp.myr b/lib/std/slcp.myr
index 1035a29..b2c9760 100644
--- a/lib/std/slcp.myr
+++ b/lib/std/slcp.myr
@@ -6,7 +6,6 @@ pkg std =
;;
generic slcp = {a : @a[:], b : @a[:]
- var i
var addr_a, addr_b
assert(a.len == b.len, "arguments to slcp() must be of equal length")
@@ -14,11 +13,11 @@ generic slcp = {a : @a[:], b : @a[:]
addr_a = a castto(@a#) castto(intptr)
addr_b = b castto(@a#) castto(intptr)
if addr_a <= addr_b
- for i = 0; i < a.len; i++
+ for var i = 0; i < a.len; i++
a[i] = b[i]
;;
else
- for i = a.len; i > 0; i--
+ for var i = a.len; i > 0; i--
a[i - 1] = b[i - 1]
;;
;;
diff --git a/lib/std/slfill.myr b/lib/std/slfill.myr
index d90e8f5..d09502f 100644
--- a/lib/std/slfill.myr
+++ b/lib/std/slfill.myr
@@ -3,9 +3,7 @@ pkg std =
;;
generic slfill = {sl, v
- var i
-
- for i = 0; i < sl.len; i++
+ for var i = 0; i < sl.len; i++
sl[i] = v
;;
-> sl
diff --git a/lib/std/strfind.myr b/lib/std/strfind.myr
index 0ec0e85..7336b8d 100644
--- a/lib/std/strfind.myr
+++ b/lib/std/strfind.myr
@@ -16,13 +16,13 @@ const strrfind = {haystack, needle
}
const strfindin = {haystack, needle, start, end
- var i, j, inc : size
+ var inc : size
inc = 1
if start > end
inc = -1
;;
- for i = start; i != end; i += inc
+ for var i = start; i != end; i += inc
/*
if we knew the direction we could terminate early,
but we allow the start and end to be passed in.
@@ -31,7 +31,7 @@ const strfindin = {haystack, needle, start, end
continue
;;
if haystack[i] == needle[0]
- for j = 0; j < needle.len; j++
+ for var j = 0; j < needle.len; j++
if haystack[i + j] != needle[j]
goto nextiter
;;
@@ -48,4 +48,4 @@ const strhas = {haystack, needle
| `Some _: -> true
| `None: -> false
;;
-} \ No newline at end of file
+}
diff --git a/lib/std/strjoin.myr b/lib/std/strjoin.myr
index 518a4dc..b8dc813 100644
--- a/lib/std/strjoin.myr
+++ b/lib/std/strjoin.myr
@@ -13,11 +13,10 @@ const strcat = {a, b
const strjoin = {strings, delim
var len, off
- var i
var s
len = 0
- for i = 0; i < strings.len; i++
+ for var i = 0; i < strings.len; i++
len += strings[i].len
;;
if strings.len > 0
@@ -26,7 +25,7 @@ const strjoin = {strings, delim
s = slalloc(len)
off = 0
- for i = 0; i < strings.len; i++
+ for var i = 0; i < strings.len; i++
slcp(s[off:off + strings[i].len], strings[i])
off += strings[i].len
/* we don't want to terminate the last string with delim */
diff --git a/lib/std/strstrip.myr b/lib/std/strstrip.myr
index a3d54fa..4f8a539 100644
--- a/lib/std/strstrip.myr
+++ b/lib/std/strstrip.myr
@@ -26,12 +26,11 @@ const strfstrip = {str
/* strip reverse on str */
const strrstrip = {str
- var i
var end
/* scan backwards for start of utf8 char */
end = str.len
- for i = str.len; i != 0; i--
+ for var i = str.len; i != 0; i--
if str[i - 1] & 0x80 == 0 || str[i-1] & 0xc0 != 0x80
if !isspace(decode(str[i-1:]))
break
diff --git a/lib/std/utf.myr b/lib/std/utf.myr
index 03cc8bb..a5ef05d 100644
--- a/lib/std/utf.myr
+++ b/lib/std/utf.myr
@@ -29,7 +29,6 @@ const charlen = {c
const encode = {buf, c
var len
var mark
- var i
len = charlen(c)
if len < 0 || buf.len < len
@@ -42,7 +41,7 @@ const encode = {buf, c
mark = (((1 << (8 - len)) - 1) ^ 0xff) castto(char)
;;
- for i = len - 1; i > 0; i--
+ for var i = len - 1; i > 0; i--
buf[i] = (c & 0x3f | 0x80) castto(byte)
c >>= 6
;;
@@ -63,7 +62,6 @@ const striter = {str
var len
var mask
var chr
- var i
var c
var tmp
@@ -94,7 +92,7 @@ const striter = {str
mask = (1 << (8 - len)) - 1
chr = (c castto(uint32)) & mask
- for i = 1; i < len; i++
+ for var i = 1; i < len; i++
tmp = str[i] castto(uint32)
chr = (chr << 6) | (tmp & 0x3f)
;;