summaryrefslogtreecommitdiffstats
path: root/gl/m4/strndup.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/strndup.m4')
-rw-r--r--gl/m4/strndup.m413
1 files changed, 9 insertions, 4 deletions
diff --git a/gl/m4/strndup.m4 b/gl/m4/strndup.m4
index dd5780b..f7934ef 100644
--- a/gl/m4/strndup.m4
+++ b/gl/m4/strndup.m4
@@ -1,5 +1,5 @@
1# strndup.m4 serial 11 1# strndup.m4 serial 14
2dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2005-2007 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.
@@ -7,15 +7,19 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_FUNC_STRNDUP], 7AC_DEFUN([gl_FUNC_STRNDUP],
8[ 8[
9 dnl Persuade glibc <string.h> to declare strndup(). 9 dnl Persuade glibc <string.h> to declare strndup().
10 AC_REQUIRE([AC_GNU_SOURCE]) 10 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
11 11
12 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
12 AC_CHECK_DECLS_ONCE([strndup]) 13 AC_CHECK_DECLS_ONCE([strndup])
14 if test $ac_cv_have_decl_strndup = no; then
15 HAVE_DECL_STRNDUP=0
16 fi
13 17
14 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'. 18 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
15 AC_CACHE_CHECK([for working strndup], gl_cv_func_strndup, 19 AC_CACHE_CHECK([for working strndup], gl_cv_func_strndup,
16 [AC_RUN_IFELSE([ 20 [AC_RUN_IFELSE([
17 AC_LANG_PROGRAM([#include <string.h> 21 AC_LANG_PROGRAM([#include <string.h>
18 #include <stdlib.h>], [[ 22 #include <stdlib.h>], [[
19#ifndef HAVE_DECL_STRNDUP 23#ifndef HAVE_DECL_STRNDUP
20 extern char *strndup (const char *, size_t); 24 extern char *strndup (const char *, size_t);
21#endif 25#endif
@@ -39,6 +43,7 @@ AC_DEFUN([gl_FUNC_STRNDUP],
39 AC_DEFINE([HAVE_STRNDUP], 1, 43 AC_DEFINE([HAVE_STRNDUP], 1,
40 [Define if you have the strndup() function and it works.]) 44 [Define if you have the strndup() function and it works.])
41 else 45 else
46 HAVE_STRNDUP=0
42 AC_LIBOBJ([strndup]) 47 AC_LIBOBJ([strndup])
43 gl_PREREQ_STRNDUP 48 gl_PREREQ_STRNDUP
44 fi 49 fi