code wiki / _hdl_build / nx_grep_hb.nx

nx_grep_hb.nx

buildroot/runtime/_hdl_build/nx_grep_hb.nx

2135 B39 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind orphan librarytopic grep
docsdependenciesstructsconstsfunctions

about

nx_grep.nx -- SOVEREIGN grep in NishiLang (operator: "we want nishi lang only not .sh... same with grep and other things you like to cheat with -- the nishi team should be all sovereign"). Replaces the shell `grep`: read a file, scan it line by line, print + count lines matching a pattern -- all bits-up over sys_read_file + substring search, no 3rd-party tool. This is the team owning text search over files, not shelling out. license_tier: ORIGINAL Reuses re_find (nx_research_extract).

dependencies 2 imports · 0 importers

nx_research_extract.nx nx_syscalls.nx nx_grep_hb.nx

imports: nx_research_extract.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

structs

none

consts

none

functions

10func _gp_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
calls 1: sys_write
13func grep_line_matches(line: *u8, len: i64, needle: *u8) -> i64 { if re_find(line, len, needle) >= 0 { return 1 } return 0 }
called by 1: grep_file calls 1: re_find
16func grep_file(path: *u8, needle: *u8, print_matches: i64) -> i64
37func grep_count(path: *u8, needle: *u8) -> i64 { return grep_file(path, needle, 0) }
calls 1: grep_file
39func grep_has(path: *u8, needle: *u8) -> i64 { if grep_file(path, needle, 0) > 0 { return 1 } return 0 }
calls 1: grep_file