diff options
Diffstat (limited to 'src/LYKeymap.c')
-rw-r--r-- | src/LYKeymap.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/LYKeymap.c b/src/LYKeymap.c index 639d9492..90cd3c44 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -1,4 +1,4 @@ -/* $LynxId: LYKeymap.c,v 1.73 2010/11/07 21:21:04 tom Exp $ */ +/* $LynxId: LYKeymap.c,v 1.74 2011/05/26 23:24:42 tom Exp $ */ #include <HTUtils.h> #include <LYUtils.h> #include <LYGlobalDefs.h> @@ -1376,32 +1376,37 @@ int lkcstring_to_lkc(const char *src) { int c = -1; - if (strlen(src) == 1) + if (strlen(src) == 1) { c = *src; - else if (strlen(src) == 2 && *src == '^') + } else if (strlen(src) == 2 && *src == '^') { c = src[1] & 037; - else if (strlen(src) >= 2 && isdigit(UCH(*src))) { - if (sscanf(src, "%d", &c) != 1) - return (-1); + } else if (strlen(src) >= 2 && isdigit(UCH(*src))) { + char *next = 0; + + c = (int) strtol(src, &next, 0); + if (next != 0 && *next != '\0') + c = (-1); #ifdef USE_KEYMAPS } else { map_string_to_keysym(src, &c); #ifndef USE_SLANG if (c >= 0) { if ((c & LKC_MASK) > 255 && !(c & LKC_ISLKC)) - return (-1); /* Don't accept untranslated curses KEY_* */ + c = (-1); /* Don't accept untranslated curses KEY_* */ else c &= ~LKC_ISLKC; } #endif #endif } - if (c == CH_ESC) + + if (c == CH_ESC) { escape_bound = 1; - if (c < -1) - return (-1); - else - return c; + } else if (c < -1) { + c = (-1); + } + + return c; } static int LYLoadKeymap(const char *arg GCC_UNUSED, |