From Sebastian to ~sircmpwn/hare-dev
> +// Get the tzdata directory, from $TZDIR or the fallback > /usr/share/zoneinfo. > +export fn get_tzdir() str = { > + const tzdir = match (os::getenv("TZDIR")) { > + case let tzdir: str => > + yield tzdir; > + case void => > + yield ZONEINFO_PREFIX; > + }; > + return tzdir; > +}; This could use os::tryenv:
From Sebastian to ~sircmpwn/hare-dev
! is highlighted bold red when it appears immediately after a closing
parentheses that wasn't part of a comment, and is not immediately
followed by an equals sign.
Note that this only works when ! comes after a function call, as it
almost always does. Handling all edge cases where ! is used after a
non-call expression is, if not impossible, extremely impractical without
the use of semantic analysis.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
---
Since v1: ! is only highlighted following a function call. See the
commit message for reasoning.
[message trimmed]
From Sebastian to ~sircmpwn/hare-dev
Signed-off-by: Sebastian <sebastian@sebsite.pw> --- io/+freebsd/file.ha | 46 +++++++++++++++++++++++++++++++++---- io/+linux/file.ha | 56 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 93 insertions(+), 9 deletions(-) diff --git a/io/+freebsd/file.ha b/io/+freebsd/file.ha index 81b2c93f..b2a66a6d 100644 --- a/io/+freebsd/file.ha +++ b/io/+freebsd/file.ha @@ -21,7 +21,18 @@ export fn fdopen(fd: int) file = fd; fn fd_read(fd: file, buf: []u8) (size | EOF | error) = { match (rt::read(fd, buf: *[*]u8, len(buf))) { case let err: rt::errno => [message trimmed]
From Sebastian to ~sircmpwn/hare-dev
Both io::underread and utf8::more result in the function returning utf8::invalid, since these are only possible if the codepoint is malformed. Signed-off-by: Sebastian <sebastian@sebsite.pw> --- bufio/scanner.ha | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bufio/scanner.ha b/bufio/scanner.ha index 3e24cb87..b900698d 100644 --- a/bufio/scanner.ha @@ -74,18 +74,22 @@ export fn scanrune( [message trimmed]
From Sebastian to ~sircmpwn/hare-dev
Signed-off-by: Sebastian <sebastian@sebsite.pw> --- encoding/utf8/rune.ha | 2 -- 1 file changed, 2 deletions(-) diff --git a/encoding/utf8/rune.ha b/encoding/utf8/rune.ha index 10d1aa17..0390609d 100644 --- a/encoding/utf8/rune.ha +++ b/encoding/utf8/rune.ha @@ -15,8 +15,6 @@ const sizes: [_]rsize = [ rsize { mask = 0xE0, result = 0xC0, octets = 2 }, rsize { mask = 0xF0, result = 0xE0, octets = 3 }, rsize { mask = 0xF8, result = 0xF0, octets = 4 }, rsize { mask = 0xFC, result = 0xF8, octets = 5 },[message trimmed]
From Sebastian to ~sircmpwn/hare-dev
Signed-off-by: Sebastian <sebastian@sebsite.pw> --- encoding/utf8/decode.ha | 10 ---------- encoding/utf8/rune.ha | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/encoding/utf8/decode.ha b/encoding/utf8/decode.ha index 6c503886..81b06559 100644 --- a/encoding/utf8/decode.ha +++ b/encoding/utf8/decode.ha @@ -154,13 +154,3 @@ export fn valid(src: (str | []u8)) bool = { }; abort(); }; [message trimmed]
From Sebastian to ~sircmpwn/hare-dev
Previously, findall had a bug where consecutive matches wouldn't be
found. Minimal reproduction is given below:
let re = regex::compile(`a`)!;
defer regex::finish(&re);
const matches = regex::findall(&re, "aa");
defer regex::free_matches(matches);
assert(len(matches) == 2);
The assertion failed prior to this commit, since the second "a" was
skipped over. If the string were instead "a a", this would've succeeded.
Although this commit is large, the fix is relatively simple. However,
this commit also does some significant refactoring in the process of
[message trimmed]
From Sebastian to ~sircmpwn/hare-dev
Implements: https://todo.sr.ht/~sircmpwn/hare/710 Signed-off-by: Sebastian <sebastian@sebsite.pw> --- regex/+test.ha | 112 ++++++++++++++++++++++++++++++++++++++++++++ regex/regex.ha | 123 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) diff --git a/regex/+test.ha b/regex/+test.ha index 02e838e7..4e7e5882 100644 --- a/regex/+test.ha +++ b/regex/+test.ha @@ -132,6 +132,71 @@ fn run_findall_case( }; }; [message trimmed]
From Sebastian to ~sircmpwn/hare-dev
Previously, find and findall would return void if no matches were found. This commit changes this behavior, so an empty slice is returned instead. Signed-off-by: Sebastian <sebastian@sebsite.pw> --- Since v1: dropped free_{captures,matches} -> {captures,matches}_free patch, since it's still unclear how these functions should be named. Either the style guide needs to be updated and these functions changed, or other stdlib functions should be changed. regex/+test.ha | 106 +++++++++++++++++++++++-------------------------- regex/README | 30 ++++++-------- regex/regex.ha | 14 ++++--- [message trimmed]
From Sebastian to ~sircmpwn/hare-dev
Signed-off-by: Sebastian <sebastian@sebsite.pw> --- Still needs spec update hare/lex/lex.ha | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha index 2db75c68..c9e836cc 100644 --- a/hare/lex/lex.ha +++ b/hare/lex/lex.ha @@ -415,6 +415,10 @@ fn lex_literal(lex: *lexer) (token | error) = { case 'x' => base = 16; [message trimmed]