[PATCH hare-csv] update for Hare 0.24.2
Export this patch
---
format/csv/reader.ha | 7 ++++---
format/csv/writer.ha | 14 +++++++-------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/format/csv/reader.ha b/format/csv/reader.ha
index 53b711c..e83555d 100644
--- a/format/csv/reader.ha
+++ b/format/csv/reader.ha
@@ -2,6 +2,7 @@ use bufio;
use bytes;
use fmt;
use io;
+use memio;
use strings;
use encoding::utf8;
@@ -24,7 +25,7 @@ export fn newreader(in: io::handle, delim: rune) reader = {
// Reads one record (a slice of strings) from a [[reader]].
export fn read(r: *reader) ([]str | io::EOF | encoding::utf8::invalid | io::error) = {
- let line = match (bufio::scanline(r.in)?) {
+ let line = match (bufio::read_line(r.in)?) {
case let b: []u8 =>
yield strings::fromutf8(bytes::trim(b, ' '))?;
case io::EOF =>
@@ -86,7 +87,7 @@ export fn read(r: *reader) ([]str | io::EOF | encoding::utf8::invalid | io::erro
21,"2""2",23
31,32,"3,,,,3"
`);
- let buf = bufio::fixed(csv, io::mode::READ);
+ let buf = memio::fixed(csv);
let r = newreader(&buf, ',');
@@ -117,7 +118,7 @@ export fn read(r: *reader) ([]str | io::EOF | encoding::utf8::invalid | io::erro
21|"2""2"|23
31|32|3,,,,3
`);
- let buf = bufio::fixed(csv, io::mode::READ);
+ let buf = memio::fixed(csv);
let r = newreader(&buf, '|');
diff --git a/format/csv/writer.ha b/format/csv/writer.ha
index 8b6248e..a898ac0 100644
--- a/format/csv/writer.ha
+++ b/format/csv/writer.ha
@@ -2,8 +2,8 @@ use bufio;
use encoding::utf8;
use io;
use fmt;
+use memio;
use strings;
-use strio;
// An [[io::handle]] wrapper for rriting CSV data, with a configurable
// delimiter.
@@ -38,9 +38,9 @@ export fn write(w: *writer, record: []str) (void | io::error) = {
};
if (hasdelim || hasquote) {
- strio::concat(w.out, quote, rec, quote)?;
+ memio::concat(w.out, quote, rec, quote)?;
} else {
- strio::concat(w.out, rec)?;
+ memio::concat(w.out, rec)?;
};
if (i == len(record) - 1) {
@@ -54,7 +54,7 @@ export fn write(w: *writer, record: []str) (void | io::error) = {
};
@test fn write() void = {
- let buf = strio::dynamic();
+ let buf = memio::dynamic();
let w = newwriter(&buf, ',');
@@ -69,11 +69,11 @@ export fn write(w: *writer, record: []str) (void | io::error) = {
31,32,"3,,,,3"
`;
- assert(strings::compare(strio::string(&buf), expected) == 0);
+ assert(strings::compare(memio::string(&buf)!, expected) == 0);
};
@test fn write_delim() void = {
- let buf = strio::dynamic();
+ let buf = memio::dynamic();
let w = newwriter(&buf, '|');
@@ -88,5 +88,5 @@ export fn write(w: *writer, record: []str) (void | io::error) = {
31|"3|2"|3,,,,3
`;
- assert(strings::compare(strio::string(&buf), expected) == 0);
+ assert(strings::compare(memio::string(&buf)!, expected) == 0);
};
--
2.34.1