~torresjrjr/dc

1c73944df8806b9a34073bae3251457e07a5ca2f — Byron Torres 2 years ago 3ed4fa8
use bufio::bufstream instead of io::handle
1 files changed, 7 insertions(+), 6 deletions(-)

M dc.ha
M dc.ha => dc.ha +7 -6
@@ 42,15 42,16 @@ export fn main() void = {
		defer io::close(file);

		const in = bufio::buffered(file, buf, []);
		dc(in);
		dc(&in);
	};

	dc(os::stdin);
	const in = bufio::buffered(os::stdin, buf, []);
	dc(&in);
};

fn dc(in: io::handle) void = {
fn dc(in: *bufio::bufstream) void = {
	for (true) {
		const r = match (bufio::scanrune(in)) {
		const r = match (bufio::scanrune(&in.stream)) {
		case utf8::invalid =>
			fmt::fatal("dc: invalid utf8 input");
		case io::error =>


@@ 81,7 82,7 @@ fn dc(in: io::handle) void = {
		case 'q' =>
			os::exit(0);
		case '!' =>
			const cmdline = match (bufio::scanline(in)) {
			const cmdline = match (bufio::scanline(&in.stream)) {
			case io::error =>
				fmt::fatal("dc: IO error");
			case io::EOF =>


@@ 227,7 228,7 @@ fn dc(in: io::handle) void = {
	os::exit(1);
};

fn scan_number(in: io::handle) f64 = {
fn scan_number(in: *bufio::bufstream) f64 = {
	let num: []u8 = [];
	defer free(num);
	let seen_decimal = false;