ref/hare/strings/replace.ha:46-66. Two-pass byte scan: pass 1 counts non-overlapping needle hits via bytes.hasprefix, pass 2 allocs the result []u8 at exact size and copies chunks + replacement. Single nomem propagation site at the alloc — ww's append builtin aborts on OOM (#11), so the per-chunk append(...)? form Hare uses is not available; the exact-size single alloc is equivalent in spec. total==0 returns {nil,0} to dodge rt_alloc(0) per #47. Empty needle is intentionally ungated and loops forever — that's Hare's behavior at ref/hare/strings/replace.ha:31 (i += len(needle) is 0; hasprefix("") always matches). Hare-faithful divergence, documented at the site. multireplace deferred to #49 — its (str, str) variadic gather hits #39 in variadic-param position. Filed and blocked accordingly.
30 KiB
30 KiB