lib/encoding/base64: Hare base64/base64url on io-streaming surface

Rewrite the buffer-based base64 placeholder as a faithful port of
ref/hare/encoding/base64/base64.ha over the just-landed io-streaming
surface (mirrors lib/encoding/hex).

Ships: std_encoding/url_encoding (module-level `def` consts; decmap
trailing 0xff run spelled out, no '...', to stay on #251 and avoid the
#250 repeat-fill sugar); the streaming encoder newencoder/encode/
encodeslice/encodestr with a padding closer wired into the inline
vtable; encodedsize/decodedsize; and decodestr as a direct in-memory
decode via decmap (the same divergence hex took for its direct path —
its return union carries errors.invalid, unconstrained by io.error).

Deferred (at-site notes): the streaming decoder newdecoder/decode_reader
(#247-sibling, blocked on #199b — io.error lacks errors.invalid).

clear() wipes the work buffers with explicit full-length slices
(`[0:len(...)]`) rather than Hare's bare-array decay (pending #258
[N]T->[]T coercion) to preserve the whole-array hygiene wipe.

base64 graduates off 900_stdlib (cross-module refs resolve only via
driver concatenation, as hex did); coverage at 984_base64_run over the
RFC 4648 §10 vectors for std and url.
This commit is contained in:
2026-06-02 04:55:08 +09:00
parent ca8c78e97d
commit 4d0d3b58e6
3 changed files with 566 additions and 312 deletions

View File

@@ -18,7 +18,6 @@ static const char *modules[] = {
"lib/path/path.ww",
"lib/encoding/utf8/utf8.ww",
"lib/encoding/base32/base32.ww",
"lib/encoding/base64/base64.ww",
"lib/hash/fnv/fnv.ww",
"lib/hash/adler32/adler32.ww",
"lib/hash/crc16/crc16.ww",
@@ -38,14 +37,17 @@ static const char *modules[] = {
* os.strerror (ww folds Hare's sys role into os); lib/strings.iterator
* + lib/strings.next reference utf8.decoder / utf8.done;
* lib/bytes.tokenize references os.assert + types.I64_MAX/MIN per
* ref/hare/bytes/tokenize.ha:23-24,42-43; lib/encoding/hex graduated
* to Hare's io-streaming surface (references io.handle / fmt.fprint /
* memio.dynamic / strconv / errors.invalid). Coverage lives at
* ref/hare/bytes/tokenize.ha:23-24,42-43; lib/encoding/hex and
* lib/encoding/base64 graduated to Hare's io-streaming surface
* (hex references io.handle / fmt.fprint / memio.dynamic / strconv /
* errors.invalid; base64 references io.handle / memio.dynamic /
* bytes.zero / strings.frombytes / errors.invalid). Coverage lives at
* lib/bufio/bufiotest.ww + lib/bytes/bytestest.ww +
* lib/errors/errnotest.ww + lib/fmt/fmttest.ww + lib/os/stattest.ww
* + lib/strings/stringstest.ww + lib/encoding/hex/hextest.ww (wired
* at 998_bufio_run.c, 967_bytes_run.c, 902_errno_run.c, 970_fmt_run.c,
* 976_stat_run.c, 966_strings_run.c, 979_hex_run.c), plus the
* + lib/strings/stringstest.ww + lib/encoding/hex/hextest.ww +
* lib/encoding/base64/base64_test.ww (wired at 998_bufio_run.c,
* 967_bytes_run.c, 902_errno_run.c, 970_fmt_run.c, 976_stat_run.c,
* 966_strings_run.c, 979_hex_run.c, 984_base64_run.c), plus the
* bufio.scanline / fmt.println e2e rows in test/wcc/700_e2e.c. */
"lib/net/net.ww",
NULL