2009-09-09 Eric Blake <ebb9@byu.net>
+ strndup: fix improper m4 caching
+ * m4/strndup.m4 (gl_FUNC_STRNDUP): Rework to avoid side effects
+ inside AC_CACHE_CHECK. Use REPLACE_STRNDUP, not HAVE_STRNDUP.
+ (gl_PREREQ_STRNDUP): Delete.
+ * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Update default.
+ * modules/string (Makefile.am): Substitute it.
+ * lib/string.in.h (strndup): Modernize prototype.
+
getcwd: port to mingw
* m4/getcwd.m4 (gl_FUNC_GETCWD): Mingw directories are very
different from the POSIX assumptions made throughout the getcwd
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
-# serial 8
+# serial 9
# Written by Paul Eggert.
HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
- HAVE_STRNDUP=1; AC_SUBST([HAVE_STRNDUP])
HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
+ REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
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])
-# strndup.m4 serial 16
+# strndup.m4 serial 17
dnl Copyright (C) 2002-2003, 2005-2009 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 Persuade glibc <string.h> to declare strndup().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
AC_CHECK_DECLS_ONCE([strndup])
+ AC_CHECK_FUNCS_ONCE([strndup])
if test $ac_cv_have_decl_strndup = no; then
HAVE_DECL_STRNDUP=0
fi
- # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
- AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup],
- [AC_RUN_IFELSE([
- AC_LANG_PROGRAM([[#include <string.h>
- #include <stdlib.h>]], [[
+ if test $ac_cv_func_strndup = yes; then
+ # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
+ AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup_works],
+ [AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([[#include <string.h>
+ #include <stdlib.h>]], [[
#ifndef HAVE_DECL_STRNDUP
extern char *strndup (const char *, size_t);
#endif
free (s);
s = strndup ("shorter string", 13);
return s[13] != '\0';]])],
- [gl_cv_func_strndup=yes],
- [gl_cv_func_strndup=no],
- [AC_CHECK_FUNC([strndup],
- [AC_EGREP_CPP([too risky], [
-#ifdef _AIX
- too risky
-#endif
- ],
- [gl_cv_func_strndup=no],
- [gl_cv_func_strndup=yes])],
- [gl_cv_func_strndup=no])])])
- if test $gl_cv_func_strndup = yes; then
- AC_DEFINE([HAVE_STRNDUP], [1],
- [Define if you have the strndup() function and it works.])
+ [gl_cv_func_strndup_works=yes],
+ [gl_cv_func_strndup_works=no],
+ [case $host_os in
+ aix*) gl_cv_func_strndup_works="guessing no";;
+ *) gl_cv_func_strndup_works="guessing yes";;
+ esac])])
+ case $gl_cv_func_strndup_works in
+ *no)
+ REPLACE_STRNDUP=1
+ AC_LIBOBJ([strndup])
+ ;;
+ esac
else
- HAVE_STRNDUP=0
AC_LIBOBJ([strndup])
- gl_PREREQ_STRNDUP
fi
])
-
-# Prerequisites of lib/strndup.c.
-AC_DEFUN([gl_PREREQ_STRNDUP], [:])
-e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
-e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
-e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
- -e 's|@''HAVE_STRNDUP''@|$(HAVE_STRNDUP)|g' \
-e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
-e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
-e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
-e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
-e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
-e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
+ -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|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' \