The macro _GL_LARGE_CHAR32_T is a bit of a misnomer. While the type
char32_t is standardized and the same on all platforms, it's the
wchar_t type which is too small for a Unicode character on some
platforms. Therefore, I'm renaming this macro.


2023-04-04  Bruno Haible  <br...@clisp.org>

        uchar: Rename _GL_LARGE_CHAR32_T to _GL_SMALL_WCHAR_T.
        * lib/uchar.in.h (_GL_SMALL_WCHAR_T): Renamed from _GL_LARGE_CHAR32_T.
        * lib/mbrtoc32.c: Update.
        * lib/mbsrtoc32s.c: Update.
        * lib/mbsnrtoc32s.c: Update.
        * lib/c32tob.c: Update.
        * lib/c32rtomb.c: Update.
        * lib/c32srtombs.c: Update.
        * lib/c32snrtombs.c: Update.
        * lib/c32is-impl.h: Update.
        * tests/test-uchar.c: Update.

diff --git a/lib/c32is-impl.h b/lib/c32is-impl.h
index dba00b51ae..13a7dff58c 100644
--- a/lib/c32is-impl.h
+++ b/lib/c32is-impl.h
@@ -74,7 +74,7 @@ FUNC (wint_t wc)
     return 0;
 # endif
 
-#elif _GL_LARGE_CHAR32_T                /* Cygwin, mingw, MSVC */
+#elif _GL_SMALL_WCHAR_T                 /* Cygwin, mingw, MSVC */
   /* The wchar_t encoding is UTF-16.
      The char32_t encoding is UCS-4.  */
 
diff --git a/lib/c32rtomb.c b/lib/c32rtomb.c
index eb312f49f7..298c6be235 100644
--- a/lib/c32rtomb.c
+++ b/lib/c32rtomb.c
@@ -42,7 +42,7 @@ c32rtomb (char *s, char32_t wc, mbstate_t *ps)
 
   return c32rtomb (s, wc, ps);
 
-#elif _GL_LARGE_CHAR32_T
+#elif _GL_SMALL_WCHAR_T
 
   if (s == NULL)
     return wcrtomb (NULL, 0, ps);
diff --git a/lib/c32snrtombs.c b/lib/c32snrtombs.c
index 7988be4ae4..644e171afe 100644
--- a/lib/c32snrtombs.c
+++ b/lib/c32snrtombs.c
@@ -23,7 +23,7 @@
 
 #include <wchar.h>
 
-#if (HAVE_WORKING_MBRTOC32 && !defined __GLIBC__) || _GL_LARGE_CHAR32_T
+#if (HAVE_WORKING_MBRTOC32 && !defined __GLIBC__) || _GL_SMALL_WCHAR_T
 /* The char32_t encoding of a multibyte character may be different than its
    wchar_t encoding, or char32_t is wider than wchar_t.  */
 
diff --git a/lib/c32srtombs.c b/lib/c32srtombs.c
index 9152e75057..093d151483 100644
--- a/lib/c32srtombs.c
+++ b/lib/c32srtombs.c
@@ -23,7 +23,7 @@
 
 #include <wchar.h>
 
-#if (HAVE_WORKING_MBRTOC32 && !defined __GLIBC__) || _GL_LARGE_CHAR32_T
+#if (HAVE_WORKING_MBRTOC32 && !defined __GLIBC__) || _GL_SMALL_WCHAR_T
 /* The char32_t encoding of a multibyte character may be different than its
    wchar_t encoding, or char32_t is wider than wchar_t.  */
 
diff --git a/lib/c32tob.c b/lib/c32tob.c
index 2d7296463d..75c46c1dcd 100644
--- a/lib/c32tob.c
+++ b/lib/c32tob.c
@@ -41,7 +41,7 @@ c32tob (wint_t wc)
         return (unsigned char) buf[0];
     }
   return EOF;
-#elif _GL_LARGE_CHAR32_T
+#elif _GL_SMALL_WCHAR_T
   /* In all known encodings, unibyte characters correspond only to
      characters in the BMP.  */
   if (wc != WEOF && (wchar_t) wc == wc)
