nx_fix_putn.nx
buildroot/runtime/nx_fix_putn.nx
about
nx_fix_putn.nx -- AUTO-FIXER for the propagating leaky-putn anti-pattern (per-character sys_mmap(1) inside a
digit-print loop = a mmap-in-loop leak-by-construction, copied into ~40 fetch/census/gate organs). Replaces
the exact leaky block with the hoisted write-once form -- BYTE-EXACT match, so a variant that doesn't match
is left untouched (safe: never a fuzzy edit). Modes:
nx_fix_putn <file> -- fix one file (report FIXED / no-match)
nx_fix_putn sweep <dir> -- walk dir, fix every matching .nx, report count
After fixing, the caller re-gates/rebuilds (the fix is proven verdict-equal to the 3 hand-fixes). This is the
"build the tool so eating the debt is one step" move. Sovereign (getdents64 + file IO, no shell). expect_exit: 0
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_dir.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 11 | const FX_MAGIC_4096: i64 = 4096 |
| 13 | const FX_BUF: i64 = 1048576 |
| 14 | const FX_CAP: i64 = 16384 |
| 19 | const FX_NEEDLE: *u8 = " var i: i64 = k - 1\x0a while i >= 0 { let o: *u8 = sys_mmap(1); o[0] = d[i]; sys_write(1, o, 1); i = i - 1 }\x00" |
| 21 | const FX_REPL: *u8 = " let o: *u8 = sys_mmap(24); var i: i64 = 0\x0a while i < k { o[i] = d[k - 1 - i]; i = i + 1 }\x0a sys_write(1, o, k)\x00" |
functions
| 23 | func fx_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 24 | func fx_putn(v: i64) -> i64 |
| 31 | func fx_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 32 | func fx_read(path: *u8, buf: *u8) -> i64 |
| 39 | func fx_find(buf: *u8, n: i64, needle: *u8) -> i64 |
| 51 | func fx_fix_file(path: *u8, buf: *u8, out: *u8) -> i64 |
| 70 | func main(argc: i64, argv: *i64) -> i64 |