Skip to main content

pattern_range_to_string

Function pattern_range_to_string 

Source
pub fn pattern_range_to_string(rangestr: &str) -> String
Expand description

Port of int pattern_range_to_string(char *rangestr, char *outstr) from Src/pattern.c:1179. Walks a Meta-encoded range bytestring, re-emitting the human-readable form: literal chars as-is, PP_RANGE pairs as c1-c2, POSIX classes as [:name:]. Returns the output length; outstr is the destination buffer (NULL = measure-only). The Rust port operates on &str (UTF-8 native) — Meta-byte decode collapses since zshrs’s pattern compiler stores raw chars, so the function effectively walks the chars and emits POSIX class names from the [i] table at range_type’s reverse lookup.

Rust signature: drops C’s outstr out-param. C measures-then-fills via two passes when outstr is non-NULL; Rust returns the String directly. Callers needing the C “measure-only” mode read .len() on the result.