>From b6b037e627692b276e22f6c3ca6eabedcc535f70 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 22 Jan 2023 11:51:46 +0100 Subject: [PATCH 18/47] Resolve conflicts for functions introduced in Android API level 21. * lib/string.in.h (stpcpy): Consider REPLACE_STPCPY. Disable _GL_CXXALIASWARN invocation on non-glibc systems. * m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_STPCPY. * modules/string (Makefile.am): Substitute REPLACE_STPCPY. * m4/stpcpy.m4 (gl_FUNC_STPCPY): Conditionally set REPLACE_STPCPY. * modules/stpcpy (configure.ac): Consider REPLACE_STPCPY. --- ChangeLog | 7 +++++++ lib/string.in.h | 18 ++++++++++++++++-- m4/stpcpy.m4 | 5 ++++- m4/string_h.m4 | 3 ++- modules/stpcpy | 3 ++- modules/string | 1 + 6 files changed, 32 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80063baa0f..1cf4f77554 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ Resolve conflicts for functions introduced in Android API level 21. + * lib/string.in.h (stpcpy): Consider REPLACE_STPCPY. Disable + _GL_CXXALIASWARN invocation on non-glibc systems. + * m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_STPCPY. + * modules/string (Makefile.am): Substitute REPLACE_STPCPY. + * m4/stpcpy.m4 (gl_FUNC_STPCPY): Conditionally set REPLACE_STPCPY. + * modules/stpcpy (configure.ac): Consider REPLACE_STPCPY. + * lib/stdlib.in.h (_Exit): Consider REPLACE__EXIT. Disable _GL_CXXALIASWARN invocation on non-glibc systems. (getprogname): Consider REPLACE_GETPROGNAME. Disable _GL_CXXALIASWARN diff --git a/lib/string.in.h b/lib/string.in.h index b227a17887..ffcc7e25c6 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -406,14 +406,28 @@ _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ #if @GNULIB_STPCPY@ -# if ! @HAVE_STPCPY@ +# if @REPLACE_STPCPY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef stpcpy +# define stpcpy rpl_stpcpy +# endif +_GL_FUNCDECL_RPL (stpcpy, char *, + (char *restrict __dst, char const *restrict __src) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (stpcpy, char *, + (char *restrict __dst, char const *restrict __src)); +# else +# if !@HAVE_STPCPY@ _GL_FUNCDECL_SYS (stpcpy, char *, (char *restrict __dst, char const *restrict __src) _GL_ARG_NONNULL ((1, 2))); -# endif +# endif _GL_CXXALIAS_SYS (stpcpy, char *, (char *restrict __dst, char const *restrict __src)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (stpcpy); +# endif #elif defined GNULIB_POSIXCHECK # undef stpcpy # if HAVE_RAW_DECL_STPCPY diff --git a/m4/stpcpy.m4 b/m4/stpcpy.m4 index 462f511d25..f3acbee7be 100644 --- a/m4/stpcpy.m4 +++ b/m4/stpcpy.m4 @@ -1,4 +1,4 @@ -# stpcpy.m4 serial 10 +# stpcpy.m4 serial 11 dnl Copyright (C) 2002, 2007, 2009-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -16,6 +16,9 @@ AC_DEFUN([gl_FUNC_STPCPY], gl_CHECK_FUNCS_ANDROID([stpcpy], [[#include ]]) if test $ac_cv_func_stpcpy = no; then HAVE_STPCPY=0 + case "$gl_cv_onwards_func_stpcpy" in + future*) REPLACE_STPCPY=1 ;; + esac fi ]) diff --git a/m4/string_h.m4 b/m4/string_h.m4 index 5da3cc2529..132ed87d6a 100644 --- a/m4/string_h.m4 +++ b/m4/string_h.m4 @@ -5,7 +5,7 @@ # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 35 +# serial 36 # Written by Paul Eggert. @@ -131,6 +131,7 @@ AC_DEFUN([gl_STRING_H_DEFAULTS], REPLACE_FFSLL=0; AC_SUBST([REPLACE_FFSLL]) REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) + REPLACE_STPCPY=0; AC_SUBST([REPLACE_STPCPY]) REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY]) REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL]) REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) diff --git a/modules/stpcpy b/modules/stpcpy index a4aac236a2..66c481d691 100644 --- a/modules/stpcpy +++ b/modules/stpcpy @@ -11,7 +11,8 @@ string configure.ac: gl_FUNC_STPCPY -gl_CONDITIONAL([GL_COND_OBJ_STPCPY], [test $HAVE_STPCPY = 0]) +gl_CONDITIONAL([GL_COND_OBJ_STPCPY], + [test $HAVE_STPCPY = 0 || test $REPLACE_STPCPY = 1]) AM_COND_IF([GL_COND_OBJ_STPCPY], [ gl_PREREQ_STPCPY ]) diff --git a/modules/string b/modules/string index 70bf2b869f..03a1b0547c 100644 --- a/modules/string +++ b/modules/string @@ -109,6 +109,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \ + -e 's|@''REPLACE_STPCPY''@|$(REPLACE_STPCPY)|g' \ -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \ -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ -- 2.34.1