diff options
-rw-r--r-- | CHANGES | 7 | ||||
-rw-r--r-- | src/LYKeymap.c | 57 | ||||
-rw-r--r-- | src/LYStrings.c | 13 | ||||
-rw-r--r-- | src/LYStrings.h | 4 |
4 files changed, 43 insertions, 38 deletions
diff --git a/CHANGES b/CHANGES index 437f9606..d85809f7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,9 +1,12 @@ --- $LynxId: CHANGES,v 1.762 2014/12/07 14:36:22 tom Exp $ +-- $LynxId: CHANGES,v 1.763 2014/12/09 01:43:47 tom Exp $ =============================================================================== Changes since Lynx 2.8 release =============================================================================== -2014-12-07 (2.8.9dev.2) +2014-12-08 (2.8.9dev.2) +* correct a bug in the map_string_to_keysym() function introduced in + 2.8.8dev.17: as used via the remap() function, this returns the curses + code for a special key rather than Lynx's internal code (Debian #769601) -TD * add checks when translating from UTF-8 to Unicode, to ensure that only the shortest encoding is accepted. Other/longer encodings are mapped to the UCS replacement character as in xterm (Debian #763268) -TD diff --git a/src/LYKeymap.c b/src/LYKeymap.c index 20d7f101..c8d3a6c0 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -1,4 +1,4 @@ -/* $LynxId: LYKeymap.c,v 1.110 2013/12/17 00:27:55 tom Exp $ */ +/* $LynxId: LYKeymap.c,v 1.113 2014/12/09 01:48:50 tom Exp $ */ #include <HTUtils.h> #include <LYUtils.h> #include <LYGlobalDefs.h> @@ -967,7 +967,7 @@ int lkcstring_to_lkc(const char *src) c = (-1); #ifdef USE_KEYMAPS } else { - map_string_to_keysym(src, &c); + map_string_to_keysym(src, &c, TRUE); #ifndef USE_SLANG if (c >= 0) { /* make curses-keys mapped from Keysym_Strings[] available here */ @@ -1059,39 +1059,37 @@ int remap(char *key, { Kcmd *mp; int c; + int result = 0; #if !defined(DIRED_SUPPORT) || !defined(OK_OVERRIDE) - if (for_dired) - return 0; -#endif - if (func == NULL) - return 0; - c = lkcstring_to_lkc(key); - if (c <= -1) - return 0; - else if (c >= 0) { - /* Remapping of key actions is supported only for basic - * lynxkeycodes, without modifiers etc.! If we get somehow - * called for an invalid lynxkeycode, fail or silently ignore - * modifiers. - kw - */ - if (c & (LKC_ISLECLAC | LKC_ISLAC)) - return 0; - if ((c & LKC_MASK) != c) - c &= LKC_MASK; + if (for_dired) { + return result; } - if (c + 1 >= KEYMAP_SIZE) - return 0; - if ((mp = LYStringToKcmd(func)) != 0) { +#endif + if (func != NULL) { + c = lkcstring_to_lkc(key); + if ((c >= 0) && (c < KEYMAP_SIZE)) { + /* Remapping of key actions is supported only for basic + * lynxkeycodes, without modifiers etc.! If we get somehow + * called for an invalid lynxkeycode, fail or silently ignore + * modifiers -KW + */ + if (!(c & (LKC_ISLECLAC | LKC_ISLAC))) { + c &= LKC_MASK; + if ((mp = LYStringToKcmd(func)) != 0) { #if defined(DIRED_SUPPORT) && defined(OK_OVERRIDE) - if (for_dired) - key_override[c + 1] = mp->code; - else + if (for_dired) + key_override[c + 1] = mp->code; + else #endif - keymap[c + 1] = (LYKeymap_t) mp->code; - return (c ? c : (int) LAC_TO_LKC0(mp->code)); /* don't return 0, successful */ + keymap[c + 1] = (LYKeymap_t) mp->code; + /* don't return 0, successful */ + result = (c ? c : (int) LAC_TO_LKC0(mp->code)); + } + } + } } - return 0; + return result; } typedef struct { @@ -1529,6 +1527,7 @@ static void initKeyMap(LYEditConfig * table) */ void LYinitKeymap(void) { + CTRACE((tfp, "LYinitKeymap\n")); initKeyMap(&myKeymapData); #if defined(DIRED_SUPPORT) && defined(OK_OVERRIDE) initKeyMap(&myOverrideData); diff --git a/src/LYStrings.c b/src/LYStrings.c index 491d2079..64418ab2 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -1,4 +1,4 @@ -/* $LynxId: LYStrings.c,v 1.258 2013/11/28 11:57:39 tom Exp $ */ +/* $LynxId: LYStrings.c,v 1.260 2014/12/09 01:49:18 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <UCAux.h> @@ -1188,7 +1188,7 @@ static Keysym_String_List *lookupKeysymByName(const char *name) return result; } -int map_string_to_keysym(const char *str, int *keysym) +int map_string_to_keysym(const char *str, int *keysym, int internal) { int modifier = 0; @@ -1259,7 +1259,9 @@ int map_string_to_keysym(const char *str, int *keysym) Keysym_String_List *k = lookupKeysymByName(str); if (k != 0) { - *keysym = k->value; + *keysym = (internal + ? k->internal + : k->value); } } @@ -1347,7 +1349,7 @@ static int setkey_cmd(char *parse) } if (t != s) *t = '\0'; - if (map_string_to_keysym(s, &keysym) >= 0) { + if (map_string_to_keysym(s, &keysym, FALSE) >= 0) { if (!unescape_string(parse, buf, buf + sizeof(buf) - 1)) { MY_TRACE((tfp, "KEYMAP(SKIP) could unescape key\n")); return 0; /* Trace the failure and continue. */ @@ -1386,7 +1388,7 @@ static int unsetkey_cmd(char *parse) { int keysym; - if (map_string_to_keysym(parse, &keysym) >= 0) + if (map_string_to_keysym(parse, &keysym, FALSE) >= 0) define_key((char *) 0, keysym); } #endif @@ -1432,6 +1434,7 @@ static int read_keymap_file(void) if ((fp = fopen(file, "r")) == 0) return 0; + CTRACE((tfp, "read_keymap_file %s\n", file)); linenum = 0; while (LYSafeGets(&line, fp) != 0) { char *s = LYSkipBlanks(line); diff --git a/src/LYStrings.h b/src/LYStrings.h index 0e6519ea..6f368a48 100644 --- a/src/LYStrings.h +++ b/src/LYStrings.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYStrings.h,v 1.113 2013/10/20 20:33:23 tom Exp $ + * $LynxId: LYStrings.h,v 1.114 2014/12/09 01:49:51 tom Exp $ */ #ifndef LYSTRINGS_H #define LYSTRINGS_H @@ -324,7 +324,7 @@ extern "C" { #if defined(USE_KEYMAPS) extern int lynx_initialize_keymaps(void); - extern int map_string_to_keysym(const char *src, int *lec); + extern int map_string_to_keysym(const char *src, int *lec, int internal); #endif extern BOOL LYRemapEditBinding(int xlkc, int lec, int select_edi); /* in LYEditmap.c */ |