xfree86: allow negative conditions in "Match*" statements Match statement syntax is extended to allow strings like: "aaa,!a,bbb,!b,ccc,!c" Match succeedes if an attribute matches aaa, bbb, or ccc, or does not match neither a, b, or c.
Signed-off-by: Oleh Nykyforchyn <[email protected]> --- hw/xfree86/common/xf86Xinput.c | 28 ++++++++++++++++++++++------ 1 files changed, 22 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index e7e1ce1..9462bad 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -495,13 +495,29 @@ MatchAttrToken(const char *attr, struct list *patterns, char * const *cur; Bool match = FALSE; - for (cur = group->values; *cur; cur++) - if ((*compare)(attr, *cur) == 0) { - match = TRUE; - break; + for (cur = group->values; *cur; cur++) { + if (**cur == '!') { + /* + * A condition starting with '!' is NEGATIVE + * If it is matched, the match is rejected + */ + if ((*compare)(attr, *cur+1) == 0) + return FALSE; + else + match = TRUE; + } + else { + if ((*compare)(attr, *cur) == 0) { + match = TRUE; + break; + } + } } - if (!match) - return FALSE; + /* + * Either a positive condition or all + * negative conditions succeeded + */ + if (!match) return FALSE; } /* All the entries in the list matched the attribute */ -- 1.7.4.4 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
