~autumnull/treecat-dev

update for stdlib bufio/memio and sort v1 PROPOSED

Coutinho de Souza: 1
 update for stdlib bufio/memio and sort

 2 files changed, 5 insertions(+), 4 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~autumnull/treecat-dev/patches/46998/mbox | git am -3
Learn more about email & git

[PATCH] update for stdlib bufio/memio and sort Export this patch

From: Gustavo Coutinho de Souza <dev@onemoresuza.mailer.me>

Rename `bufio` functions with `scan` to `read_`.

Replace `sort::strings` with `sort::sort`.

These changes allow the program to be compiled against the Hare version
on Nixpkgs[1] and on Alpine[2].

[1]: https://github.com/NixOS/nixpkgs/blob/efe27d768e91ae9b8d3f59820f6a77193b0d67e6/pkgs/development/compilers/hare/default.nix#L23
[2]: https://git.alpinelinux.org/aports/tree/community/hare/APKBUILD?id=d3f97c2ebd124a4f7cc262f920fc68a7bec552ea#n4
---
 src/treecat.ha   | 3 ++-
 src/untreecat.ha | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/treecat.ha b/src/treecat.ha
index 89a2d61..f74d90b 100644
--- a/src/treecat.ha
+++ b/src/treecat.ha
@@ -6,6 +6,7 @@ use memio;
use os;
use path;
use sort;
use sort::cmp;
use strings;

type coloras = enum {
@@ -123,7 +124,7 @@ fn treecat(
				if (!(fs::isfile(d.ftype) || fs::isdir(d.ftype) || fs::islink(d.ftype))) continue;
				append(children, strings::dup(d.name));
		};
		sort::strings(children);
		sort::sort(children, size(str), &cmp::strs);

		const dir_prefix = strings::concat(prefix, "│   ");
		const final_prefix = strings::concat(prefix, "    ");
diff --git a/src/untreecat.ha b/src/untreecat.ha
index 106f388..f61c1b2 100644
--- a/src/untreecat.ha
+++ b/src/untreecat.ha
@@ -110,7 +110,7 @@ fn untreecat_r(
			fmt::fatal("Unexpected character in symlink prefix");
		};

		const target = match (bufio::scanline(input)?) {
		const target = match (bufio::read_line(input)?) {
			case let b: []u8 => yield b;
			case io::EOF => fmt::fatal("Unexpected EOF, expected symlink target");
		};
@@ -153,7 +153,7 @@ fn untreecat_r(
				fmt::fatal("Unexpected character in file prefix");
			};

			let line = match(bufio::scanline(input)?) {
			let line = match(bufio::read_line(input)?) {
				case let b: []u8 => yield b;
				case io::EOF =>
					if (end) {
@@ -207,7 +207,7 @@ fn untreecat_r(
};

fn scan_filename(input: io::handle) (entry | io::error | utf8::invalid) = {
	match (bufio::scanline(input)?) {
	match (bufio::read_line(input)?) {
	case io::EOF => fmt::fatal("Unexpected EOF");
	case let line: []u8 =>
		defer free(line);
-- 
2.42.0