pub fn cpatterns_same(a: Option<&Cpattern>, b: Option<&Cpattern>) -> boolExpand description
Port of cpatterns_same(Cpattern a, Cpattern b) from Src/Zle/compmatch.c:42.
static int
cpatterns_same(Cpattern a, Cpattern b)
{
while (a) {
if (!b) return 0;
if (a->tp != b->tp) return 0;
switch (a->tp) {
case CPAT_CCLASS: case CPAT_NCLASS: case CPAT_EQUIV:
if (strcmp(a->u.str, b->u.str) != 0) return 0;
break;
case CPAT_CHAR:
if (a->u.chr != b->u.chr) return 0;
break;
default:
break;
}
a = a->next;
b = b->next;
}
return !b;
}Walk two parallel Cpattern chains testing structural equality
(same tp + same str for class types or same chr for
CPAT_CHAR). Used by cmatchers_same to dedupe matcher specs.
WARNING: param names don’t match C — Rust=(b) vs C=(a, b)
cpatterns_same — see implementation.