Hi, Jeremy Huddleston recently reported a build failure of gettext on some not-yet-released FreeBSD based system, due to the gnulib stpncpy module. On that system, stpncpy is defined as a "complex macro", causing 1) the gl_FUNC_STPNCPY macro to think that stpncpy does not work, 2) the string.h replacement to redeclare it, leading to a build failure.
I'm committing this patch which will fix problem 2 and likely also fix problem 1. 2010-08-15 Bruno Haible <br...@clisp.org> stpncpy: Allow stpncpy to be defined as a macro. * m4/stpncpy.m4 (gl_FUNC_STPNCPY): Don't attempt to redeclare stpncpy if it's already correctly declared. * lib/string.in.h (stpncpy): Undefine before redefining. Reported by Jeremy Huddleston <jerem...@macports.org>. --- lib/string.in.h.orig Mon Aug 16 01:56:33 2010 +++ lib/string.in.h Mon Aug 16 01:56:10 2010 @@ -233,6 +233,7 @@ #if @GNULIB_STPNCPY@ # if @REPLACE_STPNCPY@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef stpncpy # define stpncpy rpl_stpncpy # endif _GL_FUNCDECL_RPL (stpncpy, char *, --- m4/stpncpy.m4.orig Mon Aug 16 01:56:33 2010 +++ m4/stpncpy.m4 Sun Aug 15 13:30:28 2010 @@ -1,4 +1,4 @@ -# stpncpy.m4 serial 11 +# stpncpy.m4 serial 12 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -25,6 +25,7 @@ dnl in AIX: dest + max(0,n-1) dnl Only the glibc return value is useful in practice. + AC_CHECK_DECLS_ONCE([stpncpy]) AC_CHECK_FUNCS_ONCE([stpncpy]) if test $ac_cv_func_stpncpy = yes; then AC_CACHE_CHECK([for working stpncpy], [gl_cv_func_stpncpy], [ @@ -32,7 +33,9 @@ #include <stdlib.h> #include <string.h> /* for strcpy */ /* The stpncpy prototype is missing in <string.h> on AIX 4. */ +#if !HAVE_DECL_STPNCPY extern char *stpncpy (char *dest, const char *src, size_t n); +#endif int main () { const char *src = "Hello"; char dest[10];