code wiki / (root) / nx_txtscan.nx

nx_txtscan.nx

buildroot/runtime/nx_txtscan.nx

8657 B223 linesdepth 3pulls 5 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_txtscan.nx -- CLI over nx_txtscan_lib: sovereign, BYTE-ORIENTED text search. The estate already had two sovereign greps (nx_codegrep, nx_shelltool grep) and both are line-oriented, because both reimplemented grep's worldview rather than only its independence. On knowledge/library/write_nsfwbot_flowgpt_2601_14324.txt -- 112,755 bytes, ONE line, which is what scraped text normally looks like -- asking for a pattern returns the whole file as a single "match". This organ reports OFFSETS, which every byte stream has, instead of lines, which only some text has. nx_txtscan find <path> <pattern> [ctx] every hit: offset + a clamped context window nx_txtscan count <path> <pattern> occurrences (overlapping) nx_txtscan ctl <path> non-tab/LF/CR control bytes + run lengths `ctl` is not a bonus mode: it is the capability that found 211 corrupted sources in the local tree, each carrying one 119-byte run of 0x0E where a migration should have rewritten a number formatter. nx_cc accepts 0x0E as whitespace, so every one of those files compiles clean. u2605HONEST TRUNCATION IS PART OF THE CONTRACT. This organ prints `truncated=1` with the counts whenever it did not see everything -- because a capped listing that reports absence is a silent wrong answer, and that exact defect cost this session a job that sat enqueued and ignored while a worker reported "queue empty". license_tier: ORIGINAL module: nishi-core.text.scan.cli capability: TEXT_SCAN_BYTE_ORIENTED

dependencies 3 imports · 0 importers

nx_estate_path.nx nx_itoa_lib.nx nx_txtscan_lib.nx nx_txtscan.nx

imports: nx_estate_path.nxnx_itoa_lib.nxnx_txtscan_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main tw ts_streq ts_ctl ts_slurp ep_open_rd sys_openat_rd sys_mmap ep_join sys_read sys_munmap te tx_next_ctl tx_is_ctl tx_run_len tw ↻ nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write sys_munmap ↻ sys_munmap ↻ ts_note_trunc tw ↻ nxi_out ↻ te ↻ ts_count ts_slurp ↻ te ↻ tx_count tx_next tx_match_at tx_lower tx_len tw ↻ nxi_out ↻ ts_note_trunc ↻ ts_atoi ts_find

structs

none

consts

32const TS_BUF_BYTES: i64 = 33554432
37const TS_SHOW_MAX: i64 = 64
39const TS_CTX_DEFAULT: i64 = 60
40const TS_CTX_MAX: i64 = 400

functions

42func tw(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
43func te(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(2, s, n); return 0 }
47func ts_show(buf: *u8, lo: i64, hi: i64) -> i64
called by 1: ts_find calls 2: tx_is_ctlsys_munmap
61func ts_slurp(path: *u8, buf: *u8, cap: i64, more: *i64) -> i64
83func ts_note_trunc(more: i64, n: i64) -> i64
called by 3: ts_findts_countts_ctl calls 2: twnxi_out
91func ts_find(path: *u8, pat: *u8, ctx: i64) -> i64
called by 1: main calls 10: ts_slurptetx_lentx_nexttwnxi_out+4
126func ts_count(path: *u8, pat: *u8) -> i64
called by 1: main calls 7: ts_slurptetx_counttx_lentwnxi_out+1
140func ts_ctl(path: *u8) -> i64
180func ts_streq(a: *u8, b: *u8) -> i64
called by 1: main
187func ts_atoi(s: *u8) -> i64
called by 1: main
200func main(argc: i64, argv: *i64) -> i64