Jim Meyering wrote: > > The above makes me think your tools have incomplete "weak_alias" support, > > so that lib/strndup.o ends up with a definition for a function > > named __strndup, rather than rpl_strndup.
Huh? 'weak_alias' should never be defined, except inside glibc (i.e. if _LIBC). > No one signed off, but it works everywhere I've tested, > so I've checked it in. Your patch looks good. I'm checking in further simplifications; avoiding the use of an identifier starting with __, and added comments. 2006-09-28 Bruno Haible <[EMAIL PROTECTED]> * m4/strndup.m4 (gl_FUNC_STRNDUP): Don't define __STRNDUP_PREFIX. * lib/strndup.h: Simplify the redefinition of strndup. (_GL_CONCAT, _GL_XCONCAT, __STRNDUP_ID): Remove macros. diff -c -3 -r1.11 strndup.m4 *** m4/strndup.m4 28 Sep 2006 11:16:05 -0000 1.11 --- m4/strndup.m4 28 Sep 2006 20:44:51 -0000 *************** *** 1,4 **** ! # strndup.m4 serial 10 dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # strndup.m4 serial 11 dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 39,46 **** AC_DEFINE([HAVE_STRNDUP], 1, [Define if you have the strndup() function and it works.]) else - AC_DEFINE([__STRNDUP_PREFIX], [[rpl_]], - [Define to rpl_ if the strndup replacement function should be used.]) AC_LIBOBJ([strndup]) gl_PREREQ_STRNDUP fi --- 39,44 ---- diff -c -3 -r1.3 strndup.h *** lib/strndup.h 28 Sep 2006 11:16:05 -0000 1.3 --- lib/strndup.h 28 Sep 2006 20:44:51 -0000 *************** *** 15,30 **** along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ ! #include <string.h> #include <stddef.h> ! #ifdef __STRNDUP_PREFIX ! # define _GL_CONCAT(x, y) x ## y ! # define _GL_XCONCAT(x, y) _GL_CONCAT (x, y) ! # define __STRNDUP_ID(y) _GL_XCONCAT (__STRNDUP_PREFIX, y) # undef strndup ! # define strndup __STRNDUP_ID (strndup) ! # if !HAVE_DECL_STRNDUP /* Return a newly allocated copy of at most N bytes of STRING. */ extern char *strndup (const char *string, size_t n); # endif --- 15,31 ---- along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ ! /* Get size_t. */ #include <stddef.h> + /* If HAVE_STRNDUP, get the strndup declaration. + If !HAVE_STRNDUP, include <string.h> now so that it doesn't cause + trouble if included later. */ + #include <string.h> ! #if !HAVE_STRNDUP # undef strndup ! # define strndup rpl_strndup ! # if !HAVE_DECL_STRNDUP /* Don't risk conflicting declarations. */ /* Return a newly allocated copy of at most N bytes of STRING. */ extern char *strndup (const char *string, size_t n); # endif