lib: rename stdlib surface to Hare names; add endian/math

Sweeping rename so the lib/ surface mirrors Hare's stdlib spellings.
- ascii: rune-taking predicates; ishex -> isxdigit
- bufio: rinit -> init; take1/takeline -> readbyte/readline
- bytes: indexsub -> index
- encoding/utf8: runelen -> runesz
- errors: eEOF/eShortRead/... -> eof/underread/...
- fmt: errln -> errorln; println/fprintln return i64
- os: readfull/writefull -> readall/writeall; unlink -> remove
- path: isabs -> abs; drop lastindex (now strings.rbyteindex)
- strconv: u64toa/i64toa -> u64tos/i64tos; parse64/parseu64 -> stoi64/stou64
- strings: drop len/isempty; equal -> compare; indexbyte -> byteindex; +rbyteindex
- types: drop numeric helpers (moved to math)
- new lib/endian (htonu16/ntohu16), lib/math (absi32/absi64)
- net: drop htons (use endian.htonu16)

Callers in selfhost/, lib/ww/, cmd/w6c/cgen.c, and test/wcc/700_e2e.c
updated to match.
This commit is contained in:
2026-05-12 00:45:18 +09:00
parent 35421f2561
commit 1ac1d985f6
37 changed files with 597 additions and 568 deletions

View File

@@ -75,13 +75,13 @@ def RELA_ADDEND: u64 = 16u64;
// ---- file slurp --------------------------------------------------------
fn readall(path: *u8) (*u8, u64) = {
fn slurp(path: *u8) (*u8, u64) = {
let fd: i32 = os.open(path, os.O_RDONLY, 0i32);
if (fd < 0) { return nil, 0u64; };
let n: i64 = os.filesize(fd);
if (n < 0i64) { os.close(fd); return nil, 0u64; };
let buf: *u8 = os.alloc(n: u64): *u8;
let got: i64 = os.readfull(fd, buf, n: u64);
let got: i64 = os.readall(fd, buf, n: u64);
os.close(fd);
if (got != n) { return nil, 0u64; };
return buf, n: u64;
@@ -334,7 +334,7 @@ fn loadarchive(l: *lnk, path: *u8, buf: *u8, len: u64) i32 = {
export fn load(l: *lnk, path: *u8) i32 = {
let bufp: *u8;
let buflen: u64;
bufp, buflen = readall(path);
bufp, buflen = slurp(path);
if (bufp == nil) {
os.write(2, "w6l: cannot read object\n".ptr, 23u64);
return -1;