~sircmpwn/hare-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH hare 1/2] encoding::utf8: move utf8sz to rune.ha

Details
Message ID
<20220623232334.31183-1-sebastian@sebsite.pw>
DKIM signature
pass
Download raw message
Patch: +10 -10
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();
};

// Returns the expected length of a UTF-8 codepoint in bytes given its first
// byte, or void if the given byte doesn't begin a valid UTF-8 sequence.
export fn utf8sz(c: u8) (size | void) = {
	for (let i = 0z; i < len(sizes); i += 1) {
		if (c & sizes[i].mask == sizes[i].result) {
			return sizes[i].octets;
		};
	};
};
diff --git a/encoding/utf8/rune.ha b/encoding/utf8/rune.ha
index ccdfe1d1..10d1aa17 100644
--- a/encoding/utf8/rune.ha
+++ b/encoding/utf8/rune.ha
@@ -27,3 +27,13 @@ export fn runesz(r: rune) size = {
		else if (ch < 0x10000) 3
		else 4;
};

// Returns the expected length of a UTF-8 codepoint in bytes given its first
// byte, or void if the given byte doesn't begin a valid UTF-8 sequence.
export fn utf8sz(c: u8) (size | void) = {
	for (let i = 0z; i < len(sizes); i += 1) {
		if (c & sizes[i].mask == sizes[i].result) {
			return sizes[i].octets;
		};
	};
};
-- 
2.36.1

[PATCH hare 2/2] encoding::utf8: don't recognize 5/6 octet sequences as valid

Details
Message ID
<20220623232334.31183-2-sebastian@sebsite.pw>
In-Reply-To
<20220623232334.31183-1-sebastian@sebsite.pw> (view parent)
DKIM signature
pass
Download raw message
Patch: +0 -2
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 },
	rsize { mask = 0xFE, result = 0xF8, octets = 6 },
];

// Returns the size of a rune, in octets, when encoded as UTF-8.
-- 
2.36.1

[hare/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CKXWG6WT5AJZ.3L3BA8CBN4QXV@cirno>
In-Reply-To
<20220623232334.31183-2-sebastian@sebsite.pw> (view parent)
DKIM signature
missing
Download raw message
hare/patches: SUCCESS in 1m30s

[encoding::utf8: move utf8sz to rune.ha][0] from [Sebastian][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/33237
[1]: sebastian@sebsite.pw

✓ #786651 SUCCESS hare/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/786651
✓ #786652 SUCCESS hare/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/786652
Reply to thread Export thread (mbox)