lib: char-literals for ascii/fnmatch/shlex magic decimals (Wave-1)

Replace magic ASCII decimals with char literals in ascii/fnmatch/shlex
predicates (e.g. `c < 48` → `c < '0'`). Byte-id-neutral: ascii params are
rune, so rune<rune emission is unchanged; fnmatch/shlex compare u8 against
value-preserving (<=126) rune constants. Range bounds (0/31/127), the ±32
case offset, the 128 high-bit mask, and fnmatch 0u8 sentinels stay decimal.

Regenerate the three combined.ww that embed ascii (w6c, wwdump, smoke).

Add functional rows pinning predicates reachable only via fnmatch ctype
classes / shlex split: [[:space:]]/[[:print:]]/[[:graph:]] + the '\t' arm
of [[:blank:]] (fnmatchtest), '\t'/'\n' split separators + issafe's
special-char set (shlextest) — so a wrong substitution would be caught.
This commit is contained in:
2026-06-02 19:24:40 +09:00
parent 90479fed68
commit d1310a03ad
8 changed files with 150 additions and 136 deletions

View File

@@ -4363,20 +4363,20 @@ package ascii;
import strings;
export fn isdigit(c: rune) bool = {
if (c < 48) { return false; };
if (c > 57) { return false; };
if (c < '0') { return false; };
if (c > '9') { return false; };
return true;
};
export fn isupper(c: rune) bool = {
if (c < 65) { return false; };
if (c > 90) { return false; };
if (c < 'A') { return false; };
if (c > 'Z') { return false; };
return true;
};
export fn islower(c: rune) bool = {
if (c < 97) { return false; };
if (c > 122) { return false; };
if (c < 'a') { return false; };
if (c > 'z') { return false; };
return true;
};
@@ -4392,22 +4392,22 @@ export fn isalnum(c: rune) bool = {
// isspace — the C/Hare set: space, tab, NL, VT, FF, CR.
export fn isspace(c: rune) bool = {
if (c == 32) { return true; }; // ' '
if (c == 9) { return true; }; // '\t'
if (c == 10) { return true; }; // '\n'
if (c == 11) { return true; }; // '\v'
if (c == 12) { return true; }; // '\f'
if (c == 13) { return true; }; // '\r'
if (c == ' ') { return true; };
if (c == '\t') { return true; };
if (c == '\n') { return true; };
if (c == '\v') { return true; };
if (c == '\f') { return true; };
if (c == '\r') { return true; };
return false;
};
export fn isxdigit(c: rune) bool = {
if (isdigit(c)) { return true; };
if (c >= 65) {
if (c <= 70) { return true; }; // 'A'..'F'
if (c >= 'A') {
if (c <= 'F') { return true; };
};
if (c >= 97) {
if (c <= 102) { return true; }; // 'a'..'f'
if (c >= 'a') {
if (c <= 'f') { return true; };
};
return false;
};
@@ -4441,22 +4441,22 @@ export fn iscntrl(c: rune) bool = {
// isblank — space and tab.
export fn isblank(c: rune) bool = {
if (c == 32) { return true; }; // ' '
if (c == 9) { return true; }; // '\t'
if (c == ' ') { return true; };
if (c == '\t') { return true; };
return false;
};
// isprint — printable: space through '~'.
export fn isprint(c: rune) bool = {
if (c < 32) { return false; };
if (c > 126) { return false; };
if (c < ' ') { return false; };
if (c > '~') { return false; };
return true;
};
// isgraph — printable, non-space.
export fn isgraph(c: rune) bool = {
if (c < 33) { return false; };
if (c > 126) { return false; };
if (c < '!') { return false; };
if (c > '~') { return false; };
return true;
};