nano

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

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

tweaks: use knowledge of Unicode to skip the general multibyte conversion

The relevant range is so small (128 bytes) that "manual" conversion
is much faster (and a bit shorter, eliding two variables).

Diffstat:
Msrc/winio.c | 19+++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/winio.c b/src/winio.c @@ -995,21 +995,20 @@ int parse_kbinput(WINDOW *win) return ERR; #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 two bytes into the input buffer. */ - put_back((unsigned char)multibyte[1]); - put_back((unsigned char)multibyte[0]); - - free(multibyte); + /* Convert the code to the corresponding Unicode. */ + if (byte < 0xC0) { + put_back((unsigned char)byte); + put_back(0xC2); + } else { + put_back((unsigned char)(byte - 0x40)); + put_back(0xC3); + } escapes = 0; } #endif else { + retval = byte; escapes = 0; - return byte; } } else { if (digit_count > 0)