* lib/wchar.in.h (wcsncat): Consider REPLACE_WCSNCAT.
* m4/wcsncat.m4 (gl_FUNC_WCSNCAT): Test whether the zero-length bug is
present.
* m4/wchar_h.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WCSNCAT.
* modules/wchar (Makefile.am): Substitute REPLACE_WCSNCAT.
* modules/wcsncat (Status, Notice): Remove.
(configure.ac): Consider REPLACE_WCSNCAT.
* doc/posix-functions/wcsncat.texi: Mention the zero-length bug.
+2024-11-05 Bruno Haible <bruno@clisp.org>
+
+ wcsncat: Guarantee N3322 functionality.
+ * lib/wchar.in.h (wcsncat): Consider REPLACE_WCSNCAT.
+ * m4/wcsncat.m4 (gl_FUNC_WCSNCAT): Test whether the zero-length bug is
+ present.
+ * m4/wchar_h.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WCSNCAT.
+ * modules/wchar (Makefile.am): Substitute REPLACE_WCSNCAT.
+ * modules/wcsncat (Status, Notice): Remove.
+ (configure.ac): Consider REPLACE_WCSNCAT.
+ * doc/posix-functions/wcsncat.texi: Mention the zero-length bug.
+
2024-11-05 Bruno Haible <bruno@clisp.org>
wmemmove tests: Verify N3322 functionality.
Portability problems fixed by Gnulib:
@itemize
+@item
+This function does not support zero-length operations on NULL pointers
+on some platforms:
+macOS 15, NetBSD 10.0, OpenBSD 7.6, Solaris 11.4, Cygwin 3.5.4.
@end itemize
Portability problems not fixed by Gnulib:
/* Append no more than N wide characters of SRC onto DEST. */
#if @GNULIB_WCSNCAT@
-# if !@HAVE_WCSNCAT@
+# if @REPLACE_WCSNCAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcsncat
+# define wcsncat rpl_wcsncat
+# endif
+_GL_FUNCDECL_RPL (wcsncat, wchar_t *,
+ (wchar_t *restrict dest, const wchar_t *restrict src,
+ size_t n), );
+_GL_CXXALIAS_RPL (wcsncat, wchar_t *,
+ (wchar_t *restrict dest, const wchar_t *restrict src,
+ size_t n));
+# else
+# if !@HAVE_WCSNCAT@
_GL_FUNCDECL_SYS (wcsncat, wchar_t *,
(wchar_t *restrict dest, const wchar_t *restrict src,
size_t n), );
-# endif
+# endif
_GL_CXXALIAS_SYS (wcsncat, wchar_t *,
(wchar_t *restrict dest, const wchar_t *restrict src,
size_t n));
+# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (wcsncat);
# endif
# wchar_h.m4
-# serial 64
+# serial 65
dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH])
REPLACE_WCSFTIME=0; AC_SUBST([REPLACE_WCSFTIME])
REPLACE_WCSCMP=0; AC_SUBST([REPLACE_WCSCMP])
+ REPLACE_WCSNCAT=0; AC_SUBST([REPLACE_WCSNCAT])
REPLACE_WCSNCMP=0; AC_SUBST([REPLACE_WCSNCMP])
REPLACE_WCSSTR=0; AC_SUBST([REPLACE_WCSSTR])
REPLACE_WCSTOK=0; AC_SUBST([REPLACE_WCSTOK])
# wcsncat.m4
-# serial 2
+# serial 3
dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_DEFUN([gl_FUNC_WCSNCAT],
[
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
AC_CHECK_FUNCS_ONCE([wcsncat])
- if test $ac_cv_func_wcsncat = no; then
+ if test $ac_cv_func_wcsncat = yes; then
+ AC_CACHE_CHECK([for working wcsncat], [gl_cv_func_wcsncat_works],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <wchar.h>
+ #include <stddef.h>
+ ]], [[
+ wchar_t y[1];
+ int volatile value = (wcsncat (y, NULL, 0) == y);
+ return !value;
+ ]])
+ ],
+ [gl_cv_func_wcsncat_works=yes],
+ [gl_cv_func_wcsncat_works=no],
+ [case "$host_os" in
+ # Guess no on macOS, NetBSD, OpenBSD, Solaris, Cygwin.
+ darwin* | netbsd* | openbsd* | solaris* | cygwin*)
+ gl_cv_func_wcsncat_works="guessing no" ;;
+ *)
+ gl_cv_func_strndup_works="guessing yes" ;;
+ esac
+ ])
+ ])
+ case "$gl_cv_func_wcsncat_works" in
+ *yes) ;;
+ *) REPLACE_WCSNCAT=1 ;;
+ esac
+ else
HAVE_WCSNCAT=0
fi
])
-e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
-e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \
-e 's|@''REPLACE_WCSCMP''@|$(REPLACE_WCSCMP)|g' \
+ -e 's|@''REPLACE_WCSNCAT''@|$(REPLACE_WCSNCAT)|g' \
-e 's|@''REPLACE_WCSNCMP''@|$(REPLACE_WCSNCMP)|g' \
-e 's|@''REPLACE_WCSSTR''@|$(REPLACE_WCSSTR)|g' \
-e 's|@''REPLACE_WCSTOK''@|$(REPLACE_WCSTOK)|g' \
Description:
wcsncat() function: append part of a wide string to a wide string.
-Status:
-obsolete
-
-Notice:
-This module is obsolete.
-
Files:
lib/wcsncat.c
lib/wcsncat-impl.h
configure.ac:
gl_FUNC_WCSNCAT
-gl_CONDITIONAL([GL_COND_OBJ_WCSNCAT], [test $HAVE_WCSNCAT = 0])
+gl_CONDITIONAL([GL_COND_OBJ_WCSNCAT],
+ [test $HAVE_WCSNCAT = 0 || test $REPLACE_WCSNCAT = 1])
gl_WCHAR_MODULE_INDICATOR([wcsncat])
Makefile.am: