ref: e83d16d5bd500b8e1913a836560f943a757ab86b
parent: 6121d28dc28103cb85b22fe404daaa8c441790b4
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Aug 27 11:55:36 EDT 2016
Rename `std.Fail to `std.Err.
--- a/bench/regex-match.myr
+++ b/bench/regex-match.myr
@@ -13,7 +13,7 @@
for i = 0; i < 100; i++
match regex.compile(".*")
| `std.Ok r: re = r
- | `std.Fail m: std.fatal("couldn't compile regex: %s\n", m)
+ | `std.Err m: std.fatal("couldn't compile regex: %s\n", m)
;;
match regex.exec(re, str)
--- a/lib/bio/bio.myr
+++ b/lib/bio/bio.myr
@@ -117,7 +117,7 @@
const dial = {srv, mode
match std.dial(srv)
| `std.Ok sock: -> `std.Ok mkfile(sock, mode)
- | `std.Fail m: -> `std.Fail m
+ | `std.Err m: -> `std.Err m
;;
}
@@ -136,7 +136,7 @@
const sysopen = {path, mode, openmode, perm
match std.openmode(path, openmode, (perm : int64))
| `std.Ok fd: -> `std.Ok mkfile(fd, mode)
- | `std.Fail e: -> `std.Fail "could not open fd"
+ | `std.Err e: -> `std.Err "could not open fd"
;;
}
@@ -232,7 +232,7 @@
| `std.Ok n:
count += n
d = d[n:]
- | `std.Fail err:
+ | `std.Err err:
if count == 0
-> `Err errtype(err)
else
@@ -268,7 +268,7 @@
f.rstart = f.rend = 0
match std.seek(f.fd, off, std.Seekset)
| `std.Ok ret: -> `std.Ok ret
- | `std.Fail e: -> `std.Fail errtype(e)
+ | `std.Err e: -> `std.Err errtype(e)
;;
}
@@ -604,7 +604,7 @@
| `std.Ok n:
count += n
src = src[n:]
- | `std.Fail e:
+ | `std.Err e:
-> `Err errtype(e)
;;
;;
@@ -646,7 +646,7 @@
| `std.Ok n:
count += n
f.rend += n
- | `std.Fail e:
+ | `std.Err e:
if count > 0
f.lasterr = e
else
--- a/lib/bio/test/bio-create.myr
+++ b/lib/bio/test/bio-create.myr
@@ -7,7 +7,7 @@
std.mkdir("tmpout", 0o755);
match bio.create("tmpout/test-create", bio.Wr, 0o644)
| `std.Ok bio: f = bio
- | `std.Fail m: std.fatal("Failed to open file: {}\n", m)
+ | `std.Err m: std.fatal("Failed to open file: {}\n", m)
;;
bio.close(f)
}
--- a/lib/bio/test/bio-delim.myr
+++ b/lib/bio/test/bio-delim.myr
@@ -7,7 +7,7 @@
match bio.open("data/lines", bio.Rd)
| `std.Ok bio: f = bio
- | `std.Fail m: std.fatal("Unable to open data file: {}\n", m)
+ | `std.Err m: std.fatal("Unable to open data file: {}\n", m)
;;
/* read first line */
--- a/lib/bio/test/bio-endianrd.myr
+++ b/lib/bio/test/bio-endianrd.myr
@@ -17,7 +17,7 @@
/* use the expected write data as read data */
match bio.open("data/bio-endianwr-expected", bio.Rd)
| `std.Ok bio: f = bio
- | `std.Fail m: std.fatal("Unable to open data file: {}\n", m)
+ | `std.Err m: std.fatal("Unable to open data file: {}\n", m)
;;
/* byte */
--- a/lib/bio/test/bio-endianwr.myr
+++ b/lib/bio/test/bio-endianwr.myr
@@ -10,7 +10,7 @@
match bio.create("tmpout/test-endianwr", bio.Wr, 0o644)
| `std.Ok bio: f = bio
- | `std.Fail m: std.fatal("Unable to open data file: {}\n", m)
+ | `std.Err m: std.fatal("Unable to open data file: {}\n", m)
;;
/* byte */
--- a/lib/bio/test/bio-peek.myr
+++ b/lib/bio/test/bio-peek.myr
@@ -8,7 +8,7 @@
match bio.open("data/datafile", bio.Rd)
| `std.Ok bio: f = bio
- | `std.Fail m: std.fatal("Unable to open data file: {}", m)
+ | `std.Err m: std.fatal("Unable to open data file: {}", m)
;;
std.assert(peekb(f) == 0x30, "wrong byte value read from datafile")
--- a/lib/bio/test/bio-read.myr
+++ b/lib/bio/test/bio-read.myr
@@ -9,7 +9,7 @@
match bio.open("data/datafile", bio.Rd)
| `std.Ok bio: f = bio
- | `std.Fail m: std.fatal("Unable to open data file: {}", m)
+ | `std.Err m: std.fatal("Unable to open data file: {}", m)
;;
/* read a 4 byte chunk j*/
--- a/lib/bio/test/bio-unitwr.myr
+++ b/lib/bio/test/bio-unitwr.myr
@@ -5,7 +5,7 @@
var f
match bio.create("tmpout/test-unitwr", bio.Wr, 0o644)
| `std.Ok bio: f = bio
- | `std.Fail m: std.fatal("Unable to open data file: {}\n", m)
+ | `std.Err m: std.fatal("Unable to open data file: {}\n", m)
;;
bio.putb(f, 42)
bio.putc(f, 'ה')
--- a/lib/bio/test/bio-write.myr
+++ b/lib/bio/test/bio-write.myr
@@ -9,7 +9,7 @@
match bio.create("tmpout/test-write", bio.Wr, 0o644)
| `std.Ok bio: f = bio
- | `std.Fail m: std.fatal("Unable to open data file: {}", m)
+ | `std.Err m: std.fatal("Unable to open data file: {}", m)
;;
/* write a 5 byte chunk */
--- a/lib/date/parse.myr
+++ b/lib/date/parse.myr
@@ -53,7 +53,7 @@
d.actual -= (d.tzoff : std.time)
match err
- | `std.Some e: -> `std.Fail e
+ | `std.Some e: -> `std.Err e
| `std.None: /* no error, we're ok */
;;
--- a/lib/date/test/parse.myr
+++ b/lib/date/test/parse.myr
@@ -9,7 +9,7 @@
| `std.Ok d:
std.assert(d.actual == 0, "got wrong date")
eq(std.bfmt(buf[:], "{D}", d), "1969-12-31 16:00:00 -0800")
- | `std.Fail m:
+ | `std.Err m:
std.fatal("failed to parse date: {}\n", m)
;;
@@ -16,7 +16,7 @@
match date.parsefmt("%Y-%m-%d", "1969 12 31")
| `std.Ok d:
std.fatal("should have errored")
- | `std.Fail m:
+ | `std.Err m:
eq(std.bfmt(buf[:], "{}", m), "expected separator '-', found ' '")
;;
@@ -25,7 +25,7 @@
| `std.Ok d:
std.assert(d.actual == 0, "got wrong date")
eq(std.bfmt(buf[:], "{D}", d), "1970-1-01 00:00:00 +0000")
- | `std.Fail m:
+ | `std.Err m:
std.fatal("failed to parse date: {}\n", m)
;;
@@ -34,7 +34,7 @@
| `std.Ok d:
std.assert(d.actual == -1173675600 * 1_000_000, "wrong timestamp")
eq(std.bfmt(buf[:], "{D}", d), "1932-10-23 00:00:00 +0500")
- | `std.Fail m:
+ | `std.Err m:
std.fatal("Failed to parse date: {}", m)
;;
}
--- a/lib/date/zoneinfo+posixy.myr
+++ b/lib/date/zoneinfo+posixy.myr
@@ -81,7 +81,7 @@
/* check magic */
match std.slurp(file)
| `std.Ok d: p = d
- | `std.Fail m:
+ | `std.Err m:
-> std.zalloc()
;;
--- a/lib/fileutil/walk.myr
+++ b/lib/fileutil/walk.myr
@@ -29,7 +29,7 @@
if std.fisdir(p)
match std.diropen(p)
| `std.Ok d: std.slpush(&itp.dirstk, d)
- | `std.Fail e: /* ? */
+ | `std.Err e: /* ? */
;;
std.slpush(&itp.curdir, p)
goto nextfile
--- a/lib/inifile/parse.myr
+++ b/lib/inifile/parse.myr
@@ -20,7 +20,7 @@
const load = {path
match std.open(path, std.Ordonly)
| `std.Ok fd: -> loadf(fd)
- | `std.Fail e: -> `std.Fail `Fileerr
+ | `std.Err e: -> `std.Err `Fileerr
;;
}
@@ -68,7 +68,7 @@
-> `std.Ok ini
| `std.Some e:
free(ini)
- -> `std.Fail e
+ -> `std.Err e
;;
}
--- a/lib/inifile/test/inifile.myr
+++ b/lib/inifile/test/inifile.myr
@@ -9,7 +9,7 @@
const failopen = {
match inifile.load("figment-of-my-imagination.ini")
| `std.Ok _: std.die("found imaginary file\n")
- | `std.Fail _: /* as expected */
+ | `std.Err _: /* as expected */
;;
}
--- a/lib/inifile/write.myr
+++ b/lib/inifile/write.myr
@@ -12,7 +12,7 @@
var ret
match bio.create(path, bio.Wr, 0o666)
- | `std.Fail e: -> false
+ | `std.Err e: -> false
| `std.Ok f:
ret = writeini(f, ini)
bio.close(f)
--- a/lib/regex/compile.myr
+++ b/lib/regex/compile.myr
@@ -13,7 +13,7 @@
type parseresult = union
`Some ast#
`None
- `Fail status
+ `Err status
;;
/* Compiles a pattern into a regex */
@@ -26,11 +26,11 @@
re = std.mk([.pat = pat, .nmatch = 1])
match regexparse(re)
- | `None: -> `std.Fail `Incomplete
- | `Fail f: -> `std.Fail f
+ | `None: -> `std.Err `Incomplete
+ | `Err f: -> `std.Err f
| `Some t:
if re.pat.len != re.idx
- -> `std.Fail `Incomplete
+ -> `std.Err `Incomplete
else
-> `std.Ok t
;;
@@ -55,8 +55,8 @@
/* compiles a pattern into an allocated regex */
const regexcompile = {re, id
match regexparse(re)
- | `None: -> `std.Fail (`Incomplete)
- | `Fail f: -> `std.Fail f
+ | `None: -> `std.Err (`Incomplete)
+ | `Err f: -> `std.Err f
| `Some t:
/*
we can bail out of parsing early if we get
@@ -64,7 +64,7 @@
*/
if re.pat.len != re.idx
astfree(t)
- -> `std.Fail (`Incomplete)
+ -> `std.Err (`Incomplete)
;;
dump(re, t, 0)
append(re, `Ilbra 0, t)
@@ -75,7 +75,7 @@
astfree(t)
-> `std.Ok re
;;
- -> `std.Fail (`Noimpl)
+ -> `std.Err (`Noimpl)
}
const free = {re
@@ -476,12 +476,12 @@
-> `Some t
else
astfree(t)
- -> `Fail `Incomplete
+ -> `Err `Incomplete
;;
| `None:
-> `None
- | `Fail st:
- -> `Fail st
+ | `Err st:
+ -> `Err st
;;
}
@@ -499,9 +499,9 @@
ret = mk(re, `Alt (ret, rhs), idx)
| `None:
astfree(ret)
- -> `Fail (`Incomplete)
- | `Fail f:
- -> `Fail f
+ -> `Err (`Incomplete)
+ | `Err f:
+ -> `Err f
;;
;;
| other:
@@ -521,7 +521,7 @@
match catexpr(re)
| `Some rhs:
ret = mk(re, `Cat (t, rhs), idx)
- | `Fail f: -> `Fail f
+ | `Err f: -> `Err f
| `None: /* nothing */
;;
| other:
@@ -564,9 +564,9 @@
/* lower prec operators */
| '|': -> `None
| ')': -> `None
- | '*': -> `Fail `Badrep '*'
- | '+': -> `Fail `Badrep '+'
- | '?': -> `Fail `Badrep '?'
+ | '*': -> `Err `Badrep '*'
+ | '+': -> `Err `Badrep '+'
+ | '?': -> `Err `Badrep '?'
| '[': -> chrclass(re)
| '^': getc(re); ret = mk(re, `Bol, re.idx)
| '$': getc(re); ret = mk(re, `Eol, re.idx)
@@ -579,7 +579,7 @@
getc(re)
if matchc(re, '?')
if !matchc(re, ':')
- -> `Fail `Badrep '?'
+ -> `Err `Badrep '?'
;;
nocap = true
else
@@ -594,15 +594,15 @@
-> `Some mk(re, `Cap (m, s), idx)
;;
else
- -> `Fail `Unbalanced '('
+ -> `Err `Unbalanced '('
;;
- | `None: -> `Fail `Emptyparen
- | `Fail st: -> `Fail st
+ | `None: -> `Err `Emptyparen
+ | `Err st: -> `Err st
;;
| '\\':
getc(re) /* consume the slash */
if re.pat.len == re.idx
- -> `Fail `Incomplete
+ -> `Err `Incomplete
;;
-> escaped(re)
| c:
@@ -652,7 +652,7 @@
| 'n': ret = `Some mk(re, `Chr '\n', idx)
| 'b': ret = `Some mk(re, `Chr '\b', idx)
| 'u': ret = unichar(re, idx)
- | chr: ret = `Fail `Badescape chr
+ | chr: ret = `Err `Badescape chr
;;
-> ret
}
@@ -661,7 +661,7 @@
var c
if !matchc(re, '{')
- -> `Fail `Badescape 'u'
+ -> `Err `Badescape 'u'
;;
c = 0
@@ -670,7 +670,7 @@
c += std.charval(getc(re), 16)
;;
if !matchc(re, '}')
- -> `Fail `Badescape 'u'
+ -> `Err `Badescape 'u'
;;
-> `Some mk(re, `Chr c, idx)
}
@@ -683,7 +683,7 @@
var idx
if re.pat.len == re.idx
- -> `Fail (`Incomplete)
+ -> `Err (`Incomplete)
;;
n = 0
idx = re.idx
@@ -720,7 +720,7 @@
elif std.sleq(s, "Zs") || std.sleq(s, "Space_Separator")
tab = _ranges.tabblank[:]
else
- -> `Fail (`Badrange s)
+ -> `Err (`Badrange s)
;;
if !neg
t = mk(re, `Ranges std.sldup(tab), idx)
@@ -749,7 +749,7 @@
;;
if !matchc(re, ']')
std.slfree(rl)
- -> `Fail `Unbalanced '['
+ -> `Err `Unbalanced '['
;;
std.sort(rl, {a, b;
--- a/lib/regex/redump.myr
+++ b/lib/regex/redump.myr
@@ -28,7 +28,7 @@
comp = regex.dbgcompile(cmd.args[0], false)
;;
match comp
- | `std.Fail m:
+ | `std.Err m:
std.fatal("unable to compile regex: {}\n", m)
| `std.Ok re:
if cmd.args.len > 1
@@ -48,7 +48,7 @@
| `std.Ok fd:
dump(re, fd)
bio.close(fd)
- | `std.Fail m:
+ | `std.Err m:
std.fatal("failed to open {}: {}\n", f, m)
;;
;;
--- a/lib/std/blat.myr
+++ b/lib/std/blat.myr
@@ -9,7 +9,7 @@
const blat = {path, buf, perm
match openmode(path, Ocreat|Owronly, perm)
| `Ok fd: -> fblat(fd, buf)
- | `Fail e: -> false
+ | `Err e: -> false
;;
}
@@ -20,7 +20,7 @@
count = 0
while true
match write(fd, buf[count:])
- | `Fail e: -> false
+ | `Err e: -> false
| `Ok n:
if n == 0
break
--- a/lib/std/dial+plan9.myr
+++ b/lib/std/dial+plan9.myr
@@ -29,7 +29,7 @@
match csdial("/net", proto, rem)
| `Ok fd: -> `Ok fd
- | `Fail m:
+ | `Err m:
-> csdial("/net.alt", proto, rem)
;;
}
@@ -42,15 +42,15 @@
/* Try using the connection server */
dir = fmt("{}/cs", netdir)
match open(dir, Ordwr)
- | `Fail e:
+ | `Err e:
clone = fmt("{}/{}/clone", netdir, proto)
match call(clone, rem, netdir)
| `Ok fd:
std.slfree(clone)
-> `Ok fd
- | `Fail err:
+ | `Err err:
std.slfree(clone)
- -> `Fail "unable to dial without cs"
+ -> `Err "unable to dial without cs"
;;
| `Ok fd:
csfd = fd
@@ -59,9 +59,9 @@
csaddr = fmt("{}!{}", proto, rem)
match write(csfd, csaddr)
- | `Fail m:
+ | `Err m:
close(csfd)
- -> `Fail "couldn't blah cs"
+ -> `Err "couldn't blah cs"
| `Ok _:
/* nothing */
;;
@@ -71,7 +71,7 @@
while true
match read(csfd, buf[:])
| `std.Ok _:
- | `std.Fail e:
+ | `std.Err e:
break
;;
@@ -84,13 +84,13 @@
match call(clone, addr, netdir)
| `Ok fd: break
- | `Fail _: /* nothing */
+ | `Err _: /* nothing */
;;
;;
close(csfd)
if ret < 0
- -> `Fail "unable to dial"
+ -> `Err "unable to dial"
;;
-> `Ok ret
}
@@ -102,16 +102,16 @@
var cfd, datafd
var c, n
- datafd = `Fail "didn't even try to open shit"
+ datafd = `Err "didn't even try to open shit"
c = nsclonestr(clone, netdir)
match open(c, Ordwr)
- | `Fail e: goto cleanup
+ | `Err e: goto cleanup
| `Ok fd: cfd = fd
;;
match read(cfd, namebuf[:])
| `Ok fd: /* nothing */
- | `Fail m: goto cleanup
+ | `Err m: goto cleanup
;;
fput(cfd, "connect {}", addr)
name = strstrip(namebuf[:n])
@@ -122,7 +122,7 @@
dpath = bfmt(databuf[:], "{}/{}/data", base, name)
match open(dpath, Ordwr)
| `Ok fd: datafd = `Ok fd
- | `Fail m: datafd = `Fail "could not open data"
+ | `Err m: datafd = `Err "could not open data"
;;
:cleanup
close(cfd)
--- a/lib/std/dial+posixy.myr
+++ b/lib/std/dial+posixy.myr
@@ -33,8 +33,8 @@
| `Some ("tcp", str): -> dialsock(sys.Sockstream, str)
| `Some ("udp", str): -> dialsock(sys.Sockdgram, str)
| `Some ("unix", u): -> dialunix(u)
- | `Some (proto, str): -> `Fail "unknown protocol"
- | `None: -> `Fail "missing protocol"
+ | `Some (proto, str): -> `Err "unknown protocol"
+ | `None: -> `Err "missing protocol"
;;
}
@@ -47,15 +47,15 @@
var err
match nameseg(str)
- | `None: -> `Fail "required host!port for ip dial"
- | `Some ("", _): -> `Fail "empty host"
- | `Some (_, ""): -> `Fail "empty port"
+ | `None: -> `Err "required host!port for ip dial"
+ | `Some ("", _): -> `Err "empty host"
+ | `Some (_, ""): -> `Err "empty port"
| `Some segs: (hoststr, portstr) = segs
;;
match parseport(portstr)
| `Some p: port = p
- | `None: -> `Fail("invalid port")
+ | `None: -> `Err("invalid port")
;;
match getaddr(hoststr)
@@ -67,18 +67,18 @@
sa6=[.fam=sys.Afinet6, .addr=bits, .port=hosttonet(port)]
sa = (&sa6 : sys.sockaddr#)
sz = sizeof(sys.sockaddr_in6)
- | `Fail m:
- -> `Fail m
+ | `Err m:
+ -> `Err m
;;
sock = sys.socket(sa.fam, proto, 0)
if sock < 0
- -> `Fail "failed to create socket"
+ -> `Err "failed to create socket"
;;
err = sys.connect(sock, sa, sz)
if err < 0
sys.close(sock)
- -> `Fail "Failed to bind socket"
+ -> `Err "Failed to bind socket"
;;
-> `Ok (sock : fd)
@@ -90,16 +90,16 @@
sa = [.fam = sys.Afunix]
if path.len >= sa.path.len
- -> `Fail "path too long"
+ -> `Err "path too long"
;;
sock = sys.socket(sys.Afunix, sys.Sockstream, 0)
if sock < 0
- -> `Fail "failed to create socket"
+ -> `Err "failed to create socket"
;;
slcp(sa.path[:path.len], path)
if sys.connect(sock, (&sa : sys.sockaddr#), sizeof(sys.sockaddr_un)) < 0
- -> `Fail "failed to bind address"
+ -> `Err "failed to bind address"
;;
-> `Ok (sock : fd)
}
--- a/lib/std/dialparse+posixy.myr
+++ b/lib/std/dialparse+posixy.myr
@@ -49,10 +49,10 @@
slfree(hi)
else
slfree(hi)
- -> `Fail "no hosts resolved for addr"
+ -> `Err "no hosts resolved for addr"
;;
- | `Fail m:
- -> `Fail "could not get host info"
+ | `Err m:
+ -> `Err "could not get host info"
;;
;;
-> `Ok ip
--- a/lib/std/dir+freebsd.myr
+++ b/lib/std/dir+freebsd.myr
@@ -28,7 +28,7 @@
fd = sys.open(p, sys.Ordonly | sys.Odir)
if fd < 0
- -> `Fail "couldn't open directory"
+ -> `Err "couldn't open directory"
;;
dir = zalloc()
dir.fd = fd
--- a/lib/std/dir+linux.myr
+++ b/lib/std/dir+linux.myr
@@ -30,7 +30,7 @@
fd = sys.open(p, sys.Ordonly | sys.Odir)
if fd < 0
- -> `Fail "couldn't open directory"
+ -> `Err "couldn't open directory"
;;
dir = zalloc()
dir.fd = fd
--- a/lib/std/dir+openbsd.myr
+++ b/lib/std/dir+openbsd.myr
@@ -28,7 +28,7 @@
fd = sys.open(p, sys.Ordonly | sys.Odir)
if fd < 0
- -> `Fail "couldn't open directory"
+ -> `Err "couldn't open directory"
;;
dir = zalloc()
dir.fd = fd
--- a/lib/std/dir+osx.myr
+++ b/lib/std/dir+osx.myr
@@ -28,7 +28,7 @@
fd = sys.open(p, sys.Ordonly | sys.Odir)
if fd < 0
- -> `Fail "couldn't open directory"
+ -> `Err "couldn't open directory"
;;
dir = zalloc()
dir.fd = fd
--- a/lib/std/dir+plan9.myr
+++ b/lib/std/dir+plan9.myr
@@ -28,7 +28,7 @@
match open(p, Ordonly)
| `Ok f: fd = f
- | `Fail e: -> `Fail "couldn't open directory"
+ | `Err e: -> `Err "couldn't open directory"
;;
dir = zalloc()
@@ -45,7 +45,7 @@
match read(d.fd, d.buf[:])
| `Ok 0:
-> `None
- | `Fail e:
+ | `Err e:
-> `None
| `Ok len:
d.len = (len : int64)
--- a/lib/std/env+plan9.myr
+++ b/lib/std/env+plan9.myr
@@ -43,7 +43,7 @@
| `None:
s = fmt("/env/{}", name)
match std.slurp(s)
- | `Fail m:
+ | `Err m:
ret = `None
| `Ok data:
data = cstrconv(data)
--- a/lib/std/listen+posixy.myr
+++ b/lib/std/listen+posixy.myr
@@ -26,8 +26,8 @@
| `Some ("tcp", str): -> announcesock(sys.Sockstream, str)
| `Some ("udp", str): -> announcesock(sys.Sockdgram, str)
| `Some ("unix", str): -> announceunix(str)
- | `Some (proto, str): -> `Fail "unknown protocol"
- | `None: -> `Fail "missing protocol"
+ | `Some (proto, str): -> `Err "unknown protocol"
+ | `None: -> `Err "missing protocol"
;;
}
@@ -40,15 +40,15 @@
var yes
match nameseg(str)
- | `None: -> `Fail "required addr!port for ip listen"
- | `Some ("", _): -> `Fail "empty host"
- | `Some (_, ""): -> `Fail "empty port"
+ | `None: -> `Err "required addr!port for ip listen"
+ | `Some ("", _): -> `Err "empty host"
+ | `Some (_, ""): -> `Err "empty port"
| `Some segs: (hoststr, portstr) = segs
;;
match parseport(portstr)
| `Some p: port = p
- | `None: -> `Fail("invalid port")
+ | `None: -> `Err("invalid port")
;;
if std.sleq(hoststr, "*")
@@ -65,20 +65,20 @@
sa6=[.fam=sys.Afinet6, .addr=bits, .port=hosttonet(port)]
sa = (&sa6 : sys.sockaddr#)
sz = sizeof(sys.sockaddr_in6)
- | `Fail m:
- -> `Fail m
+ | `Err m:
+ -> `Err m
;;
;;
sock = sys.socket(sa.fam, proto, 0)
if sock < 0
- -> `Fail "failed to create socket"
+ -> `Err "failed to create socket"
;;
yes = 1
if sys.setsockopt(sock, sys.Solsock, sys.Soreuseaddr, (&yes : void#), sizeof(int)) < 0
- -> `Fail "failed to set sock opts"
+ -> `Err "failed to set sock opts"
;;
if sys.bind(sock, sa, sz) < 0
- -> `Fail "failed to bind socket"
+ -> `Err "failed to bind socket"
;;
-> `Ok (sock : fd)
}
@@ -90,21 +90,21 @@
sa = [.fam = sys.Afunix]
if path.len >= sa.path.len
- -> `Fail "path too long"
+ -> `Err "path too long"
;;
slcp(sa.path[:path.len], path)
sock = sys.socket(sys.Afunix, sys.Sockstream, 0)
if sock < 0
- -> `Fail "failed to create socket"
+ -> `Err "failed to create socket"
;;
yes = 1
if sys.setsockopt(sock, sys.Solsock, sys.Soreuseaddr, (&yes : void#), sizeof(int)) < 0
- -> `Fail "failed to set sock opts"
+ -> `Err "failed to set sock opts"
;;
sys.unlink(path)
if sys.bind(sock, (&sa : sys.sockaddr#), sizeof(sys.sockaddr_un)) < 0
- -> `Fail "failed to bind address"
+ -> `Err "failed to bind address"
;;
-> `Ok (sock : fd)
@@ -112,7 +112,7 @@
const listen = {sock : std.fd -> result(fd, byte[:])
if sys.listen((sock : sys.fd), 10) < 0
- -> `Fail "unable to listen on socket"
+ -> `Err "unable to listen on socket"
;;
-> `Ok (sys.dup((sock : sys.fd)) : fd)
}
@@ -124,7 +124,7 @@
fd = sys.accept((lfd : sys.fd), (0 : sys.sockaddr#), (0 : sys.size#))
if fd < 0
- -> `Fail "unable to accept socket"
+ -> `Err "unable to accept socket"
;;
-> `Ok (fd : fd)
}
--- a/lib/std/mktemp.myr
+++ b/lib/std/mktemp.myr
@@ -38,10 +38,10 @@
for var i = 0; i < Retries; i++
path = randpath(tmpdir, base)
match std.openmode(path, opt | Ocreat, mode)
- | `Fail e:
+ | `Err e:
if e != Eexist
std.slfree(path)
- -> `Fail e
+ -> `Err e
;;
| `Ok fd:
-> `Ok (fd, path)
@@ -48,7 +48,7 @@
;;
std.slfree(path)
;;
- -> `Fail Eexist
+ -> `Err Eexist
}
const mktemppath = {base
--- a/lib/std/readall.myr
+++ b/lib/std/readall.myr
@@ -18,8 +18,8 @@
break
| `Ok n:
dst = dst[n:]
- | `Fail e:
- -> `Fail e
+ | `Err e:
+ -> `Err e
;;
;;
-> `Ok sz - dst.len
--- a/lib/std/resolve+posixy.myr
+++ b/lib/std/resolve+posixy.myr
@@ -102,7 +102,7 @@
match slurp(Hostfile)
| `Ok d: h = d
- | `Fail m: -> void
+ | `Err m: -> void
;;
lines = strsplit(h, "\n")
@@ -170,7 +170,7 @@
lock(netlck)
match slurp(Resolvfile)
| `Ok d: h = d
- | `Fail m: -> void
+ | `Err m: -> void
;;
lines = strsplit(h, "\n")
@@ -228,7 +228,7 @@
var nsrv, r
if !valid(host)
- -> `Fail (`Badhost)
+ -> `Err (`Badhost)
;;
lock(netlck)
for ns in nameservers
@@ -241,7 +241,7 @@
;;
;;
unlock(netlck)
- -> `Fail (`Badsrv)
+ -> `Err (`Badsrv)
}
const dnsconnect = {ns
@@ -318,7 +318,7 @@
n = sys.read(srv, pktbuf[:])
if n < 0
- -> `Fail `Badconn
+ -> `Err `Badconn
;;
pkt = pktbuf[:n]
-> hosts(pkt, id)
@@ -333,7 +333,7 @@
/* parse header */
(v, off) = unpack16(pkt, off) /* id */
if v != id
- -> `Fail `Badresp
+ -> `Err `Badresp
;;
(v, off) = unpack16(pkt, off) /* flags */
(q, off) = unpack16(pkt, off) /* qdcount */
--- a/lib/std/result.myr
+++ b/lib/std/result.myr
@@ -1,7 +1,7 @@
pkg std =
type result(@a, @b) = union
`Ok @a
- `Fail @b
+ `Err @b
;;
;;
--- a/lib/std/slurp.myr
+++ b/lib/std/slurp.myr
@@ -16,7 +16,7 @@
const slurp = {path
var sl
match open(path, Ordonly)
- | `Fail e: -> `Fail e
+ | `Err e: -> `Err e
| `Ok fd:
sl = fslurp(fd)
close(fd)
@@ -41,9 +41,9 @@
bufsz *= 2
slgrow(&buf, bufsz)
;;
- | `Fail e:
+ | `Err e:
slfree(buf)
- -> `Fail e
+ -> `Err e
;;
;;
die("unreachable")
--- a/lib/std/spork.myr
+++ b/lib/std/spork.myr
@@ -17,11 +17,11 @@
/* open up pipes */
err = pipe(&infds)
if err != Enone
- -> `Fail err
+ -> `Err err
;;
err = pipe(&outfds)
if err != Enone
- -> `Fail err
+ -> `Err err
;;
match sporkfd(cmd, infds[0], outfds[1])
@@ -30,8 +30,8 @@
close(infds[0]);
close(outfds[1]);
-> `Ok (pid, infds[1], outfds[0])
- | `Fail m:
- -> `Fail m
+ | `Err m:
+ -> `Err m
;;
}
@@ -41,23 +41,23 @@
pid = fork()
/* error */
if pid < 0
- -> `Fail (pid : errno)
+ -> `Err (pid : errno)
/* child */
elif pid == 0
/* stdin/stdout for our communication. */
match dup2(infd, 0)
| `Ok _: /* nothing */
- | `Fail e: -> `Fail e
+ | `Err e: -> `Err e
;;
match dup2(outfd, 1)
| `Ok _: /* nothing */
- | `Fail e: -> `Fail e
+ | `Err e: -> `Err e
;;
close(infd)
close(outfd)
err = execvp(cmd[0], cmd)
if err != Enone
- -> `Fail err
+ -> `Err err
;;
/* if fork succeeds, we never return */
die("unreachable")
--- a/lib/std/syswrap+plan9.myr
+++ b/lib/std/syswrap+plan9.myr
@@ -120,7 +120,7 @@
var buf : byte[Stringsoff + 512] /* enough space for some strings */
if sys.stat(path, buf[:]) < Stringsoff
- -> `Fail Emisc
+ -> `Err Emisc
;;
-> `Ok (getle32(buf[Mtimeoff:Mtimeoff + 8]) : time)
}
@@ -129,7 +129,7 @@
var buf : byte[Stringsoff + 512] /* enough space for some strings */
if sys.stat(path, buf[:]) < Stringsoff
- -> `Fail Emisc
+ -> `Err Emisc
;;
-> `Ok (getle64(buf[Lengthoff:Lengthoff + 8]) : off)
}
@@ -246,7 +246,7 @@
generic check = {e : @a::(integral, numeric) -> result(@b, errno)
if e < 0
- -> `Fail lasterr()
+ -> `Err lasterr()
else
-> `Ok (e : @b)
;;
--- a/lib/std/syswrap+posixy.myr
+++ b/lib/std/syswrap+posixy.myr
@@ -175,7 +175,7 @@
generic check = {e : @a::(integral, numeric) -> result(@b, errno)
if e < 0
- -> `Fail (e : errno)
+ -> `Err (e : errno)
else
-> `Ok (e : @b)
;;
--- a/lib/std/try.myr
+++ b/lib/std/try.myr
@@ -12,7 +12,7 @@
generic try = {v
match v
| `Ok x: -> x
- | `Fail m: fatal("error: {}\n", m)
+ | `Err m: fatal("error: {}\n", m)
;;
}
@@ -19,7 +19,7 @@
generic tryv = {v, d
match v
| `Ok x: -> x
- | `Fail m: -> d
+ | `Err m: -> d
;;
}
--- a/lib/std/writeall.myr
+++ b/lib/std/writeall.myr
@@ -16,7 +16,7 @@
match std.write(fd, src)
| `Ok n:
src = src[n:]
- | `Fail e:
+ | `Err e:
-> (sz - src.len, `Some e)
;;
;;
--- a/lib/thread/spawn+freebsd.myr
+++ b/lib/thread/spawn+freebsd.myr
@@ -21,7 +21,7 @@
stk = getstk(sz)
if stk == sys.Mapbad
- -> `std.Fail "couldn't get stack"
+ -> `std.Err "couldn't get stack"
;;
tid = -1
/* find top of stack */
@@ -51,7 +51,7 @@
], sizeof(sys.thrparam))
if ret < 0
- -> `std.Fail "couldn't spawn thread"
+ -> `std.Err "couldn't spawn thread"
;;
-> `std.Ok (tid : tid)
}
--- a/lib/thread/spawn+linux.myr
+++ b/lib/thread/spawn+linux.myr
@@ -26,7 +26,7 @@
stk = getstk(sz)
if stk == sys.Mapbad
- -> `std.Fail "couldn't get stack"
+ -> `std.Err "couldn't get stack"
;;
tos = (stk : std.intptr)
tos -= sizeof(int64)
@@ -42,7 +42,7 @@
&ctid, (0 : byte#), \
(startthread : void#))
if ret < 0
- -> `std.Fail "couldn't spawn thread"
+ -> `std.Err "couldn't spawn thread"
;;
-> `std.Ok (ret : tid)
}
--- a/lib/thread/spawn+openbsd.myr
+++ b/lib/thread/spawn+openbsd.myr
@@ -20,7 +20,7 @@
stk = getstk(sz)
if stk == sys.Mapbad
- -> `std.Fail "couldn't get stack"
+ -> `std.Err "couldn't get stack"
;;
/* store size */
tos = (stk : std.intptr)
@@ -42,7 +42,7 @@
sizeof(sys.tforkparams), \
(startthread : void#), \
(0 : void#)) < 0
- -> `std.Fail "couldn't spawn thread"
+ -> `std.Err "couldn't spawn thread"
;;
-> `std.Ok (ret : tid)
}
--- a/lib/thread/spawn+osx.myr
+++ b/lib/thread/spawn+osx.myr
@@ -46,7 +46,7 @@
0)
if ret == (-1 : void#)
- -> `std.Fail "couldn't spawn thread"
+ -> `std.Err "couldn't spawn thread"
;;
-> `std.Ok (ret : tid)
}
--- a/lib/thread/spawn+plan9.myr
+++ b/lib/thread/spawn+plan9.myr
@@ -12,7 +12,7 @@
| 0:
fn()
std.exit(0)
- | -1: -> `std.Fail "unable to spawn thread"
+ | -1: -> `std.Err "unable to spawn thread"
| thr: -> `std.Ok (thr : tid)
;;
}
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -509,11 +509,11 @@
*/
match std.fmtime(src)
| `std.Ok mt: srcmt = mt
- | `std.Fail e: std.fatal("could not stat {}: {}\n", src, e)
+ | `std.Err e: std.fatal("could not stat {}: {}\n", src, e)
;;
match std.fmtime(dst)
| `std.Ok mt: dstmt = mt
- | `std.Fail e: -> false
+ | `std.Err e: -> false
;;
-> srcmt <= dstmt
}
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -283,7 +283,7 @@
;;
match bio.open(path, bio.Rd)
- | `std.Fail m: std.fatal("could not open {}: {}\n", path, m)
+ | `std.Err m: std.fatal("could not open {}: {}\n", path, m)
| `std.Ok f: -> f
;;
}
@@ -391,7 +391,7 @@
| `std.Ok file:
std.slfree(path)
-> file
- | `std.Fail m:
+ | `std.Err m:
;;
std.fput(std.Err, "could not find library {}\n", lib)
std.fput(std.Err, "search path is:\n")
--- a/mbld/install.myr
+++ b/mbld/install.myr
@@ -79,7 +79,7 @@
else
std.remove(path)
match std.slurp(file)
- | `std.Fail m: std.fatal("could not open {} for reading\n", file)
+ | `std.Err m: std.fatal("could not open {} for reading\n", file)
| `std.Ok buf:
if std.blat(path, buf, perm)
std.put("\t{} => {}\n", file, path)
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -104,7 +104,7 @@
])
match std.slurp(path)
| `std.Ok d: p.data = d
- | `std.Fail _: std.fatal("could not open '{}'\n", path)
+ | `std.Err _: std.fatal("could not open '{}'\n", path)
;;
p.rest = p.data
-> p
--- a/mbld/subtest.myr
+++ b/mbld/subtest.myr
@@ -50,7 +50,7 @@
match std.read(f, buf[:])
| `std.Ok 0: break
| `std.Ok n: std.write(log, buf[:n])
- | `std.Fail e: std.fatal("error writing log: {}\n", e)
+ | `std.Err e: std.fatal("error writing log: {}\n", e)
;;
;;
std.slfree(buf)
@@ -84,7 +84,7 @@
| `std.Some `std.Ok _:
endtest(&curtest, &nresults, true, "")
continue
- | `std.Some `std.Fail m:
+ | `std.Some `std.Err m:
endtest(&curtest, &nresults, false, m)
ok = false
continue
@@ -174,7 +174,7 @@
if std.sleq(m[1], "ok")
-> `std.Some `std.Ok void
else
- -> `std.Some `std.Fail std.sldup(m[2])
+ -> `std.Some `std.Err std.sldup(m[2])
;;
| `std.None:
-> `std.None
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -161,7 +161,7 @@
;;
std.put(":\t")
match std.spork(cmd)
- | `std.Fail m:
+ | `std.Err m:
std.fatal("\nunable to run test: {}\n", m)
| `std.Ok (pid, infd, outfd):
log = std.strcat(cmd[0], ".log")
--- a/test/catfile.myr
+++ b/test/catfile.myr
@@ -7,7 +7,7 @@
r = std.slurp("data/catfile-in")
match r
| `std.Ok dat: std.write(1, dat)
- | `std.Fail msg: std.put("Failed to read file: {}\n", msg)
+ | `std.Err msg: std.put("Failed to read file: {}\n", msg)
;;
}