[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AIX tests failures
Re: AIX tests failures
Sun, 28 May 2006 21:50:51 +0200
[ Cc:ing bug-gnulib ]
* Jim Meyering wrote on Sun, May 28, 2006 at 07:58:24PM CEST:
> Ralf Wildenhues <address@hidden> wrote:
> > ... AIX strndup is severely broken, at least on 4.3.3 and 5.1, similar
> > to its strnlen; see also. See for example this test:
> I have to confess that I wonder if it's worth trying to work around
> bugs in AIX 4. Is it still officially supported? Is it used by many?
> I haven't had access to such a system for a few years now, and no one
> has been building coreutils on any version of AIX, as far as I've heard.
> But since it affects 5.1, too, maybe it's worthwhile.
> Do you feel like writing a patch to coreutils/m4/strndup.m4
> that makes it perform a run-test for this bug?
Not sure if I have much motivation for fighting this into glibc, but
here you go. I'm unsure if conditionalizing away the #undef __strndup
is wrong for some system.
Tested on AIX 4.3.3, 5.1, 5.2 (first has strnlen and strndup broken,
second has strnlen fixed, last has both fixed) and with a linux->mingw
I only saw Paul's message after mostly finishing this one, so feel free
to decide as you like. (I don't know whether Gnulib intends to target
systems that are apparently not of interest to coreutils any more.)
* strndup.c: Undefine `strndup', `__strndup' only if LIBC.
* strndup.m4: Replace the AC_REPLACE_FUNCS with a check for
the declaration of strnlen and a run test that exposes the
AIX 5.1 strnlen bug. In the failure case, #define strndup
RCS file: /cvsroot/gnulib/gnulib/lib/strndup.c,v
retrieving revision 1.14
diff -u -r1.14 strndup.c
--- lib/strndup.c 24 Jan 2006 07:40:58 -0000 1.14
+++ lib/strndup.c 28 May 2006 19:22:22 -0000
@@ -33,11 +33,11 @@
# ifndef __strnlen
# define __strnlen strnlen
+# undef __strndup
+# undef strndup
# define __strndup strndup
RCS file: /cvsroot/gnulib/gnulib/m4/strndup.m4,v
retrieving revision 1.5
diff -u -r1.5 strndup.m4
--- m4/strndup.m4 11 Aug 2005 09:56:12 -0000 1.5
+++ m4/strndup.m4 28 May 2006 19:22:23 -0000
@@ -1,5 +1,5 @@
-# strndup.m4 serial 5
-dnl Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+# strndup.m4 serial 6
+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,
dnl with or without modifications, as long as this notice is preserved.
@@ -11,8 +11,26 @@
dnl Persuade glibc <string.h> to declare strndup().
- if test $ac_cv_func_strndup = no; then
+ # AIX 5.1 fails to add the terminating \0.
+ AC_CACHE_CHECK([for working strndup], gl_cv_func_strndup,
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
+ extern char *strndup (const char *, size_t);
+ char *s = strndup ("some longer string", 15);
+ free (s);
+ s = strndup ("shorter string", 13);
+ return s != '\0';]])],
+ test $gl_cv_func_strndup = no &&
+ if test $gl_cv_func_strndup = no; then
+ AC_DEFINE(strndup, rpl_strndup,
+ [Define to rpl_strndup if the replacement function should be used,])
- Re: AIX tests failures,
Ralf Wildenhues <=