Mercurial > hg > octave-nkf > gnulib-hg
changeset 13194:5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 10 Apr 2010 11:29:14 +0200 |
parents | d655bd302ece |
children | 563239444f8f |
files | ChangeLog lib/string.in.h m4/string_h.m4 m4/strnlen.m4 modules/string |
diffstat | 5 files changed, 31 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-04-10 Bruno Haible <bruno@clisp.org> + + 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 <config.h>. + * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Initialize + REPLACE_STRNLEN. + * modules/string (Makefile.am): Substitute REPLACE_STRNLEN. + Reported by Jarno Rajahalme <jarno.rajahalme@nsn.com>. + 2010-04-08 James Youngman <jay@gnu.org> * doc/manywarnings.texi (manywarnings): Add missing parenthesis in
--- a/lib/string.in.h +++ b/lib/string.in.h @@ -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
--- 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 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])
--- a/m4/strnlen.m4 +++ b/m4/strnlen.m4 @@ -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 <string.h> 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 ])
--- a/modules/string +++ b/modules/string @@ -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' \