+2020-05-30 Bruno Haible <bruno@clisp.org>
+
+ wmempcpy: New module.
+ Reported by Paul Eggert in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00387.html>.
+ * lib/wchar.in.h (wmempcpy): New declaration.
+ * lib/wmempcpy.c: New file.
+ * m4/wmempcpy.m4: New file.
+ * m4/wchar_h.m4 (gl_WCHAR_H): Test whether wmempcpy is declared.
+ (gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WMEMPCPY, HAVE_WMEMPCPY.
+ * modules/wchar (Makefile.am): Substitute GNULIB_WMEMPCPY,
+ HAVE_WMEMPCPY.
+ * modules/wmempcpy: New file.
+ * tests/test-wchar-c++.cc: Check the signature of wmempcpy.
+ * doc/glibc-functions/wmempcpy.texi: Mention the new module.
+ * modules/mempcpy (Description): Fix typo.
+
2020-05-30 Bruno Haible <bruno@clisp.org>
crypto/gc-random: Fix list of crypto devices for NetBSD, OpenBSD.
@uref{https://www.kernel.org/doc/man-pages/online/pages/man3/wmempcpy.3.html,,man wmempcpy}.
@end itemize
-Gnulib module: ---
+Gnulib module: wmempcpy
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on many non-glibc platforms:
+Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin, mingw, MSVC 14, Android 5.1.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
-This function is missing on many non-glibc platforms:
-Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin, mingw, MSVC 14, Android 5.1.
-@item
On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
accommodate all Unicode characters.
@end itemize
#endif
+/* Copy N wide characters of SRC to DEST.
+ Return pointer to wide characters after the last written wide character. */
+#if @GNULIB_WMEMPCPY@
+# if !@HAVE_WMEMPCPY@
+_GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
+ (wchar_t *restrict dest,
+ const wchar_t *restrict src, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
+ (wchar_t *restrict dest,
+ const wchar_t *restrict src, size_t n));
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (wmempcpy);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef wmempcpy
+# if HAVE_RAW_DECL_WMEMPCPY
+_GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
+ "use gnulib module wmempcpy for portability");
+# endif
+#endif
+
+
/* Set N wide characters of S to C. */
#if @GNULIB_WMEMSET@
# if !@HAVE_WMEMSET@
--- /dev/null
+/* Copy wide character array, return pointer after last written wide character.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <wchar.h>
+
+/* Copy N wide characters of SRC to DEST.
+ Return pointer to wide characters after the last written wide character. */
+wchar_t *
+wmempcpy (wchar_t *dest, const wchar_t *src, size_t n)
+{
+ return wmemcpy (dest, src, n) + n;
+}
dnl Written by Eric Blake.
-# wchar_h.m4 serial 45
+# wchar_h.m4 serial 46
AC_DEFUN([gl_WCHAR_H],
[
#include <wchar.h>
]],
[btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb
- wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset
+ wcsrtombs wcsnrtombs wcwidth
+ wmemchr wmemcmp wmemcpy wmemmove wmempcpy wmemset
wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp
wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr
wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth wcsftime
GNULIB_WMEMCMP=0; AC_SUBST([GNULIB_WMEMCMP])
GNULIB_WMEMCPY=0; AC_SUBST([GNULIB_WMEMCPY])
GNULIB_WMEMMOVE=0; AC_SUBST([GNULIB_WMEMMOVE])
+ GNULIB_WMEMPCPY=0; AC_SUBST([GNULIB_WMEMPCPY])
GNULIB_WMEMSET=0; AC_SUBST([GNULIB_WMEMSET])
GNULIB_WCSLEN=0; AC_SUBST([GNULIB_WCSLEN])
GNULIB_WCSNLEN=0; AC_SUBST([GNULIB_WCSNLEN])
HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP])
HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY])
HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE])
+ HAVE_WMEMPCPY=1; AC_SUBST([HAVE_WMEMPCPY])
HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET])
HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN])
HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN])
--- /dev/null
+# wmempcpy.m4 serial 1
+dnl Copyright (C) 2020 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_WMEMPCPY],
+[
+ AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+ dnl Persuade glibc <wchar.h> to declare wmempcpy().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ dnl The wmempcpy() declaration in lib/wchar.in.h uses 'restrict'.
+ AC_REQUIRE([AC_C_RESTRICT])
+
+ AC_CHECK_FUNCS_ONCE([wmempcpy])
+ if test $ac_cv_func_wmempcpy = no; then
+ HAVE_WMEMPCPY=0
+ fi
+])
Description:
-mempcpy() function: copy memory area, return point after last written byte.
+mempcpy() function: copy memory area, return pointer after last written byte.
Files:
lib/mempcpy.c
-e 's/@''GNULIB_WMEMCMP''@/$(GNULIB_WMEMCMP)/g' \
-e 's/@''GNULIB_WMEMCPY''@/$(GNULIB_WMEMCPY)/g' \
-e 's/@''GNULIB_WMEMMOVE''@/$(GNULIB_WMEMMOVE)/g' \
+ -e 's/@''GNULIB_WMEMPCPY''@/$(GNULIB_WMEMPCPY)/g' \
-e 's/@''GNULIB_WMEMSET''@/$(GNULIB_WMEMSET)/g' \
-e 's/@''GNULIB_WCSLEN''@/$(GNULIB_WCSLEN)/g' \
-e 's/@''GNULIB_WCSNLEN''@/$(GNULIB_WCSNLEN)/g' \
-e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \
-e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \
-e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \
+ -e 's|@''HAVE_WMEMPCPY''@|$(HAVE_WMEMPCPY)|g' \
-e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \
-e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \
-e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \
--- /dev/null
+Description:
+wmempcpy() function: copy wide character array, return pointer after last written wide character.
+
+Files:
+lib/wmempcpy.c
+m4/wmempcpy.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WMEMPCPY
+if test $HAVE_WMEMPCPY = 0; then
+ AC_LIBOBJ([wmempcpy])
+fi
+gl_WCHAR_MODULE_INDICATOR([wmempcpy])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
(wchar_t *, const wchar_t *, size_t));
#endif
+#if GNULIB_TEST_WMEMPCPY
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wmempcpy, wchar_t *,
+ (wchar_t *, const wchar_t *, size_t));
+#endif
+
#if GNULIB_TEST_WMEMSET
SIGNATURE_CHECK (GNULIB_NAMESPACE::wmemset, wchar_t *,
(wchar_t *, wchar_t, size_t));