]> Savannah Git Hosting - gnulib.git/commitdiff
mbchar: Reduce size of 'struct mbchar'. Part 2.
authorBruno Haible <bruno@clisp.org>
Mon, 17 Jul 2023 17:50:27 +0000 (19:50 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 17 Jul 2023 17:50:27 +0000 (19:50 +0200)
* lib/mbchar.h (mb_setascii): Disable if the module 'mbfile' is not in use.
(mb_copy): Update.

ChangeLog
lib/mbchar.h

index b6a3321d7a0f6509818218ed3975f9b6aaf9539d..1eea948669cb77bfa9e8769428cbc6d6babfc0ad 100644 (file)
--- 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  <bruno@clisp.org>
 
index d1900b5a5173d00d27b11d58659ef2fc5735cf5d..fd5b2ed4ec38d482d46b796b48772ee29aade757 100644 (file)
 
    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))