+2023-07-17 Bruno Haible <bruno@clisp.org>
+
+ mbchar: Reduce size of 'struct mbchar'.
+ * modules/mbfile (configure.ac): Define GNULIB_MBFILE as an indicator.
+ * lib/mbchar.h (MBCHAR_BUF_SIZE): Set to 4.
+ (struct mbchar): Disable member 'buf' if the module 'mbfile' is not in
+ use.
+
2023-07-17 Bruno Haible <bruno@clisp.org>
mbszero: Fix for Minix.
# define MBCHAR_INLINE _GL_INLINE
#endif
-#define MBCHAR_BUF_SIZE 24
+/* The longest multibyte characters, nowadays, are 4 bytes long.
+ Regardless of the values of MB_CUR_MAX and MB_LEN_MAX. */
+#define MBCHAR_BUF_SIZE 4
struct mbchar
{
size_t bytes; /* number of bytes of current character, > 0 */
bool wc_valid; /* true if wc is a valid 32-bit wide character */
char32_t wc; /* if wc_valid: the current character */
+#if defined GNULIB_MBFILE
char buf[MBCHAR_BUF_SIZE]; /* room for the bytes, used for file input only */
+#endif
};
/* EOF (not a real character) is represented with bytes = 0 and
configure.ac:
gl_MBFILE
+dnl Do not use gl_MODULE_INDICATOR([mbfile]) here: we don't want 'struct mbchar'
+dnl to have a different size in lib/ than in tests/.
+AC_DEFINE([GNULIB_MBFILE], [1],
+ [Define to 1 if the gnulib module 'mbfile' is in use.])
Makefile.am:
lib_SOURCES += mbfile.h mbfile.c