<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] allow octal codes with more than three digits



On Thu, Apr 22, 2010 at 11:11:15AM -0700, Michael Elkins wrote:
> allow octal codes with more than three digits
> 
little surprisingly, this patch actually works. ;)

i modified it as discussed when you created it weeks ago. take it or
leav it. :)
# HG changeset patch
# User Oswald Buddenhagen <ossi@xxxxxxx>
# Date 1273427960 -7200
# Branch HEAD
# Node ID 54a15c8a59acb5e8b03b82bc0bf7127c1504aac5
# Parent  e82ce0b30e0fcc000e68675fe4c9d08a1b10536f
reject whitespace enclosing the keycode

there is really no reason to accept it, so don't add "syntax noise"
to the config language.

diff -r e82ce0b30e0f -r 54a15c8a59ac keymap.c
--- a/keymap.c  Thu Apr 22 11:11:12 2010 -0700
+++ b/keymap.c  Sun May 09 19:59:20 2010 +0200
@@ -135,10 +135,12 @@
 static int parse_keycode (const char *s)
 {
     const char *endChar;
-    long int result = strtol(s+1, &endChar, 8);
-    /* allow trailing whitespace, eg.  < 1001 > */
-    while (ISSPACE(*endChar))
-       ++endChar;
+    long int result;
+    /* strtol would skip whitespace. we don't want to. */
+    if (!isdigit(s[1])) {
+       return -1;
+    }
+    result = strtol(s+1, &endChar, 8);
     /* negative keycodes don't make sense, also detect overflow */
     if (*endChar != '>' || result < 0 || result == LONG_MAX) {
        return -1;