commit 055a7e16b9ee6efcfae7b23e8050c1ae33913ce6
parent 799ecf63eb266fba41f4407b710c9d3daa5c14f2
Author: Drew DeVault <sir@cmpwn.com>
Date: Sat, 6 Feb 2021 17:23:38 -0500
main.ha: use fmt::fatal
Diffstat:
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/main.ha b/main.ha
@@ -4,26 +4,22 @@ use os;
export fn main() void = {
if (len(os::args) == 1z) match (io::copy(os::stdout, os::stdin)) {
- err: io::error => fatal("Error: {}\n", io::errstr(err)),
+ err: io::error => fmt::fatal("Error: {}", io::errstr(err)),
size => os::exit(0),
};
for (let i = 1z; i < len(os::args); i += 1z) {
let in = match (os::open(os::args[i], io::mode::RDONLY)) {
stream: *io::stream => stream,
- err: io::error => fatal("Error: {}: {}\n",
+ err: io::error => fmt::fatal("Error: {}: {}",
os::args[i], io::errstr(err)),
};
defer io::close(in);
match (io::copy(os::stdout, in)) {
- err: io::error => fatal("Error: {}\n", io::errstr(err)),
+ err: io::error =>
+ fmt::fatal("Error: {}", io::errstr(err)),
size => void,
};
};
};
-
-@noreturn fn fatal(fmt: str, args: fmt::formattable...) void = {
- fmt::errorf(fmt, args...);
- os::exit(1);
-};