From f97a392c0128cd68afa739eba0a5c4e58c05c9b3 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 12 Aug 2006 15:07:07 +0300 Subject: [PATCH] try_mark_key: Reject non-ASCII keys as mark characters. The previous version used only the low 8 bits of the key code. This one arranges for the whole key to be rejected if it's not ASCII. Perhaps the modifiers should be checked too, but I'm not changing that now. --- src/viewer/text/view.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 6ab45a4e..14a28783 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -637,7 +637,19 @@ enum frame_event_status try_mark_key(struct session *ses, struct document_view *doc_view, struct term_event *ev) { - unsigned char mark = get_kbd_key(ev); + unsigned char mark; + + /* set_mark and goto_mark allow only a subset of the ASCII + * character repertoire as mark characters. If get_kbd_key(ev) + * is something else (i.e. a special key or a non-ASCII + * character), map it to an ASCII character that the functions + * will not accept, so the results are consistent. + * When CONFIG_UTF_8 is not defined, this assumes that codes + * 0 to 0x7F in all codepages match ASCII. */ + if (get_kbd_key(ev) >= 0 && get_kbd_key(ev) <= 0x7F) + mark = get_kbd_key(ev); + else + mark = 0; switch (ses->kbdprefix.mark) { case KP_MARK_NOTHING: