nx_grep.nx
buildroot/runtime/nx_grep.nx
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 · 11 importers
diagram shows first 10 each side; +0 more imports, +1 more importers in the complete lists below.
imports: nx_research_extract.nxnx_syscalls.nx
imported by: nx_doc_census.nxnx_doc_census_real_audit_test.nxnx_doc_census_real_listing_test.nxnx_doc_census_run_test.nxnx_doc_census_test.nxnx_doc_inref.nxnx_doc_inref_test.nxnx_grep_test.nxnx_tool_census.nxnx_tool_census_run_test.nxnx_tool_census_test.nx
structs
| none |
consts
| none |
functions
| 10 | func _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 |
| 13 | func grep_line_matches(line: *u8, len: i64, needle: *u8) -> i64 { if re_find(line, len, needle) >= 0 { return 1 } return 0 } |
| 16 | func grep_file(path: *u8, needle: *u8, print_matches: i64) -> i64 |
| 37 | func grep_count(path: *u8, needle: *u8) -> i64 { return grep_file(path, needle, 0) } |
| 39 | func grep_has(path: *u8, needle: *u8) -> i64 { if grep_file(path, needle, 0) > 0 { return 1 } return 0 } |