diff --git a/lib/mbrtoc32.c b/lib/mbrtoc32.c
index 6c711678ce..bd90132086 100644
--- a/lib/mbrtoc32.c
+++ b/lib/mbrtoc32.c
@@ -94,7 +94,7 @@ mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t 
*ps)
       n = 1;
     }
 
-# if MBRTOC32_EMPTY_INPUT_BUG || _GL_LARGE_CHAR32_T
+# if MBRTOC32_EMPTY_INPUT_BUG || _GL_SMALL_WCHAR_T
   if (n == 0)
     return (size_t) -2;
 # endif
@@ -126,7 +126,7 @@ mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t 
*ps)
 
   return ret;
 
-# elif _GL_LARGE_CHAR32_T
+# elif _GL_SMALL_WCHAR_T
 
   /* Special-case all encodings that may produce wide character values
      > WCHAR_MAX.  */
diff --git a/lib/mbsnrtoc32s.c b/lib/mbsnrtoc32s.c
index f2e2248f66..81125fdc54 100644
--- a/lib/mbsnrtoc32s.c
+++ b/lib/mbsnrtoc32s.c
@@ -22,7 +22,7 @@
 
 #include <wchar.h>
 
-#if (HAVE_WORKING_MBRTOC32 && !defined __GLIBC__) || _GL_LARGE_CHAR32_T
+#if (HAVE_WORKING_MBRTOC32 && !defined __GLIBC__) || _GL_SMALL_WCHAR_T
 /* The char32_t encoding of a multibyte character may be different than its
    wchar_t encoding, or char32_t is wider than wchar_t.  */
 
diff --git a/lib/mbsrtoc32s.c b/lib/mbsrtoc32s.c
index a400b5851a..b5f2523990 100644
--- a/lib/mbsrtoc32s.c
+++ b/lib/mbsrtoc32s.c
@@ -22,7 +22,7 @@
 
 #include <wchar.h>
 
-#if (HAVE_WORKING_MBRTOC32 && !defined __GLIBC__) || _GL_LARGE_CHAR32_T
+#if (HAVE_WORKING_MBRTOC32 && !defined __GLIBC__) || _GL_SMALL_WCHAR_T
 /* The char32_t encoding of a multibyte character may be different than its
    wchar_t encoding, or char32_t is wider than wchar_t.  */
 
diff --git a/lib/uchar.in.h b/lib/uchar.in.h
index 4d5f07fcce..adf9c551eb 100644
--- a/lib/uchar.in.h
+++ b/lib/uchar.in.h
@@ -104,7 +104,7 @@ typedef uint_least32_t gl_char32_t;
 
 /* Define if a 'char32_t' can hold more characters than a 'wchar_t'.  */
 #if @SMALL_WCHAR_T@                    /* 32-bit AIX, Cygwin, native Windows */
-# define _GL_LARGE_CHAR32_T 1
+# define _GL_SMALL_WCHAR_T 1
 #endif
 
 
diff --git a/tests/test-uchar.c b/tests/test-uchar.c
index 38c5f2538e..df6a3ea0d0 100644
--- a/tests/test-uchar.c
+++ b/tests/test-uchar.c
@@ -43,11 +43,11 @@ static_assert ((char16_t)0xFFFF != (char16_t)0x7FFF);
 /* Check that char32_t is at least 31 bits wide.  */
 static_assert ((char32_t)0x7FFFFFFF != (char32_t)0x3FFFFFFF);
 
-/* Check that _GL_LARGE_CHAR32_T is correctly defined.  */
-#if _GL_LARGE_CHAR32_T
-static_assert (sizeof (char32_t) > sizeof (wchar_t));
+/* Check that _GL_SMALL_WCHAR_T is correctly defined.  */
+#if _GL_SMALL_WCHAR_T
+static_assert (sizeof (wchar_t) < sizeof (char32_t));
 #else
-static_assert (sizeof (char32_t) == sizeof (wchar_t));
+static_assert (sizeof (wchar_t) == sizeof (char32_t));
 #endif
 
 int




Reply via email to