hautils

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit e72bac02ba456a87e94afdf05f6f853dc3c1bb2c
parent c1f3bd94162c07f4890655a426c2262adb4ecd57
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Thu,  9 Sep 2021 17:02:33 +0000

Update for yield and io::file

Diffstat:
Mcat.ha | 6+++---
Mhead.ha | 6+++---
Mnl.ha | 4++--
Mtee.ha | 8++++----
4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/cat.ha b/cat.ha @@ -18,9 +18,9 @@ export fn utilmain() (io::error | fs::error | void) = { const file = match (os::open(cmd.args[i])) { err: fs::error => fmt::fatal("Error opening '{}': {}", cmd.args[i], fs::strerror(err)), - file: *io::stream => file, + file: io::file => file, }; - defer io::close(file); - io::copy(os::stdout, file)?; + defer io::close(&file); + io::copy(os::stdout, &file)?; }; }; diff --git a/head.ha b/head.ha @@ -32,11 +32,11 @@ export fn utilmain() (void | main::error) = { const file = match (os::open(cmd.args[i])) { err: fs::error => fmt::fatal("Error opening '{}': {}", cmd.args[i], fs::strerror(err)), - file: *io::stream => file, + file: io::file => file, }; - defer io::close(file); + defer io::close(&file); static let buf: [os::BUFSIZ]u8 = [0...]; - const file = bufio::buffered(file, buf, []); + const file = bufio::buffered(&file, buf, []); defer io::close(file); head(file, n)?; }; diff --git a/nl.ha b/nl.ha @@ -77,10 +77,10 @@ export fn utilmain() (void | main::error) = { true => match (os::open(cmd.args[0])) { err: fs::error => fmt::fatal("Error opening '{}': {}", cmd.args[0], fs::strerror(err)), - file: *io::stream => { + file: io::file => { static const rbuf: [os::BUFSIZ]u8 = [0...]; static const wbuf: [os::BUFSIZ]u8 = [0...]; - bufio::buffered(file, rbuf, wbuf); + yield bufio::buffered(&file, rbuf, wbuf); }, }, false => os::stdin, diff --git a/tee.ha b/tee.ha @@ -25,10 +25,10 @@ export fn utilmain() (main::error | void) = { }; let source = os::stdin; - let files: []*io::stream = []; + let files: []io::file = []; defer { for (let i = 0z; i < len(files); i += 1) { - io::close(files[i]); + io::close(&files[i]); }; free(files); }; @@ -38,9 +38,9 @@ export fn utilmain() (main::error | void) = { err: fs::error => fmt::fatal( "Error opening '{}' for writing: {}", cmd.args[i], fs::strerror(err)), - file: *io::stream => file, + file: io::file => file, }; - source = io::tee(source, file); + source = &io::tee(source, &file); append(files, file); };