hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 39d3505466dcb634e6ce67373035d2c5589ea6e8
parent 926a0d687d34cffe2f142f6399884fcbaba15920
Author: Byron Torres <b@torresjrjr.com>
Date:   Mon, 16 May 2022 17:23:37 +0100

time::chrono: fix reading of leap-seconds.lists

Signed-off-by: Byron Torres <b@torresjrjr.com>

Diffstat:
Mtime/chrono/leapsec.ha | 17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/time/chrono/leapsec.ha b/time/chrono/leapsec.ha @@ -1,7 +1,6 @@ // License: MPL-2.0 // (c) 2021-2022 Byron Torres <b@torresjrjr.com> use bufio; -use fmt; use fs; use io; use os; @@ -47,22 +46,24 @@ let utc_leapsecs: [](i64, i64) = []; case fs::error => return; }; - read_leapsecfile(file, &utc_leapsecs)!; + defer io::close(file)!; + read_utc_leapsecs_file(file, &utc_leapsecs)!; }; -fn read_leapsecfile(h: io::handle, leapsecs: *[](i64, i64)) (void | io::error) = { - let buffer: [os::BUFSIZ]u8 = [0...]; - const b = bufio::buffered(h, buffer, []); +fn read_utc_leapsecs_file( + h: io::handle, + leapsecs: *[](i64, i64), +) (void | io::error) = { for (true) { - const line = match (bufio::scanline(&b)) { + const line = match (bufio::scanline(h)) { case let err: io::error => return err; case io::EOF => return; case let line: []u8 => - yield line; + yield strings::fromutf8(line); }; - const line = fmt::bsprint(line); + defer free(line); if (strings::hasprefix(line, '#')) { continue; };