nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 281197895f65e84147d233db204c002724eb0be9
parent d50e8feed937cf4516c293a5260920f1e3d5e357
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed,  7 May 2025 09:18:23 +0200

bindings: lowercase an ASCII character in a locale-proof manner

Calling tolower() on the 'I' (of "M-I") in a Turkish locale will not
return 'i' but 'I' instead.  This is because the lowercase of 'I' is
'ı' (a dotless i), which does not fit in an 8-bit character type, so
tolower() will return the 'I' unchanged.

This fixes https://savannah.gnu.org/bugs/?67092.

Buglet existed since before version 2.2.0.

Diffstat:
Msrc/global.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/global.c b/src/global.c @@ -371,8 +371,12 @@ int keycode_from_string(const char *keystring) else return -1; } else if (keystring[0] == 'M') { - if (keystring[1] == '-' && keystring[3] == '\0') - return tolower((unsigned char)keystring[2]); + if (keystring[1] == '-' && keystring[3] == '\0') { + if ('A' <= keystring[2] && keystring[2] <= 'Z') + return (keystring[2] | 0x20); + else + return keystring[2]; + } if (strcasecmp(keystring, "M-Space") == 0) return (int)' '; else