dc

Tiny reverse polish desk calculator
Log | Files | Refs | README | LICENSE

commit 1c73944df8806b9a34073bae3251457e07a5ca2f
parent 3ed4fa80d02aa05a0e571cf8ed26652dbb99909c
Author: Byron Torres <b@torresjrjr.com>
Date:   Wed,  2 Feb 2022 00:43:13 +0000

use bufio::bufstream instead of io::handle

Diffstat:
Mdc.ha | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/dc.ha b/dc.ha @@ -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;