nano

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

commit 17a8b24fe50e58981ae9e89a10954d64c1c04d50
parent b9db967bc4e41a7cb3b38ddd09c6a681106325aa
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon, 20 Jul 2020 19:08:08 +0200

tweaks: skip the conversion to multibyte for plain ASCII codes

Converting an ASCII code to "multibyte" is a no-op: it stays one byte.

Diffstat:
Msrc/winio.c | 24+++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/winio.c b/src/winio.c @@ -993,22 +993,24 @@ int parse_kbinput(WINDOW *win) * obtained byte(s) back into the input buffer. */ if (byte == PROCEED) return ERR; - else { - int count, onebyte; - char *multibyte; - - /* Convert the decimal code to one or two bytes. */ - multibyte = make_mbchar((long)byte, &count); +#ifdef ENABLE_UTF8 + else if (byte > 0x7F && using_utf8()) { + int count; + /* Convert the decimal code to two bytes. */ + char *multibyte = make_mbchar((long)byte, &count); - /* Insert the byte(s) into the input buffer. */ - for (int i = count; i > 0 ; i--) { - onebyte = (unsigned char)multibyte[i - 1]; - put_back(onebyte); - } + /* Insert the two bytes into the input buffer. */ + put_back((unsigned char)multibyte[1]); + put_back((unsigned char)multibyte[0]); free(multibyte); escapes = 0; } +#endif + else { + escapes = 0; + return byte; + } } else { if (digit_count > 0) /* A non-digit in the middle of a byte sequence: