ref: 9fa7e376e33410e78fda13897bf8e0914f201ddf
parent: 99bd0e314a7050f7ac4ae2c33207be08aa5c4507
author: Ori Bernstein <[email protected]>
date: Fri May 15 21:24:34 EDT 2015
Remove status arg from fatal. We never set it to anything other than '1' anyways. There's no standardized error codes, so the exit status isn't really useful in any case.
--- a/bld.proj
+++ b/bld.proj
@@ -3,5 +3,6 @@
libstd
libbio
libregex
+ test
;;
--- a/libstd/fmt.myr
+++ b/libstd/fmt.myr
@@ -37,8 +37,8 @@
const bfmt : (buf : byte[:], fmt : byte[:], args : ... -> byte[:])
const bfmtv : (buf : byte[:], fmt : byte[:], ap : valist -> byte[:])
- $noret const fatal : (status : int, fmt : byte[:], args : ... -> void)
- $noret const fatalv : (status : int, fmt : byte[:], ap : valist -> void)
+ $noret const fatal : (fmt : byte[:], args : ... -> void)
+ $noret const fatalv : (fmt : byte[:], ap : valist -> void)
;;
/* Writes a string of text up to 2 kb in size to stdout */
@@ -63,15 +63,15 @@
}
/* same as 'put', but exits the program after printing */
-const fatal = {status, fmt, args
+const fatal = {fmt, args
putv(fmt, vastart(&args))
- exit(status)
+ exit(1)
}
/* same as 'putv', but exits the program after printing */
-const fatalv = {status, fmt, ap
+const fatalv = {fmt, ap
putv(fmt, ap)
- exit(status)
+ exit(1)
}
/* formats a string, allocating the slice. FIXME: calculate the
--- a/libstd/optparse.myr
+++ b/libstd/optparse.myr
@@ -97,7 +97,7 @@
optusage(ctx.optargs[0], ctx.optdef)
exit(0)
else
- fatal(1, "unexpected argument '%c'\n", c)
+ fatal("unexpected argument '%c'\n", c)
;;
| `Some (true, needed):
/* -arg => '-a' 'rg' */
--- a/libstd/spork.myr
+++ b/libstd/spork.myr
@@ -45,15 +45,15 @@
elif pid == 0
/* stdin/stdout for our communication. */
if dup2(infd castto(fd), 0) != 0
- fatal(1, "unable to set stdin\n")
+ fatal("unable to set stdin\n")
;;
if dup2(outfd castto(fd), 1) != 1
- fatal(1, "unable to set stdout\n")
+ fatal("unable to set stdout\n")
;;
close(infd)
close(outfd)
execvp(cmd[0], cmd) < 0
- fatal(1, "failed to exec %s\n")
+ fatal("failed to exec %s\n")
/* parent */
else
-> `Ok pid
--- a/libstd/try.myr
+++ b/libstd/try.myr
@@ -8,6 +8,6 @@
generic try = {v
match v
| `Some x: -> x
- | `None: fatal(1, "expected `Some @a, got `None\n")
+ | `None: fatal("expected `Some @a, got `None\n")
;;
}
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -52,7 +52,7 @@
| `std.Some (`Gen gt): runin(b, gt.cmd, gt.dir)
| `std.Some (`Cmd ct): runin(b, ct.cmd, ct.dir)
| `std.Some (`Man mt): /* nothing needed */
- | `std.None: std.fatal(1, "invalid target %s\n", targ)
+ | `std.None: std.fatal("invalid target %s\n", targ)
;;
-> true
}
@@ -70,7 +70,7 @@
std.put("%s...\n", targ.name)
dg = myrdeps(b, targ, false, addsrc)
if !std.hthas(dg.deps, targ.name)
- std.fatal(1, "no input files for %s\n", targ.name)
+ std.fatal("no input files for %s\n", targ.name)
;;
if builddep(b, dg, targ.name, targ.incpath) || !freshlibs(targ, dg.libs)
src = std.htkeys(dg.sources)
@@ -92,7 +92,7 @@
archive = std.fmt("lib%s.a", lib)
dg = myrdeps(b, targ, false, false)
if !std.hthas(dg.deps, lib)
- std.fatal(1, "no target declared for %s\n", lib)
+ std.fatal("no target declared for %s\n", lib)
;;
u = builddep(b, dg, targ.name, targ.incpath)
l = builddep(b, dg, archive, targ.incpath)
@@ -155,7 +155,7 @@
;;
| `std.None:
if !std.fexists(d)
- std.fatal(1, "no input file %s\n", d)
+ std.fatal("no input file %s\n", d)
;;
;;
if !isfresh(d, out)
@@ -204,7 +204,7 @@
run(cmd)
std.slfree(o)
else
- std.fatal(1, "Unknown file type for %s\n", src)
+ std.fatal("Unknown file type for %s\n", src)
;;
}
@@ -277,7 +277,7 @@
if std.hassuffix(f, ".myr")
cmd = std.slpush(cmd, srcswapsuffix(f, ".use"))
elif !std.hassuffix(f, ".s")
- std.fatal(1, "unknown file type for %s\n", f)
+ std.fatal("unknown file type for %s\n", f)
;;
;;
run(cmd)
@@ -311,7 +311,7 @@
const visit = {cmd, head, g, lib, looped, marked, incs
if std.hthas(looped, lib)
- std.fatal(1, "cycle in library graph involving \"%s\"\n", lib)
+ std.fatal("cycle in library graph involving \"%s\"\n", lib)
elif std.hthas(marked, lib)
-> cmd
;;
@@ -331,7 +331,7 @@
else
match findlib(lib, incs)
| `std.None:
- std.fatal(1, "could not find library lib%s.a\n", lib)
+ std.fatal("could not find library lib%s.a\n", lib)
| `std.Some p:
-> std.slput(cmd, head, p)
;;
@@ -401,7 +401,7 @@
*/
match std.fmtime(src)
| `std.Some mt: srcmt = mt
- | `std.None: std.fatal(1, "could not stat %s\n", src)
+ | `std.None: std.fatal("could not stat %s\n", src)
;;
match std.fmtime(dst)
| `std.Some mt: dstmt = mt
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -144,7 +144,7 @@
;;
| `Local (l, lnum):
if !std.hassuffix(l, ".use")
- std.fatal(1, "%s:%s: local dependency \"%s\" should end with .use\n", path, lnum, l)
+ std.fatal("%s:%s: local dependency \"%s\" should end with .use\n", path, lnum, l)
;;
if obj.len != 0
pushdep(g, l, obj)
@@ -177,7 +177,7 @@
if ds.addsrc
std.htput(g.sources, src, true)
elif !std.hthas(g.input, usefile)
- std.fatal(1, "%s:%i: source file %s not listed in bldfile\n", f, line, src)
+ std.fatal("%s:%i: source file %s not listed in bldfile\n", f, line, src)
;;
;;
pushdep(g, src, usefile)
@@ -194,12 +194,12 @@
if !std.fexists(path)
match std.htget(b.gensrc, path)
| `std.Some gt: run(gt.cmd)
- | `std.None: std.fatal(1, "no input file %s\n", path)
+ | `std.None: std.fatal("no input file %s\n", path)
;;
;;
match bio.open(path, bio.Rd)
| `std.Some fd: f = fd
- | `std.None: std.fatal(1, "could not open %s\n", path)
+ | `std.None: std.fatal("could not open %s\n", path)
;;
lnum = 0
@@ -230,14 +230,14 @@
f = openlib(lib, incs)
match bio.getc(f)
| `std.Some 'U': /* nothing */
- | `std.Some _: std.fatal(1, "library %s: corrupt or invalid usefile\n", lib)
- | `std.None: std.fatal(1, "library %s: could not read usefile\n", lib)
+ | `std.Some _: std.fatal("library %s: corrupt or invalid usefile\n", lib)
+ | `std.None: std.fatal("library %s: could not read usefile\n", lib)
;;
match bio.getbe32(f)
| `std.Some 1: /* nothing: version matches. */
| `std.Some 0: std.fput(1, "library %s: warning: old usefile version\n", lib)
- | `std.Some _: std.fatal(1, "library %s: usefile version unknown\n", lib)
- | `std.None: std.fatal(1, "library %s: corrutpt or invalid usefile\n", lib)
+ | `std.Some _: std.fatal("library %s: usefile version unknown\n", lib)
+ | `std.None: std.fatal("library %s: corrutpt or invalid usefile\n", lib)
;;
std.slfree(rdstr(f))
done = false
@@ -276,7 +276,7 @@
| `std.None:
/* nothing */
;;
- std.fatal(1, "could not find library %s.\n", lib)
+ std.fatal("could not find library %s.\n", lib)
}
const depname = {deps, ln, lnum
--- a/mbld/fsel.myr
+++ b/mbld/fsel.myr
@@ -35,11 +35,11 @@
basename = f[:i]
match std.strrfind(f[i+1:], ".")
| `std.Some j: attrs = f[i+1:][:j]
- | `std.None: std.fatal(1, "unrecognized type for file %s\n", f)
+ | `std.None: std.fatal("unrecognized type for file %s\n", f)
;;
| `std.None:
match std.strrfind(f, ".")
- | `std.None: std.fatal(1, "unrecognized type for file %s\n", f)
+ | `std.None: std.fatal("unrecognized type for file %s\n", f)
| `std.Some i:
basename = f[:i]
attrs = ""
@@ -72,7 +72,7 @@
for k in keys
nmatch = std.htgetv(fsel._match, k, -1)
if nmatch == -1
- std.fatal(1, "no applicable file for '%s'\n", k)
+ std.fatal("no applicable file for '%s'\n", k)
;;
ret = std.slpush(ret, std.htgetv(fsel._best, k, ""))
;;
@@ -89,7 +89,7 @@
| "osx": attrs = ["osx", "posixy"][:]
| "linux": attrs = ["linux", "posixy"][:]
| "plan9": attrs = ["plan9"][:]
- | unknown: std.fatal(1, "unknown system \"%s\"\n", unknown)
+ | unknown: std.fatal("unknown system \"%s\"\n", unknown)
;;
for a in attrs
std.htput(sa, a, true)
@@ -97,7 +97,7 @@
match opt_arch
| "x64": attrs = ["x64"][:]
- | unknown: std.fatal(1, "unknown arch %s\n", unknown)
+ | unknown: std.fatal("unknown arch %s\n", unknown)
;;
for a in attrs
std.htput(sa, a, true)
--- a/mbld/install.myr
+++ b/mbld/install.myr
@@ -68,7 +68,7 @@
std.put("\t%s => %s\n", file, path)
std.remove(path)
match std.slurp(file)
- | `std.Fail m: std.fatal(1, "Could not open %s for reading\n", file)
+ | `std.Fail m: std.fatal("Could not open %s for reading\n", file)
| `std.Ok buf:
if !std.blat(path, buf, perm)
std.put("Could not write %s\n", file)
@@ -84,11 +84,11 @@
match std.strrfind(man, ".")
| `std.None:
- std.fatal(1, "manpage %s has no section\n", man)
+ std.fatal("manpage %s has no section\n", man)
| `std.Some s:
sect = s + 1
if s + 1 == man.len
- std.fatal(1, "manpage %s missing suffix\n", man)
+ std.fatal("manpage %s missing suffix\n", man)
;;
;;
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -75,7 +75,7 @@
match regex.compile("^\\s*use\\s+((\\<\\S+\\>)|(\"(\\S+)\")).*")
| `std.Ok re: bld.usepat = re
- | `std.Fail f: std.fatal(1, "Failed to compile use pattern regex\n")
+ | `std.Fail f: std.fatal("Failed to compile use pattern regex\n")
;;
b = mkbuild()
@@ -133,7 +133,7 @@
const findproj = {b, bldfile
if !findbase(b, bldfile) || !std.chdir(b.basedir)
- std.fatal(1, "could not find %s\n", bldfile)
+ std.fatal("could not find %s\n", bldfile)
;;
bld.setdir(b, "")
}
--- a/mbld/opts.myr
+++ b/mbld/opts.myr
@@ -56,13 +56,13 @@
| "Darwin": opt_sys = "osx"
| "FreeBSD": opt_sys = "freebsd"
| "Plan9": opt_sys = "plan9"
- | unknown: std.fatal(1, "unknown system \"%s\"\n", unknown)
+ | unknown: std.fatal("unknown system \"%s\"\n", unknown)
;;
match si.arch
| "x86_64": opt_arch = "x64"
| "amd64": opt_arch = "x64"
- | unknown: std.fatal(1, "unknown architecture \"%s\"\n", unknown)
+ | unknown: std.fatal("unknown architecture \"%s\"\n", unknown)
;;
opt_incpaths = [][:]
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -59,7 +59,7 @@
loadall(b, subproj, subpath)
b.basedir = curbase
else
- std.fatal(1, "could not open %s or %s \n", subbld, subproj)
+ std.fatal("could not open %s or %s \n", subbld, subproj)
;;
std.slfree(subbld)
std.slfree(subproj)
@@ -91,7 +91,7 @@
const visit = {all, b, targ, looped, marked
if std.hthas(looped, targ)
- std.fatal(1, "cycle in build depgraph involving %s\n", targ)
+ std.fatal("cycle in build depgraph involving %s\n", targ)
elif std.hthas(marked, targ)
-> all
;;
@@ -109,7 +109,7 @@
match targ
| `Bin t: -> t.libdeps
| `Lib t: -> t.libdeps
- | _: std.fatal(1, "depending on non-library target")
+ | _: std.fatal("depending on non-library target")
;;
}
@@ -123,7 +123,7 @@
p.basedir = std.sldup(basedir)
match std.slurp(path)
| `std.Ok d: p.data = d
- | `std.Fail _: std.fatal(1, "could not open '%s'\n", path)
+ | `std.Fail _: std.fatal("could not open '%s'\n", path)
;;
p.rest = p.data
-> p
@@ -353,7 +353,7 @@
| ("noinst", ""): inst = false
| ("sys", tags): systags = std.slpush(systags, tags)
| (invalid, _):
- std.fatal(1, "%s: got invalid attr '%s'\n", targ, invalid)
+ std.fatal("%s: got invalid attr '%s'\n", targ, invalid)
;;
;;
for inc in bld.opt_incpaths
@@ -614,7 +614,7 @@
targ = std.fmt("%s:%s", p.fdir, lib)
| `std.Some idx:
if idx == libpath.len
- std.fatal(1, "libdep %s missing library after ':'\n")
+ std.fatal("libdep %s missing library after ':'\n")
;;
/* absolute path */
if std.hasprefix(libpath, "@/") || std.hasprefix(libpath, "@:")
@@ -627,7 +627,7 @@
lib = std.sldup(libpath[idx+1:])
targ = std.pathcat(p.fdir, libpath)
if std.hasprefix(targ, "../")
- std.fatal(1, "library %s outside of project\n", libpath)
+ std.fatal("library %s outside of project\n", libpath)
;;
;;
;;
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -125,7 +125,7 @@
log = std.strcat(bin, ".log")
match std.spork([bin][:])
| `std.Fail m:
- std.fatal(1, "unable to run test: %s\n", m)
+ std.fatal("unable to run test: %s\n", m)
| `std.Ok (pid, infd, outfd):
match std.fslurp(outfd)
| `std.Ok "": /* empty output; nothing to log */
--- a/mbld/util.myr
+++ b/mbld/util.myr
@@ -20,17 +20,17 @@
printcmd(cmd)
pid = std.fork()
if pid == -1
- std.fatal(1, "could not fork command\n")
+ std.fatal("could not fork command\n")
elif pid == 0
if std.execvp(cmd[0], cmd) < 0
- std.fatal(1, "failed to exec %s\n", cmd[0])
+ std.fatal("failed to exec %s\n", cmd[0])
;;
else
match std.wait(pid)
| `std.Wsuccess: /* nothing */
- | `std.Wfailure: std.fatal(1, "FAIL: \"%s\"\n", std.strjoin(cmd, " "))
- | `std.Wsignalled: std.fatal(1, "CRASH: \"%s\"\n", std.strjoin(cmd, " "))
- | `std.Waiterror: std.fatal(1, "WAT: \"%s\"\n", std.strjoin(cmd, " "))
+ | `std.Wfailure: std.fatal("FAIL: \"%s\"\n", std.strjoin(cmd, " "))
+ | `std.Wsignalled: std.fatal("CRASH: \"%s\"\n", std.strjoin(cmd, " "))
+ | `std.Waiterror: std.fatal("WAT: \"%s\"\n", std.strjoin(cmd, " "))
;;
;;
}
@@ -85,7 +85,7 @@
elif std.sleq(suff, ".s")
-> std.strcat(base, new)
else
- std.fatal(1, "unrecognized source %s\n", src)
+ std.fatal("unrecognized source %s\n", src)
;;
}
@@ -98,7 +98,7 @@
const gettarg = {tab, n
match std.htget(tab, n)
- | `std.None: std.fatal(1, "internal: nonexistent %s\n", n)
+ | `std.None: std.fatal("internal: nonexistent %s\n", n)
| `std.Some t: -> t
;;
}
@@ -114,7 +114,7 @@
std.put("Entering directory '%s'\n", dir)
if !std.chdir(p)
- std.fatal(1, "could not cd into %s\n", p)
+ std.fatal("could not cd into %s\n", p)
;;
b.curdir = dir
std.slfree(p)
--- a/mbldwrap.sh
+++ b/mbldwrap.sh
@@ -2,16 +2,20 @@
# this should be a bourne compatible shell script.
if test `uname` = Plan9; then
- echo "PLAN 9 BOOTSTRAP"
export MYR_MUSE=../muse/$O.out
export MYR_MC=../$O/$O.out
export MYR_RT=../rt/_myrrt.$O
BOOT="./mk/bootstrap/bootstrap+`uname -s`-`uname -m`.sh"
else
- echo "POSIX BOOTSTRAP"
export MYR_MUSE=../muse/muse
export MYR_MC=../6/6m
export MYR_RT=../rt/_myrrt.o
BOOT="./mk/bootstrap/bootstrap+`uname -s`-`uname -m`.sh"
fi
-mbld $@ || ./mbld/mbld $@ || $BOOT
+
+if [ -z "$@" ]; then
+ mbld || ./mbld/mbld || $BOOT
+else
+ mbld $@ || ./mbld/mbld $@ || \
+ (echo "Unable to run mbld $@; have you build successfully"; false)
+fi
--- a/test/matchargstr.myr
+++ b/test/matchargstr.myr
@@ -12,12 +12,12 @@
v = `Str "asdf"
match v
- | `Int 127: std.fatal(1, "wrong match `Int 127\n")
- | `Str "foo": std.fatal(1, "Wrong match `Str \"foo\"\n")
- | `Str "fsda": std.fatal(1, "Wrong match `Str \"fsda\"\n")
+ | `Int 127: std.fatal("wrong match `Int 127\n")
+ | `Str "foo": std.fatal("Wrong match `Str \"foo\"\n")
+ | `Str "fsda": std.fatal("Wrong match `Str \"fsda\"\n")
| `Str "asdf": std.put("Correct `Str \"asdf\"!\n")
- | `Nil: std.fatal(1, "Wrong match `Str \"fsda\"\n")
- | _: std.fatal(1, "Impossible failed match\n")
+ | `Nil: std.fatal("Wrong match `Str \"fsda\"\n")
+ | _: std.fatal("Impossible failed match\n")
;;
}