~torresjrjr/public-inbox

dc: update for current language v1 APPLIED

Curtis Arthaud: 1
 update for current language

 1 files changed, 11 insertions(+), 12 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/~torresjrjr/public-inbox/patches/51507/mbox | git am -3
Learn more about email & git

[PATCH dc] update for current language Export this patch

Signed-off-by: Curtis Arthaud <uku82@gmx.fr>
---
 dc.ha | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/dc.ha b/dc.ha
index 99b1315..b425fcc 100644
--- a/dc.ha
+++ b/dc.ha
@@ -41,7 +41,7 @@ export fn main() void = {
		};
		defer io::close(file)!;

		const in = bufio::buffered(file, buf, []);
		const in = bufio::init(file, buf, []);
		match (dc(&in)) {
		case void =>
			void;
@@ -50,7 +50,7 @@ export fn main() void = {
		};
	};

	const in = bufio::buffered(os::stdin, buf, []);
	const in = bufio::init(os::stdin, buf, []);
	match (dc(&in)) {
	case void =>
		void;
@@ -59,9 +59,9 @@ export fn main() void = {
	};
};

fn dc(in: *bufio::bufstream) (void | io::error) = {
fn dc(in: *bufio::stream) (void | io::error) = {
	for (true) {
		const r = match (bufio::scanrune(&in.stream)) {
		const r = match (bufio::read_rune(&in.stream)) {
		case utf8::invalid =>
			fmt::fatal("dc: invalid utf8 input");
		case io::error =>
@@ -92,14 +92,14 @@ fn dc(in: *bufio::bufstream) (void | io::error) = {
		case 'q' =>
			os::exit(0);
		case '!' =>
			const cmdline = match (bufio::scanline(&in.stream)) {
			const cmdline = match (bufio::read_line(&in.stream)) {
			case io::error =>
				fmt::fatal("dc: IO error");
			case io::EOF =>
				fmt::errorln("dc: no shell command given")?;
				continue;
			case let input: []u8 =>
				yield match (strings::try_fromutf8(input)) {
				yield match (strings::fromutf8(input)) {
				case utf8::invalid =>
					fmt::errorln("dc: invalid shell command input")?;
					continue;
@@ -236,17 +236,17 @@ fn dc(in: *bufio::bufstream) (void | io::error) = {
	};
};

@noreturn fn usage_exit(help: []getopt::help) void = {
	getopt::printusage(os::stderr, os::args[0], help);
fn usage_exit(help: []getopt::help) never = {
	getopt::printusage(os::stderr, os::args[0], help)!;
	os::exit(1);
};

fn scan_number(in: *bufio::bufstream) f64 = {
fn scan_number(in: *bufio::stream) f64 = {
	let num: []u8 = [];
	defer free(num);
	let seen_decimal = false;
	for (true) {
		const r = match (bufio::scanrune(in)) {
		const r = match (bufio::read_rune(in)) {
		case utf8::invalid =>
			fmt::fatal("dc: invalid utf8 input");
		case io::error =>
@@ -263,7 +263,7 @@ fn scan_number(in: *bufio::bufstream) f64 = {
			};
		} else {
			bufio::unreadrune(in, r);
			match (strconv::stof64(strings::fromutf8(num))) {
			match (strconv::stof64(strings::fromutf8(num)!)) {
			case (strconv::invalid | strconv::overflow) =>
				abort("dc: invalid numerical input");
			case let n: f64 =>
@@ -271,7 +271,6 @@ fn scan_number(in: *bufio::bufstream) f64 = {
			};
		};
	};
	abort("Unreachable");
};

fn pop() f64 = {
--
2.44.0
Hi Curtis,

Applied to master. Thanks.

To git.sr.ht:~torresjrjr/dc
   8ceb910..3a6c91c  master -> master

Maybe they'll revive :D