# HG changeset patch # User Bruno Haible # Date 1270891754 -7200 # Node ID 5aec4f35399f4e7fb9ee9ad8025f70edb8b744ff # Parent d655bd302ece3e9e073ea089a6beffaf82a437f9 strnlen: Fix warning in C++ mode on MacOS X. diff -r d655bd302ece -r 5aec4f35399f ChangeLog --- a/ChangeLog Thu Apr 08 03:02:12 2010 +0100 +++ b/ChangeLog Sat Apr 10 11:29:14 2010 +0200 @@ -1,3 +1,14 @@ +2010-04-10 Bruno Haible + + strnlen: Fix warning in C++ mode on MacOS X. + * lib/string.in.h (strnlen): Use the modern idiom. + * m4/strnlen.m4 (gl_FUNC_STRNLEN): Set REPLACE_STRNLEN to 1, instead of + defining strnlen as a macro already in . + * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Initialize + REPLACE_STRNLEN. + * modules/string (Makefile.am): Substitute REPLACE_STRNLEN. + Reported by Jarno Rajahalme . + 2010-04-08 James Youngman * doc/manywarnings.texi (manywarnings): Add missing parenthesis in diff -r d655bd302ece -r 5aec4f35399f lib/string.in.h --- a/lib/string.in.h Thu Apr 08 03:02:12 2010 +0100 +++ b/lib/string.in.h Sat Apr 10 11:29:14 2010 +0200 @@ -372,12 +372,23 @@ MAXLEN bytes. If no '\0' terminator is found in that many bytes, return MAXLEN. */ #if @GNULIB_STRNLEN@ -# if ! @HAVE_DECL_STRNLEN@ +# if @REPLACE_STRNLEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strnlen +# define strnlen rpl_strnlen +# endif +_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) + __attribute__ ((__pure__)) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); +# else +# if ! @HAVE_DECL_STRNLEN@ _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); # endif -_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); _GL_CXXALIASWARN (strnlen); #elif defined GNULIB_POSIXCHECK # undef strnlen diff -r d655bd302ece -r 5aec4f35399f m4/string_h.m4 --- a/m4/string_h.m4 Thu Apr 08 03:02:12 2010 +0100 +++ b/m4/string_h.m4 Sat Apr 10 11:29:14 2010 +0200 @@ -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 16 +# serial 17 # Written by Paul Eggert. @@ -105,6 +105,7 @@ REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) + REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN]) REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) diff -r d655bd302ece -r 5aec4f35399f m4/strnlen.m4 --- a/m4/strnlen.m4 Thu Apr 08 03:02:12 2010 +0100 +++ b/m4/strnlen.m4 Sat Apr 10 11:29:14 2010 +0200 @@ -1,4 +1,4 @@ -# strnlen.m4 serial 10 +# strnlen.m4 serial 11 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -7,10 +7,11 @@ AC_DEFUN([gl_FUNC_STRNLEN], [ + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + dnl Persuade glibc to declare strnlen(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) AC_CHECK_DECLS_ONCE([strnlen]) if test $ac_cv_have_decl_strnlen = no; then HAVE_DECL_STRNLEN=0 @@ -18,12 +19,11 @@ AC_FUNC_STRNLEN if test $ac_cv_func_strnlen_working = no; then + REPLACE_STRNLEN=1 # This is necessary because automake-1.6.1 doesn't understand # that the above use of AC_FUNC_STRNLEN means we may have to use # lib/strnlen.c. #AC_LIBOBJ([strnlen]) - AC_DEFINE([strnlen], [rpl_strnlen], - [Define to rpl_strnlen if the replacement function should be used.]) gl_PREREQ_STRNLEN fi ]) diff -r d655bd302ece -r 5aec4f35399f modules/string --- a/modules/string Thu Apr 08 03:02:12 2010 +0100 +++ b/modules/string Sat Apr 10 11:29:14 2010 +0200 @@ -89,6 +89,7 @@ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ + -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \