code wiki / (root) / nx_glob_v1.nx

nx_glob_v1.nx

buildroot/runtime/nx_glob_v1.nx

6505 B180 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

glob.nx -- POSIX-style glob pattern matching. Supports: ? match exactly one byte (any byte except null) * match zero or more bytes (greedy, with backtrack) [abc] match any byte in the set [a-z] match any byte in the inclusive range [!abc] negated set (not any of abc) \\x literal x (escapes *, ?, [, \) anything literal byte match Used by: fs.nx dir-walk (list files matching *.nx), nxmake.nx dependency inputs, ignore files (.gitignore-style patterns). This is NOT a full regex -- just POSIX fnmatch's basic set. Don't try to encode complex patterns; use a real regex engine when they appear (roadmap: runtime/re.nx, TBD). Invariants: G1 Pure function: no memory allocation, no syscalls; runs purely on the input strings. Safe in tight loops. G2 Linear time in (pattern_len * text_len) worst case -- no catastrophic backtracking because `*` backtrack is bounded by text length. G3 Null-byte terminator aware: both pattern and text stop at '\0'. Callers with embedded-null bytes should pre- sanitize. G4 Character classes support byte ranges only; no Unicode codepoint classes. UTF-8 multibyte treated as opaque bytes (still matches correctly for byte-exact input).

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_glob_v1.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main glob_match glob_match_at glob_match_at ↻ sys_mmap glob_match_class

structs

none

consts

none

functions

44func glob_match_class(pattern: *u8, pp: *i64, c: i64) -> i64
called by 1: glob_match_at
103func glob_match_at(pattern: *u8, pp: i64, text: *u8, tp: i64) -> i64
157func glob_match(pattern: *u8, text: *u8) -> i64
called by 1: main calls 1: glob_match_at
165func main() -> i64
calls 1: glob_match