tweaks: reduce the maximum character length from six bytes to four

In UTF-8 valid multibyte characters are at most four bytes long,
and now that we no longer make use of mblen() and mbtowc() from
the underlying system, we won't get five- or six-byte sequences
mistakenly reported as valid (by glibc).  So it is always enough
to reserve space for just four bytes per character.
master
Benno Schulenberg 2021-04-07 17:21:25 +02:00
parent c75a3839da
commit debb288115
2 changed files with 2 additions and 8 deletions

View File

@ -111,9 +111,9 @@
#define REPLACING 1
#define INREGION 2
/* In UTF-8 a character is at most six bytes long. */
#ifdef ENABLE_UTF8
#define MAXCHARLEN 6
/* In UTF-8 a valid character is at most four bytes long. */
#define MAXCHARLEN 4
#else
#define MAXCHARLEN 1
#endif

View File

@ -1804,12 +1804,6 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
#endif
#if defined(ENABLE_UTF8) && !defined(NANO_TINY)
if (MB_CUR_MAX > MAXCHARLEN)
fprintf(stderr, "Unexpected large character size: %i bytes"
" -- please report a bug\n", (int)MB_CUR_MAX);
#endif
/* Set sensible defaults, different from what Pico does. */
SET(NO_WRAP);
SET(SMOOTH_SCROLL);