lib/ww/lex + selfhost/cmd: astrndup → strings.dup view (γ-1)
#7 Phase A first cut. 13 of 15 astrndup callers converted to the explicit (*u8, n) → str view + strings.dup shape (ref/hare/strings/ dup.ha:7). astrndup export stays in selfhost/cmd/wcc/mem.ww — 2 w6a sites blocked by the selfhost/cmd/w6a/types.ww shadow (filed as #11) and carry an inline WHY pointer until the rename ships. NUL-dependence audit: no consumer reads token text past `.len`. tok.text flows through fputq (length-bounded) and parse.curtext → n.str (streq- based dispatch across check/cgenutil); p.file is written via os.write (ptr,len); selfhost/cmd/ww/main.ww's astrndup'd pathstr only flows into visitseen/visitadd's manual byte-loop, while all OS calls in that file use the unrelated `pathstr(*u8) str` view helper on the raw pointer. Empty-str sites (lex.ww:579, 624, 640) collapse to strings.dup of an empty view; strings.dup short-circuits len==0 (lib/strings/strings.ww:72) and returns {nil, 0} — observationally identical to astrndup's prior {arena_1byte, 0}. Sites: - lib/ww/lex/lex.ww (8: 450, 529, 554, 564, 579, 624, 640, 794) - selfhost/cmd/w6c/main.ww:139 - selfhost/cmd/w6l/dyn.ww:111 (inside dcstrtostr) - selfhost/cmd/w6l/obj.ww:185 (inside cstrtostr) - selfhost/cmd/ww/main.ww:531 Wrappers (dupstr/cstrtostr/dcstrtostr) keep their bodies; deletion deferred to #10.
This commit is contained in:
@@ -13,6 +13,7 @@ package w6l;
|
||||
import os;
|
||||
import rt;
|
||||
import mem;
|
||||
import strings;
|
||||
import sym;
|
||||
|
||||
def ET_REL: i32 = 1;
|
||||
@@ -182,7 +183,10 @@ fn cstreq(p: *u8, lit: str) bool = {
|
||||
// Build a ww str from a NUL-terminated *u8 (for passing to intern).
|
||||
fn cstrtostr(a: *arena, p: *u8) str = {
|
||||
let n: u64 = cstrlen(p);
|
||||
return astrndup(a, p, n);
|
||||
let view: str;
|
||||
view.ptr = p;
|
||||
view.len = n: i32;
|
||||
return strings.dup(view);
|
||||
};
|
||||
|
||||
// ---- archive (SysV ar) types and helpers -------------------------------
|
||||
|
||||
Reference in New Issue
Block a user