glob.nx
buildroot/runtime/glob.nx
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
imports: syscalls.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
| none |
functions
| 38 | func glob_match_class(pattern: *u8, pp: *i64, c: i64) -> i64 {
called by 1: glob_match_at |
| 97 | func glob_match_at(pattern: *u8, pp: i64, text: *u8, tp: i64) -> i64 { |
| 151 | func glob_match(pattern: *u8, text: *u8) -> i64 { |
| 159 | func main() -> i64 {
calls 1: glob_match |