mirror of
https://https.git.savannah.gnu.org/git/nano.git
synced 2026-01-26 16:09:15 +00:00
tweaks: avoid using toupper() and tolower() where easily possible
Those functions can misbehave for some characters in certain locales.
This commit is contained in:
parent
8e104117a4
commit
d50e8feed9
@ -756,10 +756,11 @@ void parse_binding(char *ptr, bool dobind)
|
||||
keycopy = copy_of(keyptr);
|
||||
|
||||
/* Uppercase either the second or the first character of the key name. */
|
||||
if (keycopy[0] == '^')
|
||||
keycopy[1] = toupper((unsigned char)keycopy[1]);
|
||||
else
|
||||
keycopy[0] = toupper((unsigned char)keycopy[0]);
|
||||
if (keycopy[0] == '^') {
|
||||
if ('a' <= keycopy[1] && keycopy[1] <= 'z')
|
||||
keycopy[1] &= 0x5F;
|
||||
} else if ('a' <= keycopy[0] && keycopy[0] <= 'z')
|
||||
keycopy[0] &= 0x5F;
|
||||
|
||||
/* Verify that the key name is not too short. */
|
||||
if (keycopy[1] == '\0' || (keycopy[0] == 'M' && keycopy[2] == '\0')) {
|
||||
|
||||
@ -1046,8 +1046,8 @@ int parse_kbinput(WINDOW *frame)
|
||||
meta_key = TRUE;
|
||||
} else if (waiting_codes == 0 || nextcodes[0] == ESC_CODE ||
|
||||
(keycode != 'O' && keycode != '[')) {
|
||||
if (!shifted_metas)
|
||||
keycode = tolower(keycode);
|
||||
if ('A' <= keycode && keycode <= 'Z' && !shifted_metas)
|
||||
keycode |= 0x20;
|
||||
meta_key = TRUE;
|
||||
} else
|
||||
keycode = parse_escape_sequence(keycode);
|
||||
@ -1105,8 +1105,8 @@ int parse_kbinput(WINDOW *frame)
|
||||
/* If the first escape arrived alone but not the second, then it
|
||||
* is a Meta keystroke; otherwise, it is an "Esc Esc control". */
|
||||
if (first_escape_was_alone && !last_escape_was_alone) {
|
||||
if (!shifted_metas)
|
||||
keycode = tolower(keycode);
|
||||
if ('A' <= keycode && keycode <= 'Z' && !shifted_metas)
|
||||
keycode |= 0x20;
|
||||
meta_key = TRUE;
|
||||
} else
|
||||
keycode = convert_to_control(keycode);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user