nano

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

commit 1d4411a474991a0910c29ba6a1b105ec08ad7b68
parent 76f1a4af4fead169fcbae7596f34aa87d617bbe2
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu, 20 Feb 2020 16:38:14 +0100

tweaks: elide a function call, by copying a byte directly

Now all remaining calls of measured_copy() have a "+ 1" in their
second argument, and can thus be simplified.  And each of those
calls is followed by terminating the string with a NUL byte, so
thát can be pulled into the function.

Diffstat:
Msrc/chars.c | 5++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/chars.c b/src/chars.c @@ -204,11 +204,10 @@ int mbwidth(const char *c) * allocated) multibyte character and a length of zero. */ char *make_mbchar(long code, int *length) { - char *mb_char; + char *mb_char = charalloc(MAXCHARLEN); #ifdef ENABLE_UTF8 if (use_utf8) { - mb_char = charalloc(MAXCHARLEN); *length = wctomb(mb_char, (wchar_t)code); /* Reject invalid Unicode characters. */ @@ -219,7 +218,7 @@ char *make_mbchar(long code, int *length) } else #endif { - mb_char = measured_copy((char *)&code, 1); + *mb_char = (char)code; *length = 1; }