From: Bruno Haible Date: Mon, 17 Jul 2023 17:50:27 +0000 (+0200) Subject: mbchar: Reduce size of 'struct mbchar'. Part 2. X-Git-Tag: v1.0~1085 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=5881dc6bfdc17e08b59f4976df74a0093a728e27;p=gnulib.git mbchar: Reduce size of 'struct mbchar'. Part 2. * lib/mbchar.h (mb_setascii): Disable if the module 'mbfile' is not in use. (mb_copy): Update. --- diff --git a/ChangeLog b/ChangeLog index b6a3321d7a..1eea948669 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ * lib/mbchar.h (MBCHAR_BUF_SIZE): Set to 4. (struct mbchar): Disable member 'buf' if the module 'mbfile' is not in use. + (mb_setascii): Disable if the module 'mbfile' is not in use. + (mb_copy): Update. 2023-07-17 Bruno Haible diff --git a/lib/mbchar.h b/lib/mbchar.h index d1900b5a51..fd5b2ed4ec 100644 --- a/lib/mbchar.h +++ b/lib/mbchar.h @@ -107,6 +107,7 @@ mb_setascii (&mbc, sc) assigns the standard ASCII character sc to mbc. + (Only available if the 'mbfile' module is in use.) mb_copy (&destmbc, &srcmbc) copies srcmbc to destmbc. @@ -254,21 +255,25 @@ mb_width_aux (char32_t wc) /* Output. */ #define mb_putc(mbc, stream) fwrite ((mbc).ptr, 1, (mbc).bytes, (stream)) +#if defined GNULIB_MBFILE /* Assignment. */ -#define mb_setascii(mbc, sc) \ - ((mbc)->ptr = (mbc)->buf, (mbc)->bytes = 1, (mbc)->wc_valid = 1, \ - (mbc)->wc = (mbc)->buf[0] = (sc)) +# define mb_setascii(mbc, sc) \ + ((mbc)->ptr = (mbc)->buf, (mbc)->bytes = 1, (mbc)->wc_valid = 1, \ + (mbc)->wc = (mbc)->buf[0] = (sc)) +#endif /* Copying a character. */ MBCHAR_INLINE void mb_copy (mbchar_t *new_mbc, const mbchar_t *old_mbc) { +#if defined GNULIB_MBFILE if (old_mbc->ptr == &old_mbc->buf[0]) { memcpy (&new_mbc->buf[0], &old_mbc->buf[0], old_mbc->bytes); new_mbc->ptr = &new_mbc->buf[0]; } else +#endif new_mbc->ptr = old_mbc->ptr; new_mbc->bytes = old_mbc->bytes; if ((new_mbc->wc_valid = old_mbc->wc_valid))