summaryrefslogtreecommitdiffstats
path: root/gl/m4/strndup.m4
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-07 21:11:46 -0400
committerThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-12 21:26:35 -0400
commit74da141e618ef99959d509cb2e7be35a348a39db (patch)
tree88ebc38b381a1021fc2d74864a71e230ae591c3d /gl/m4/strndup.m4
parentc63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff)
downloadmonitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'gl/m4/strndup.m4')
-rw-r--r--gl/m4/strndup.m448
1 files changed, 22 insertions, 26 deletions
diff --git a/gl/m4/strndup.m4 b/gl/m4/strndup.m4
index 4fa7d5a7..810313cd 100644
--- a/gl/m4/strndup.m4
+++ b/gl/m4/strndup.m4
@@ -1,5 +1,5 @@
1# strndup.m4 serial 16 1# strndup.m4 serial 17
2dnl Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2005-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,17 +9,20 @@ AC_DEFUN([gl_FUNC_STRNDUP],
9 dnl Persuade glibc <string.h> to declare strndup(). 9 dnl Persuade glibc <string.h> to declare strndup().
10 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 10 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
11 11
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 13 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
13 AC_CHECK_DECLS_ONCE([strndup]) 14 AC_CHECK_DECLS_ONCE([strndup])
15 AC_CHECK_FUNCS_ONCE([strndup])
14 if test $ac_cv_have_decl_strndup = no; then 16 if test $ac_cv_have_decl_strndup = no; then
15 HAVE_DECL_STRNDUP=0 17 HAVE_DECL_STRNDUP=0
16 fi 18 fi
17 19
18 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'. 20 if test $ac_cv_func_strndup = yes; then
19 AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup], 21 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
20 [AC_RUN_IFELSE([ 22 AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup_works],
21 AC_LANG_PROGRAM([[#include <string.h> 23 [AC_RUN_IFELSE([
22 #include <stdlib.h>]], [[ 24 AC_LANG_PROGRAM([[#include <string.h>
25 #include <stdlib.h>]], [[
23#ifndef HAVE_DECL_STRNDUP 26#ifndef HAVE_DECL_STRNDUP
24 extern char *strndup (const char *, size_t); 27 extern char *strndup (const char *, size_t);
25#endif 28#endif
@@ -28,26 +31,19 @@ AC_DEFUN([gl_FUNC_STRNDUP],
28 free (s); 31 free (s);
29 s = strndup ("shorter string", 13); 32 s = strndup ("shorter string", 13);
30 return s[13] != '\0';]])], 33 return s[13] != '\0';]])],
31 [gl_cv_func_strndup=yes], 34 [gl_cv_func_strndup_works=yes],
32 [gl_cv_func_strndup=no], 35 [gl_cv_func_strndup_works=no],
33 [AC_CHECK_FUNC([strndup], 36 [case $host_os in
34 [AC_EGREP_CPP([too risky], [ 37 aix*) gl_cv_func_strndup_works="guessing no";;
35#ifdef _AIX 38 *) gl_cv_func_strndup_works="guessing yes";;
36 too risky 39 esac])])
37#endif 40 case $gl_cv_func_strndup_works in
38 ], 41 *no)
39 [gl_cv_func_strndup=no], 42 REPLACE_STRNDUP=1
40 [gl_cv_func_strndup=yes])], 43 AC_LIBOBJ([strndup])
41 [gl_cv_func_strndup=no])])]) 44 ;;
42 if test $gl_cv_func_strndup = yes; then 45 esac
43 AC_DEFINE([HAVE_STRNDUP], [1],
44 [Define if you have the strndup() function and it works.])
45 else 46 else
46 HAVE_STRNDUP=0
47 AC_LIBOBJ([strndup]) 47 AC_LIBOBJ([strndup])
48 gl_PREREQ_STRNDUP
49 fi 48 fi
50]) 49])
51
52# Prerequisites of lib/strndup.c.
53AC_DEFUN([gl_PREREQ_STRNDUP], [:])