lib: banner purge + WHY-only comment sweep (rule 8)
Every // ---- section banner dies (132 -> 0): names carry the WHAT. Narration deleted (filename restatements, run-with lines, what-the- next-line-does); every ref/hare cite, task cite, divergence, ABI/ layout contract, and ownership qualifier kept (borrowed-view lines restored where the sweep over-cut). Comment-only proven: all 442 walk-workdir .s and 32 import-probe .s byte-identical before/after; libbyteid 56-roster all-ID.
This commit is contained in:
@@ -2,12 +2,6 @@
|
||||
// fnmatch:: (ref/hare/fnmatch/fnmatch.ha) using ww byte-indexed
|
||||
// cursors in place of Hare's strings::iterator.
|
||||
//
|
||||
// Surface today:
|
||||
//
|
||||
// fnmatch.flag — enum i32 bitmask (NONE / PATHNAME /
|
||||
// NOESCAPE / PERIOD)
|
||||
// fnmatch.fnmatch(pattern: str, string: str, flags: flag) bool
|
||||
//
|
||||
// Matching rules (Hare-spec):
|
||||
//
|
||||
// - '?' matches any single byte
|
||||
@@ -328,7 +322,6 @@ fn fnmatch_internal(pattern: str, string: str, fl: flag) (bool | invalid) = {
|
||||
let pp: i32 = 0;
|
||||
let sp: i32 = 0;
|
||||
|
||||
// ---- prefix: match up to the first '*' ----------------------
|
||||
let sawstar: bool = false;
|
||||
for (!sawstar) {
|
||||
let scur: i32 = sp;
|
||||
@@ -361,7 +354,6 @@ fn fnmatch_internal(pattern: str, string: str, fl: flag) (bool | invalid) = {
|
||||
if (advance) { sp = scur; };
|
||||
};
|
||||
|
||||
// ---- find the tail (token count after the last '*') ---------
|
||||
let pp_copy: i32 = pp;
|
||||
let pp_last: i32 = pp;
|
||||
let pp_last_cnt: i32 = 0;
|
||||
@@ -398,7 +390,6 @@ fn fnmatch_internal(pattern: str, string: str, fl: flag) (bool | invalid) = {
|
||||
let tail_pos: i32 = string.len - tail_cnt;
|
||||
if (tail_pos < sp_copy) { return false; };
|
||||
|
||||
// ---- tail: match (from pp) against string[tail_pos..] -------
|
||||
let ts: i32 = tail_pos;
|
||||
let tdone: bool = false;
|
||||
for (!tdone) {
|
||||
@@ -439,7 +430,6 @@ fn fnmatch_internal(pattern: str, string: str, fl: flag) (bool | invalid) = {
|
||||
};
|
||||
};
|
||||
|
||||
// ---- middle: greedy match of each star-delimited subpattern --
|
||||
let mid_pat: str;
|
||||
mid_pat.ptr = pattern.ptr + (pp_copy: u64);
|
||||
mid_pat.len = pp_last - pp_copy;
|
||||
@@ -525,7 +515,6 @@ fn fnmatch_pathname(pattern: str, string: str, fl: flag) (bool | invalid) = {
|
||||
let final: bool = false;
|
||||
for (!final) {
|
||||
segstart_pat = pp;
|
||||
// Walk pattern until the next '/' (segment break) or end.
|
||||
let inner: bool = true;
|
||||
let kind: i32 = 0; // 0 = saw '/', 1 = saw end
|
||||
for (inner) {
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// fnmatchtest — exercises lib/fnmatch. Run with
|
||||
// `out/bin/ww run lib/fnmatch/fnmatchtest.ww`.
|
||||
//
|
||||
// Table-driven via the [[check]] helper: every row is the uniform
|
||||
// 4-tuple `(pattern, string, expected, flags)`. Cases follow Hare's
|
||||
// ref/hare/fnmatch/+test.ha (the de-facto spec for this port);
|
||||
@@ -23,8 +20,6 @@ fn check(pat: str, s: str, expected: bool, flags: i32) void = {
|
||||
assert(!(fnmatch.fnmatch(pat, s, f) != expected));
|
||||
};
|
||||
|
||||
// ---- basic literal / wildcard cases ---------------------------------
|
||||
|
||||
@test fn basic() void = {
|
||||
check("a", "a", true, 0);
|
||||
check("b", "b", true, 0);
|
||||
@@ -59,8 +54,6 @@ fn check(pat: str, s: str, expected: bool, flags: i32) void = {
|
||||
check("*?*?*?*?", "abc", false, 0);
|
||||
};
|
||||
|
||||
// ---- bracket expressions: literal / range / negation ----------------
|
||||
|
||||
@test fn brackets() void = {
|
||||
check("[b]", "b", true, 0);
|
||||
check("a[b]c", "abc", true, 0);
|
||||
@@ -110,8 +103,6 @@ fn check(pat: str, s: str, expected: bool, flags: i32) void = {
|
||||
check("[!-ac]", "b", true, 0);
|
||||
};
|
||||
|
||||
// ---- POSIX character classes: [[:alnum:]] / [[:alpha:]] / ... -------
|
||||
|
||||
@test fn ctype() void = {
|
||||
check("[[:alnum:]]", "7", true, 0);
|
||||
check("[[:alpha:]]", "[", false, 0);
|
||||
@@ -140,8 +131,6 @@ fn check(pat: str, s: str, expected: bool, flags: i32) void = {
|
||||
check("[![:alnum:][:digit:]]", "a", false, 0);
|
||||
};
|
||||
|
||||
// ---- flag.PERIOD: leading '.' must be literal in the pattern --------
|
||||
|
||||
@test fn period() void = {
|
||||
let fp: i32 = 4; // flag.PERIOD
|
||||
check(".", ".", true, fp);
|
||||
@@ -152,16 +141,12 @@ fn check(pat: str, s: str, expected: bool, flags: i32) void = {
|
||||
check(".*", "asdf", false, fp);
|
||||
};
|
||||
|
||||
// ---- flag.NOESCAPE: '\\' loses its escape meaning -------------------
|
||||
|
||||
@test fn noescape() void = {
|
||||
let nesc: i32 = 2; // flag.NOESCAPE
|
||||
check("\\", "\\", true, nesc);
|
||||
check("\\*", "\\asdf", true, nesc);
|
||||
};
|
||||
|
||||
// ---- musl-adapted cases (no flags) ---------------------------------
|
||||
|
||||
@test fn musl_basic() void = {
|
||||
check("*.c", "foo.c", true, 0);
|
||||
check("*.c", ".c", true, 0);
|
||||
@@ -201,8 +186,6 @@ fn check(pat: str, s: str, expected: bool, flags: i32) void = {
|
||||
check("[![:d-d]", "[", false, 0);
|
||||
};
|
||||
|
||||
// ---- flag.PATHNAME: '/' must be matched by literal '/' --------------
|
||||
|
||||
@test fn pathname() void = {
|
||||
let fp: i32 = 1; // flag.PATHNAME
|
||||
check("[a-z]/[a-z]", "a/b", true, fp);
|
||||
@@ -217,8 +200,6 @@ fn check(pat: str, s: str, expected: bool, flags: i32) void = {
|
||||
check("???b", "aa/b", false, fp);
|
||||
};
|
||||
|
||||
// ---- flag.PERIOD + flag.PATHNAME combined ---------------------------
|
||||
|
||||
@test fn combined() void = {
|
||||
let pp: i32 = 1; // PATHNAME
|
||||
let fp: i32 = 4; // PERIOD
|
||||
|
||||
Reference in New Issue
Block a user