nano

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

commit 48643cbdf3b92d779f7436f119e73de63e9d6db7
parent aa013aa007fb8fdd0fb07ffa29610efb0581abad
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Tue, 28 Feb 2017 15:05:02 +0100

tweaks: elide a small intermediate buffer

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

diff --git a/src/winio.c b/src/winio.c @@ -1500,7 +1500,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count) * Unicode value, and put back the corresponding byte(s). */ else { char *uni_mb; - int *seq, i; + int onebyte, i; while (uni == ERR) { free(kbinput); @@ -1512,15 +1512,12 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count) /* Convert the Unicode value to a multibyte sequence. */ uni_mb = make_mbchar(uni, (int *)count); - seq = (int *)nmalloc(*count * sizeof(int)); - - for (i = 0; i < *count; i++) - seq[i] = (unsigned char)uni_mb[i]; - /* Insert the multibyte sequence into the input buffer. */ - unget_input(seq, *count); + for (i = *count; i > 0 ; i--) { + onebyte = (unsigned char)uni_mb[i - 1]; + unget_input(&onebyte, 1); + } - free(seq); free(uni_mb); } } else