nano

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

commit e1199cd94d43b5f388b5f6cb8bbc91466bbd863b
parent 45d2458b470bd918ea9a38562deabd1d323776ea
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 10 Jan 2018 20:32:07 +0100

tweaks: elide a tiny intermediate buffer, and rename two variables

Use the same method as in parse_verbatim_kbinput() for Unicode input.

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

diff --git a/src/winio.c b/src/winio.c @@ -464,22 +464,19 @@ int parse_kbinput(WINDOW *win) /* If the decimal byte value is complete, convert it and * put the obtained byte(s) back into the input buffer. */ if (byte != ERR) { - char *byte_mb; - int byte_mb_len, *seq, i; + char *multibyte; + int count, onebyte, i; /* Convert the decimal code to one or two bytes. */ - byte_mb = make_mbchar((long)byte, &byte_mb_len); - - seq = (int *)nmalloc(byte_mb_len * sizeof(int)); - - for (i = 0; i < byte_mb_len; i++) - seq[i] = (unsigned char)byte_mb[i]; + multibyte = make_mbchar((long)byte, &count); /* Insert the byte(s) into the input buffer. */ - unget_input(seq, byte_mb_len); + for (i = count; i > 0 ; i--) { + onebyte = (unsigned char)multibyte[i - 1]; + unget_input(&onebyte, 1); + } - free(byte_mb); - free(seq); + free(multibyte); byte_digits = 0; escapes = 0;