hare

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

commit aa9d6b57fed162be8d5d1c59ef3fb0614e504bba
parent da442e0bf76cac19a137a3f779b5e0d838b94c8a
Author: Autumn! <autumnull@posteo.net>
Date:   Tue,  9 May 2023 23:51:06 +0000

mime: fix compilation with new strings::cut

Signed-off-by: Autumn! <autumnull@posteo.net>

Diffstat:
Mmime/parse.ha | 17+++++++++++------
Mmime/system.ha | 5++++-
2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/mime/parse.ha b/mime/parse.ha @@ -17,11 +17,13 @@ export type type_params = strings::tokenizer; // cause [[errors::invalid]] to be returned unless [[next_param]] is used to // enumerate all of the parameters. export fn parse(in: str) ((str, type_params) | errors::invalid) = { - const items = strings::cut(in, ";"); - const mtype = items.0, params = items.1; - const items = strings::cut(mtype, "/"); - if (len(items.0) < 1 || len(items.1) < 1) { - return errors::invalid; + const (mtype, params) = match (strings::cut(in, ";")) { + case void => yield (in, ""); + case let items: (str, str) => yield items; + }; + const items = match (strings::cut(mtype, "/")) { + case void => return errors::invalid; + case let items: (str, str) => yield items; }; typevalid(items.0)?; typevalid(items.1)?; @@ -43,7 +45,10 @@ export fn next_param(in: *type_params) ((str, str) | void | errors::invalid) = { return; }; - const items = strings::cut(tok, "="); + const items = match (strings::cut(tok, "=")) { + case void => return errors::invalid; + case let items: (str, str) => yield items; + }; // The RFC does not permit whitespace here, but whitespace is very // common in the wild. ¯\_(ツ)_/¯ items.0 = strings::trim(items.0); diff --git a/mime/system.ha b/mime/system.ha @@ -49,7 +49,10 @@ fn load_systemdb() (void | fs::error | io::error) = { continue; }; - const items = strings::cut(line, "\t"); + const items = match (strings::cut(line, "\t")) { + case void => continue; + case let items: (str, str) => yield items; + }; const mime = strings::trim(items.0), exts = strings::trim(items.1); if (len(exts) == 0) {