Instead of nesting possible handlers ever deeper, swap out the logic
for code which simply iterates through a list of function pointers.
We return as soon as a one of the functions in the list returns
sucessfully.
---
 tools/xsetwacom.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 5c1eaa1..32a1d83 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -2176,6 +2176,9 @@ static Bool set_output_area(Display *dpy, XDevice *dev, 
param_t *param, int argc
 
 static void set_output(Display *dpy, XDevice *dev, param_t *param, int argc, 
char **argv)
 {
+       Bool (*fn[]) (Display * dpy, XDevice *dev, param_t *param, int argc, 
char **argv) =
+       { set_output_area, set_output_xinerama, set_output_xrandr };
+
        if (argc == 0)
        {
                float matrix[9] = { 1, 0, 0,
@@ -2191,10 +2194,13 @@ static void set_output(Display *dpy, XDevice *dev, 
param_t *param, int argc, cha
                return;
        }
 
-       if (!set_output_area(dpy, dev, param, argc, argv))
-               if (!set_output_xinerama(dpy, dev, param, argc, argv))
-                       if (!set_output_xrandr(dpy, dev, param, argc, argv))
-                               fprintf(stderr, "Unable to map tablet to output 
'%s'.\n", *argv);
+       for (int i=0; i<sizeof(fn)/sizeof(fn[0]); i++)
+       {
+               if (fn[i](dpy, dev, param, argc, argv))
+                       return;
+       }
+
+       fprintf(stderr, "Unable to map tablet to output '%s'.\n", *argv);
 }
 
 
-- 
1.7.6


------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to