hautils

[hare] Set of POSIX utilities
Log | Files | Refs | README | LICENSE

commit f8a309c38b12bd100c581388997c2cc4110b2365
parent 746f261aaf63a48ce2a1a147feecbff594f39d2f
Author: Byron Torres <b@torresjrjr.com>
Date:   Thu, 10 Aug 2023 06:48:16 +0100

Update for stdlib changes

Diffstat:
Mhead.ha | 2+-
Mnl.ha | 2+-
Mtee.ha | 4++--
Muniq.ha | 6+++---
Mwc.ha | 16++++++++--------
5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/head.ha b/head.ha @@ -41,7 +41,7 @@ export fn utilmain() (void | main::error) = { yield file; }; static let buf: [os::BUFSIZ]u8 = [0...]; - const file = bufio::buffered(file, buf, []); + const file = bufio::init(file, buf, []); match (head(&file, n)) { case void => void; case let err: main::error => diff --git a/nl.ha b/nl.ha @@ -236,7 +236,7 @@ export fn utilmain() (void | main::error) = { case let file: io::file => static const rbuf: [os::BUFSIZ]u8 = [0...]; static const wbuf: [os::BUFSIZ]u8 = [0...]; - yield &bufio::buffered(file, rbuf, wbuf); + yield &bufio::init(file, rbuf, wbuf); } else os::stdin; diff --git a/tee.ha b/tee.ha @@ -14,12 +14,12 @@ export fn utilmain() (main::error | void) = { ); defer getopt::finish(&cmd); - let flags = fs::flags::WRONLY; + let flags = fs::flag::WRONLY; for (let i = 0z; i < len(cmd.opts); i += 1) { const opt = cmd.opts[i]; switch (opt.0) { case 'a' => - flags |= fs::flags::APPEND; + flags |= fs::flag::APPEND; case 'i' => abort("TODO: Ignore SIGINT"); case => diff --git a/uniq.ha b/uniq.ha @@ -142,7 +142,7 @@ export fn utilmain() (main::error | void) = { fmt::fatalf("Error opening '{}': {}", cmd.args[0], fs::strerror(err)); case let file: io::file => - cfg.input = &bufio::buffered(file, stdin_rbuf, stdin_wbuf); + cfg.input = &bufio::init(file, stdin_rbuf, stdin_wbuf); }; }; defer io::close(cfg.input)!; @@ -150,12 +150,12 @@ export fn utilmain() (main::error | void) = { static const stdout_rbuf: [os::BUFSIZ]u8 = [0...]; static const stdout_wbuf: [os::BUFSIZ]u8 = [0...]; if (len(cmd.args) == 2) { - match (os::create(cmd.args[1], 0o666, fs::flags::WRONLY)) { + match (os::create(cmd.args[1], 0o666, fs::flag::WRONLY)) { case let err: fs::error => fmt::fatalf("Error opening '{}': {}", cmd.args[1], fs::strerror(err)); case let file: io::file => - cfg.output = &bufio::buffered(file, stdout_rbuf, stdout_wbuf); + cfg.output = &bufio::init(file, stdout_rbuf, stdout_wbuf); }; }; defer io::close(cfg.output)!; diff --git a/wc.ha b/wc.ha @@ -6,7 +6,7 @@ use io; use main; use os; use strings; -use strio; +use memio; type items = enum uint { BYTES = 1 << 0, @@ -127,23 +127,23 @@ fn countchars(result: *counts, buf: []u8) void = { fn print(mode: items, result: *counts, path: str) (void | main::error) = { static let fmtbuf: [32]u8 = [0...]; - let buf = strio::fixed(fmtbuf); + let buf = memio::fixed(fmtbuf); if (mode & items::LINES > 0) { - strio::concat(&buf, "{0: 7} ")!; + memio::concat(&buf, "{0: 7} ")!; }; if (mode & items::WORDS > 0) { - strio::concat(&buf, "{1: 7} ")!; + memio::concat(&buf, "{1: 7} ")!; }; if (mode & items::BYTES > 0) { - strio::concat(&buf, "{2: 7} ")!; + memio::concat(&buf, "{2: 7} ")!; }; if (mode & items::CHARS > 0) { - strio::concat(&buf, "{3: 7} ")!; + memio::concat(&buf, "{3: 7} ")!; }; if (path != "") { - strio::concat(&buf, "{4}")!; + memio::concat(&buf, "{4}")!; }; - const format = strings::rtrim(strio::string(&buf)); + const format = strings::rtrim(memio::string(&buf)!); fmt::printfln(format, result.lines, result.words, result.bytes, result.chars, path)?; };