commit debb288115ed22897c31eb78a1d5326647773678
parent c75a3839da987a43030db745cf897bb96376df82
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 7 Apr 2021 17:21:25 +0200
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.
Diffstat:
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/definitions.h b/src/definitions.h
@@ -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
diff --git a/src/nano.c b/src/nano.c
@@ -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);