Because of how atoi() works, any single non-number (other than the
expected cw,ccw,half,none) would be interpreted as being equivlent
to 'none'. Since the number of valid arguments is very small, we
explicitly check each.

Signed-off-by: Jason Gerecke <killert...@gmail.com>
---
 tools/xsetwacom.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 337aa88..4194781 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -1428,19 +1428,19 @@ static void set_rotate(Display *dpy, XDevice *dev, 
param_t* param, int argc, cha
 
        TRACE("Rotate '%s' for device %ld.\n", argv[0], dev->device_id);
 
-       if (strcasecmp(argv[0], "cw") == 0)
+       if (strcasecmp(argv[0], "cw") == 0 || strcasecmp(argv[0], "1") == 0)
                rotation = 1;
-       else if (strcasecmp(argv[0], "ccw") == 0)
+       else if (strcasecmp(argv[0], "ccw") == 0 || strcasecmp(argv[0], "2") == 
0)
                rotation = 2;
-       else if (strcasecmp(argv[0], "half") == 0)
+       else if (strcasecmp(argv[0], "half") == 0 || strcasecmp(argv[0], "3") 
== 0)
                rotation = 3;
-       else if (strcasecmp(argv[0], "none") == 0)
+       else if (strcasecmp(argv[0], "none") == 0 || strcasecmp(argv[0], "0") 
== 0)
                rotation = 0;
-       else if (strlen(argv[0]) == 1)
+       else
        {
-               rotation = atoi(argv[0]);
-               if (rotation < 0 || rotation > 3)
-                       goto error;
+               fprintf(stderr, "'%s' is not a valid value for the '%s' 
property.\n",
+                       argv[0], param->name);
+               return;
        }
 
        prop = XInternAtom(dpy, param->prop_name, True);
-- 
1.7.4.1


------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to