nano

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

commit c57d040e999a91cdf5d799ccf84aa6777a26777f
parent 0adb15c7a1beb325a6a14a9d23f4b955f6b7ceb7
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue, 11 Jun 2019 19:21:47 +0200

tweaks: don't bother calling mblen() in a non-UTF-8 build

There is no need, because in non-UTF-8 encodings nano treats
each single byte as one character anyway.

Diffstat:
Msrc/chars.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/chars.c b/src/chars.c @@ -253,12 +253,14 @@ char *make_mbchar(long chr, int *chr_mb_len) /* Return the length (in bytes) of the character located at *pointer. */ int char_length(const char *pointer) { +#ifdef ENABLE_UTF8 /* If possibly a multibyte character, get its length; otherwise, it's 1. */ if ((signed char)*pointer < 0) { int length = mblen(pointer, MAXCHARLEN); - return (length > 0 ? length : 1); + return (length < 0 ? 1 : length); } else +#endif return 1; } @@ -491,11 +493,13 @@ size_t mbstrlen(const char *pointer) size_t count = 0; while (*pointer != '\0') { +#ifdef ENABLE_UTF8 if ((signed char)*pointer < 0) { int length = mblen(pointer, MAXCHARLEN); pointer += (length < 0 ? 1 : length); } else +#endif pointer++; count++;