hare

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

commit 17c38b9486c7f19a8b65b8b524fc9f9e2f538cba
parent 25dc61582fee9d8c225f2058228805929c26cc03
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon, 21 Jun 2021 12:23:05 -0400

bufio::scantok: accept multiple tokens

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

Diffstat:
Mbufio/scanner.ha | 4++--
Munix/resolvconf/load.ha | 2+-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bufio/scanner.ha b/bufio/scanner.ha @@ -16,13 +16,13 @@ export fn scanbyte(stream: *io::stream) (u8 | io::EOF | io::error) = { // Reads a slice of bytes until the delimiter. Delimiter is not included. The // return value must be freed by the caller. -export fn scantok(stream: *io::stream, delim: u8) ([]u8 | io::EOF | io::error) = { +export fn scantok(stream: *io::stream, delim: u8...) ([]u8 | io::EOF | io::error) = { let buf: []u8 = []; for (true) { match (scanbyte(stream)?) { res: u8 => { - if (res == delim) { + if (bytes::contains(delim, res)) { break; }; append(buf, res); diff --git a/unix/resolvconf/load.ha b/unix/resolvconf/load.ha @@ -35,7 +35,7 @@ export fn load() []ip::addr = { const scanner = bufio::fixed(line, io::mode::READ); defer io::close(scanner); - const tok = match (bufio::scantok(scanner, ' ')!) { + const tok = match (bufio::scantok(scanner, ' ', '\t')!) { io::EOF => break, tok: []u8 => tok, };