1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-09-01 02:34:55 +00:00

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.
This commit is contained in:
Bruno Haible
2023-07-17 19:11:38 +02:00
parent d261ea8b19
commit 49d66352f7
3 changed files with 17 additions and 1 deletions
+8
View File
@@ -1,3 +1,11 @@
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.
+5 -1
View File
@@ -156,7 +156,9 @@ _GL_INLINE_HEADER_BEGIN
# 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
{
@@ -164,7 +166,9 @@ 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
+4
View File
@@ -18,6 +18,10 @@ stdbool
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