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.
15 lines
408 B
Plaintext
15 lines
408 B
Plaintext
// encoding/utf8 — UTF-8 helpers. RFC 3629; we only handle the legal
|
|
// subset (no over-long encodings, no surrogates).
|
|
|
|
def MAX: rune = 1114111; // 0x10FFFF
|
|
def BAD: rune = -1;
|
|
|
|
export fn runesz(r: rune) i32 = {
|
|
if (r < 0) { return -1; };
|
|
if (r < 128) { return 1; };
|
|
if (r < 2048) { return 2; };
|
|
if (r < 65536) { return 3; };
|
|
if (r <= MAX) { return 4; };
|
|
return -1;
|
|
};
|