hare

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

commit 7398edc63b6204bd60f0d109c43e99bec3cba412
parent eef06dd06191d5af0ced8c89f60e5e815a2f5055
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun,  2 Jan 2022 14:16:29 +0100

update strio usage per upstream changes

TODO: squash me

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mdatetime/format.ha | 14++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/datetime/format.ha b/datetime/format.ha @@ -367,17 +367,16 @@ export fn strptime(b: *builder, layout: str, s: str) (void | errors::invalid) = // The returned string is borrowed from this buffer. export fn bstrftime(buf: []u8, layout: str, dt: *datetime) (str | errors::invalid | io::error) = { let sink = strio::fixed(buf); - defer io::close(sink); - format(sink, layout, dt)?; - return strio::string(sink); + format(&sink, layout, dt)?; + return strio::string(&sink); }; // Formats a [[datetime]] and writes it into a heap-allocated string. // The caller must free the return value. export fn strftime(layout: str, dt: *datetime) (str | errors::invalid | io::error) = { let sink = strio::dynamic(); - format(sink, layout, dt)?; - return strio::finish(sink); + format(&sink, layout, dt)?; + return strio::string(&sink); }; // Formats a [[datetime]] and writes it into a [[io::handle]]. @@ -552,7 +551,6 @@ fn get_default_locale_string_index(iter: *strings::iterator, list: []str) (int | fn get_max_n_digits(iter: *strings::iterator, n: uint) (int | errors::invalid) = { let buf: [64]u8 = [0...]; let bufstr = strio::fixed(buf); - defer io::close(bufstr); for (let i = 0z; i < n; i += 1) { let r: rune = match (strings::next(iter)) { case void => @@ -564,14 +562,14 @@ fn get_max_n_digits(iter: *strings::iterator, n: uint) (int | errors::invalid) = strings::prev(iter); break; }; - match (strio::appendrune(bufstr, r)) { + match (strio::appendrune(&bufstr, r)) { case io::error => return errors::invalid; case => void; }; }; - return match (strconv::stoi(strio::string(bufstr))) { + return match (strconv::stoi(strio::string(&bufstr))) { case let res: int => yield res; case =>