[PATCH xfree86] Allow negative conditions in "Match*" statements
Oleh Nykyforchyn
oleh.nyk at gmail.com
Wed May 18 23:38:23 PDT 2011
On Wed, 18 May 2011 14:08:27 +1000
Peter Hutterer <peter.hutterer at who-t.net> wrote:
> urgh. git diff please next time, i'm really not used to this format anymore.
> but yeah, makes sense now. thank you.
> pop the man page stuff in and I'll merge it in.
Final git diff version of the second patch:
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 <oleh.nyk at gmail.com>
---
hw/xfree86/common/xf86Xinput.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index c08ae53..88cf292 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -509,11 +509,27 @@ 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;
+ }
+ }
+ /*
+ * Hence we accept the match only if either a positive condition
+ * and all previous negative conditions succeed, or ALL (<>0)
+ * negative conditions are successful (i.e. not matched)
+ */
if (!match)
return FALSE;
}
--
1.7.0.1
--
Oleh Nykyforchyn <oleh.nyk at gmail.com>
More information about the xorg-devel
mailing list