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:
2026-08-08 21:10:18 +09:00
parent 659e859f34
commit aadc6618f0
90 changed files with 259 additions and 919 deletions

View File

@@ -1,14 +1,7 @@
// dirs — XDG base directory paths. Port of Hare's lib/dirs
// (ref/hare/dirs/xdg.ha) using the lib/temp-style static `[256]u8`
// pathbuf in place of Hare's `path::buffer` (lib/path doesn't ship
// a buffer type yet).
//
// Surface today (1:1 with Hare's xdg.ha minus runtime()):
//
// dirs.config(prog: str) str — XDG_CONFIG_HOME/<prog>, fallback $HOME/.config/<prog>
// dirs.cache(prog: str) str — XDG_CACHE_HOME/<prog>, fallback $HOME/.cache/<prog>
// dirs.data(prog: str) str — XDG_DATA_HOME/<prog>, fallback $HOME/.local/share/<prog>
// dirs.state(prog: str) str — XDG_STATE_HOME/<prog>, fallback $HOME/.local/state/<prog>
// a buffer type yet). Surface is 1:1 with Hare's xdg.ha minus runtime().
//
// Returns are static-buffer views — borrowed for the lifetime of
// the next dirs call (any of the four above). Callers needing the
@@ -71,9 +64,8 @@ def SEP: u8 = 47u8;
// octal literals, so we name the constant once.
def MODE_0755: i32 = 493i32;
// puts — append `s` to pathbuf at offset `off`, capping against the
// buffer's capacity to leave room for the trailing NUL. Returns the
// new offset. Same shape as lib/temp.puts.
// Caps at 255 to leave room for the trailing NUL. Same shape as
// lib/temp.puts.
fn puts(off: i32, s: str) i32 = {
let i: i32 = 0;
for (i < s.len) {
@@ -84,9 +76,6 @@ fn puts(off: i32, s: str) i32 = {
return off + i;
};
// build — assemble "<base>/<sub>/<prog>" into pathbuf, NUL-terminate,
// and store the length in [[pathlen]]. If `sub` is empty, the
// "/<sub>" segment is skipped and the result is "<base>/<prog>".
// Embedded '/' in `sub` (e.g. ".local/share") is fine — [[os.mkdirs]]
// handles intermediate dirs.
fn build(base: str, sub: str, prog: str) void = {
@@ -112,8 +101,7 @@ fn build(base: str, sub: str, prog: str) void = {
pathlen = off;
};
// view — return a `str` view into pathbuf[0..pathlen]. Borrowed
// for the lifetime of the next dirs call.
// Borrowed for the lifetime of the next dirs call.
fn view() str = {
let r: str;
r.ptr = &pathbuf[0];

View File

@@ -92,8 +92,6 @@ fn gettmpdir() str = {
};
};
// ---- 1: XDG_CONFIG_HOME=<tmpl>/cfg → <tmpl>/cfg/myapp --------------
@test fn test_config_xdg_set() void = {
let tmpl = gettmpdir();
let exp = expected(tmpl, "cfg", "myapp");
@@ -101,8 +99,6 @@ fn gettmpdir() str = {
assert(!(!streq(got, exp)));
};
// ---- 2: XDG_CACHE_HOME="relative/path" → fallback to $HOME/.cache --
//
// Exercises Hare's `if (!path::abs(path)) yield;` branch — a
// non-absolute XDG_*_HOME silently falls through to the HOME path.
@@ -113,8 +109,6 @@ fn gettmpdir() str = {
assert(!(!streq(got, exp)));
};
// ---- 3: XDG_DATA_HOME unset → fallback to $HOME/.local/share -------
@test fn test_data_unset_fallback() void = {
let tmpl = gettmpdir();
let exp = expected(tmpl, ".local/share", "myapp");
@@ -122,8 +116,6 @@ fn gettmpdir() str = {
assert(!(!streq(got, exp)));
};
// ---- 4: XDG_STATE_HOME unset → fallback to $HOME/.local/state ------
@test fn test_state_unset_fallback() void = {
let tmpl = gettmpdir();
let exp = expected(tmpl, ".local/state", "myapp");