pub fn parse_pattern<'a>(
name: &str,
s: &'a str,
end: char,
) -> (Option<Box<Cpattern>>, &'a str, i32, bool)Expand description
Direct port of parse_class(Cpattern p, char *iptr) from Src/Zle/complete.c:480.
93-line parser for a single character-class [...] or
equivalence-class {...} inside a Cpattern. Reads metafied
bytes from iptr, allocates p->u.str of the right size,
fills in the parsed contents (with PP_RANGE / PP_UNKWN tokens
for a-z ranges and [:class:] POSIX-style entries via
range_type lookup).
Static-link path: the metafied-byte + Meta-token + PP_*
encoding doesn’t translate cleanly to Rust’s UTF-8 strings.
Structural port returns the input pointer unmodified (signaling
“consumed nothing, parse failed”) so the caller can detect the
stub state and skip emitting the matcher.
WARNING: param names don’t match C — Rust=(_p) vs C=(p, iptr)
Direct port of Cpattern parse_pattern(char *name, char **sp, int *lp, char e, int *err) from Src/Zle/complete.c:418.
Walks *sp building a Cpattern chain. Stops at end-char e
(or whitespace if e == 0). For each char-position:
[/{→ callparse_classfor[class]/{equiv}?→ CPAT_ANY*/(/)/=→ error (invalid in matcher patterns)\+ char → escape, emit next char as CPAT_CHAR- else → CPAT_CHAR
Returns (chain_head, new_sp, length, err). Error sets err=true
and chain is None; caller bubbles up.
WARNING: signature change — C returns Cpattern + writes through
sp/lp/err; Rust returns the tuple.