~torresjrjr/dc

3a6c91c9ffb3fc664cfa5ffe8f273fbc0f1501ae — Curtis Arthaud a month ago 8ceb910 master
update for current language

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

M dc.ha
M dc.ha => dc.ha +11 -12
@@ 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 = {