[PATCH xfree86] Signed-off-by: Oleh Nykyforchyn <oleh.nyk at gmail.com>

Oleh R. Nykyforchyn oleh.nyk at gmail.com
Mon May 16 11:15:51 PDT 2011


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 |   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



More information about the xorg-devel mailing list