hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit abcfcaa9b07699569b23be17d1b1172cf3838f41
parent ccae373061634a7161b08ab3c9d05c6e99b3b10a
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon,  8 Feb 2021 14:00:37 -0500

Update stdlib

Diffstat:
Mgen-stdlib | 1+
Mmain.ha | 27+++++++++------------------
Mmk/stdlib.mk | 7++++++-
3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/gen-stdlib b/gen-stdlib @@ -21,6 +21,7 @@ gensrcs_rt() { '$(PLATFORM)/segmalloc.ha' \ '$(PLATFORM)/start.ha' \ '$(PLATFORM)/stat.ha' \ + '$(PLATFORM)/$(ARCH).ha' \ '$(PLATFORM)/syscallno$(ARCH).ha' \ '$(PLATFORM)/syscalls.ha' \ '$(PLATFORM)/types.ha' \ diff --git a/main.ha b/main.ha @@ -1,25 +1,16 @@ use fmt; -use io; use os; +use os::exec; export fn main() void = { - if (len(os::args) == 1z) match (io::copy(os::stdout, os::stdin)) { - err: io::error => fmt::fatal("Error: {}", io::errstr(err)), - size => os::exit(0), + let cmd = match (exec::cmd(os::args[1], os::args[2..]...)) { + err: exec::error => + fmt::fatal("Error: exec::cmd: {}", exec::errstr(err)), + cmd: exec::command => cmd, }; - - 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 => fmt::fatal("Error: {}: {}", - os::args[i], io::errstr(err)), - }; - defer io::close(in); - - match (io::copy(os::stdout, in)) { - err: io::error => - fmt::fatal("Error: {}", io::errstr(err)), - size => void, - }; + match (exec::start(&cmd)) { + err: exec::error => + fmt::fatal("Error: exec::start: {}", exec::errstr(err)), + * => void, }; }; diff --git a/mk/stdlib.mk b/mk/stdlib.mk @@ -8,6 +8,7 @@ stdlib_rt_srcs= \ $(STDLIB)/rt/$(PLATFORM)/segmalloc.ha \ $(STDLIB)/rt/$(PLATFORM)/start.ha \ $(STDLIB)/rt/$(PLATFORM)/stat.ha \ + $(STDLIB)/rt/$(PLATFORM)/$(ARCH).ha \ $(STDLIB)/rt/$(PLATFORM)/syscallno$(ARCH).ha \ $(STDLIB)/rt/$(PLATFORM)/syscalls.ha \ $(STDLIB)/rt/$(PLATFORM)/types.ha \ @@ -231,6 +232,7 @@ testlib_rt_srcs= \ $(STDLIB)/rt/$(PLATFORM)/segmalloc.ha \ $(STDLIB)/rt/$(PLATFORM)/start.ha \ $(STDLIB)/rt/$(PLATFORM)/stat.ha \ + $(STDLIB)/rt/$(PLATFORM)/$(ARCH).ha \ $(STDLIB)/rt/$(PLATFORM)/syscallno$(ARCH).ha \ $(STDLIB)/rt/$(PLATFORM)/syscalls.ha \ $(STDLIB)/rt/$(PLATFORM)/types.ha \ @@ -367,7 +369,10 @@ testlib_io_srcs= \ $(STDLIB)/io/copy.ha \ $(STDLIB)/io/println.ha \ $(STDLIB)/io/stream.ha \ - $(STDLIB)/io/limit.ha + $(STDLIB)/io/limit.ha \ + $(STDLIB)/io/+test/copy.ha \ + $(STDLIB)/io/+test/limit.ha \ + $(STDLIB)/io/+test/stream.ha $(TESTCACHE)/io/io.ssa: $(testlib_io_srcs) $(testlib_rt) $(testlib_strings) @printf 'HAREC \t$@\n'