hare

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

commit e2f7a14400b2b1a6667f905c954780dabc98c990
parent 7164e8e084983ad2c207632343be65980daa2f7e
Author: Sebastian <sebastian@sebsite.pw>
Date:   Sat, 28 Oct 2023 02:35:01 -0400

encoding::utf8: add strerror

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mencoding/utf8/decode.ha | 7-------
Aencoding/utf8/types.ha | 12++++++++++++
Mmakefiles/freebsd.aarch64.mk | 2+-
Mmakefiles/freebsd.riscv64.mk | 2+-
Mmakefiles/freebsd.x86_64.mk | 2+-
Mmakefiles/linux.aarch64.mk | 2+-
Mmakefiles/linux.riscv64.mk | 2+-
Mmakefiles/linux.x86_64.mk | 2+-
8 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/encoding/utf8/decode.ha b/encoding/utf8/decode.ha @@ -21,13 +21,6 @@ export fn decode(src: (str | []u8)) decoder = decoder { offs = 0, }; -// Returned when more data is needed, i.e. when an incomplete UTF-8 sequence is -// encountered. -export type more = void; - -// Returned when an invalid UTF-8 sequence was found. -export type invalid = !void; - const masks: [2][8]u8 = [ [0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f], [0x7f, 0x1f, 0x0f, 0x0f, 0x0f, 0x07, 0x07, 0x07], diff --git a/encoding/utf8/types.ha b/encoding/utf8/types.ha @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MPL-2.0 +// (c) Hare authors <https://harelang.org> + +// Returned when more data is needed, i.e. when an incomplete UTF-8 sequence is +// encountered. +export type more = void; + +// Returned when an invalid UTF-8 sequence was found. +export type invalid = !void; + +// Converts an error into a human-friendly string. +export fn strerror(err: invalid) str = "Invalid UTF-8"; diff --git a/makefiles/freebsd.aarch64.mk b/makefiles/freebsd.aarch64.mk @@ -15,7 +15,7 @@ $(HARECACHE)/rt.o: $(rt_s) @printf 'AS\t%s\n' "$@" @$(AS) $(ASFLAGS) -o $@ $(rt_s) -encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha +encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha encoding/utf8/types.ha $(HARECACHE)/encoding_utf8.ssa: $(encoding_utf8_ha) @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" diff --git a/makefiles/freebsd.riscv64.mk b/makefiles/freebsd.riscv64.mk @@ -15,7 +15,7 @@ $(HARECACHE)/rt.o: $(rt_s) @printf 'AS\t%s\n' "$@" @$(AS) $(ASFLAGS) -o $@ $(rt_s) -encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha +encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha encoding/utf8/types.ha $(HARECACHE)/encoding_utf8.ssa: $(encoding_utf8_ha) @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" diff --git a/makefiles/freebsd.x86_64.mk b/makefiles/freebsd.x86_64.mk @@ -15,7 +15,7 @@ $(HARECACHE)/rt.o: $(rt_s) @printf 'AS\t%s\n' "$@" @$(AS) $(ASFLAGS) -o $@ $(rt_s) -encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha +encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha encoding/utf8/types.ha $(HARECACHE)/encoding_utf8.ssa: $(encoding_utf8_ha) @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" diff --git a/makefiles/linux.aarch64.mk b/makefiles/linux.aarch64.mk @@ -15,7 +15,7 @@ $(HARECACHE)/rt.o: $(rt_s) @printf 'AS\t%s\n' "$@" @$(AS) $(ASFLAGS) -o $@ $(rt_s) -encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha +encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha encoding/utf8/types.ha $(HARECACHE)/encoding_utf8.ssa: $(encoding_utf8_ha) @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" diff --git a/makefiles/linux.riscv64.mk b/makefiles/linux.riscv64.mk @@ -15,7 +15,7 @@ $(HARECACHE)/rt.o: $(rt_s) @printf 'AS\t%s\n' "$@" @$(AS) $(ASFLAGS) -o $@ $(rt_s) -encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha +encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha encoding/utf8/types.ha $(HARECACHE)/encoding_utf8.ssa: $(encoding_utf8_ha) @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" diff --git a/makefiles/linux.x86_64.mk b/makefiles/linux.x86_64.mk @@ -15,7 +15,7 @@ $(HARECACHE)/rt.o: $(rt_s) @printf 'AS\t%s\n' "$@" @$(AS) $(ASFLAGS) -o $@ $(rt_s) -encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha +encoding_utf8_ha = encoding/utf8/decode.ha encoding/utf8/decodetable.ha encoding/utf8/encode.ha encoding/utf8/rune.ha encoding/utf8/types.ha $(HARECACHE)/encoding_utf8.ssa: $(encoding_utf8_ha) @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@"