Skip to main content

subscript_arg_split

Function subscript_arg_split 

Source
pub fn subscript_arg_split(s: &str, ishash: bool) -> Option<(String, String)>
Expand description

!!! WARNING: RUST-ONLY HELPER !!! C has no separate function here: this is the scan loop that OPENS getarg (c:Src/params.c:1533-1541), lifted out because the Rust paramsubst expands the whole subscript in one place and then needs to know where C would have cut it.

c:Src/params.c:1533-1541 — for (t = s, i = 0; (c = t) && ((c != Outbrack && (ishash || c != ‘,’)) || i || inpar); t++) { / Untokenize inull() except before brackets and double-quotes */ if (inull(c)) { c = t[1]; if (c == ‘[’ || … ) { … ++t; } … continue; } if (c == ‘[’ || c == Inbrack) i++; else if (c == ‘]’ || c == Outbrack) i–; if (c == ‘(’ || c == Inpar) inpar++; else if (c == ‘)’ || c == Outpar) inpar–; … }

Returns the two RAW (still unexpanded) argument texts when the scan stopped on a top-level range comma, else None (one argument only). ishash mirrors C’s ishash gate: for a hash, , is an ordinary key byte and never terminates the argument.