~sircmpwn/hare-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH hautils] Update for stdlib changes

Details
Message ID
<20230810054817.102579-1-b@torresjrjr.com>
DKIM signature
missing
Download raw message
Patch: +15 -15
---
 head.ha |  2 +-
 nl.ha   |  2 +-
 tee.ha  |  4 ++--
 uniq.ha |  6 +++---
 wc.ha   | 16 ++++++++--------
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/head.ha b/head.ha
index c06b7ea..4b3394e 100644
--- 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
index 4ec228f..9120f4e 100644
--- 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
index 1076932..82a5fb9 100644
--- 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
index 1b9123a..56a3ed3 100644
--- 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
index fe45946..abcc6e9 100644
--- 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)?;
};
-- 
2.41.0
Details
Message ID
<CUTVOPZMYXRI.TMDJFWC59TB8@taiga>
In-Reply-To
<20230810054817.102579-1-b@torresjrjr.com> (view parent)
DKIM signature
missing
Download raw message
Thanks!

To git@git.sr.ht:~sircmpwn/hautils
   746f261..f8a309c  master -> master
Reply to thread Export thread (mbox)