hare

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

commit d4449388c590db10abd2572f13b23496a26a3093
parent abcfcaa9b07699569b23be17d1b1172cf3838f41
Author: Drew DeVault <sir@cmpwn.com>
Date:   Thu, 11 Feb 2021 11:31:32 -0500

Add --gc-sections to LD

Diffstat:
MMakefile | 2+-
Mmain.ha | 27++++++++++++++++++---------
2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile @@ -30,7 +30,7 @@ $(TESTCACHE)/hare.ssa: $(hare_srcs) $(hare_testlib_deps) hare: $(stdlib_start) $(HARECACHE)/hare.o @printf 'LD\t$@\n' - @$(LD) -T $(rtscript) -o $@ \ + @$(LD) -T $(rtscript) --gc-sections -o $@ \ $(stdlib_start) $(HARECACHE)/hare.o $(hare_stdlib_deps) hare-tests: $(testlib_start) $(TESTCACHE)/hare.o diff --git a/main.ha b/main.ha @@ -1,16 +1,25 @@ use fmt; +use io; use os; -use os::exec; export fn main() void = { - 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, + 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), }; - match (exec::start(&cmd)) { - err: exec::error => - fmt::fatal("Error: exec::start: {}", exec::errstr(err)), - * => void, + + 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, + }; }; };