]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
wchar-h: <string.h> namespace cleanup
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 23 Apr 2026 19:59:52 +0000 (12:59 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 23 Apr 2026 20:00:31 +0000 (13:00 -0700)
Do not pollute <wchar.h> includers with <string.h> names
on GCC-compatible platforms.
* lib/wchar.in.h (_GL_WCHAR_MEMSET) [@GNULIB_MBSZERO@]: New macro.
(mbszero): Use it.

ChangeLog
lib/wchar.in.h

index cbadb6f6879870a47c42016a5df12c5b2254a2e3..3d5eeade61f15b80f505d481ef9c4565a0d35e42 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-04-23  Paul Eggert  <eggert@cs.ucla.edu>
+
+       wchar-h: <string.h> namespace cleanup
+       Do not pollute <wchar.h> includers with <string.h> names
+       on GCC-compatible platforms.
+       * lib/wchar.in.h (_GL_WCHAR_MEMSET) [@GNULIB_MBSZERO@]: New macro.
+       (mbszero): Use it.
+
 2026-04-19  Jim Meyering  <meyering@fb.com>
 
        maint.mk: fix sc_Wundef_boolean race with parallel syntax-check
index a60a4dfc67e32eab784f1af97fb408881bd53a20..29ecd92f5c0de2af95c7b6ab88a2df82e522a865 100644 (file)
@@ -258,8 +258,15 @@ _GL_EXTERN_C void free (void *);
 
 
 #if @GNULIB_MBSZERO@
-/* Get memset().  */
-# include <string.h>
+# ifdef __has_builtin
+#  if __has_builtin (__builtin_memset)
+#   define _GL_WCHAR_MEMSET __builtin_memset
+#  endif
+# endif
+# ifndef _GL_WCHAR_MEMSET
+#  include <string.h>
+#  define _GL_WCHAR_MEMSET memset
+# endif
 #endif
 
 
@@ -587,7 +594,7 @@ _GL_INLINE
 _GL_ARG_NONNULL ((1)) void
 mbszero (mbstate_t *ps)
 {
-  memset (ps, 0, _GL_MBSTATE_ZERO_SIZE);
+  _GL_WCHAR_MEMSET (ps, 0, _GL_MBSTATE_ZERO_SIZE);
 }
 #  define GNULIB_defined_mbszero 1
 # endif