diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2007-01-24 22:47:25 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2007-01-24 22:47:25 +0000 |
commit | fe856aa957978504137c1d425815d4ed8a22be40 (patch) | |
tree | a5bb46ce0e64b2056f75700eadbf27aba7c39418 /gl/m4/strndup.m4 | |
parent | 210f39bc84cfbb21cd72dc054e43f13815ee0616 (diff) | |
download | monitoring-plugins-fe856aa957978504137c1d425815d4ed8a22be40.tar.gz |
Sync with gnulib - lots of extraneous code removed in preference to GNU code
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1580 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'gl/m4/strndup.m4')
-rw-r--r-- | gl/m4/strndup.m4 | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gl/m4/strndup.m4 b/gl/m4/strndup.m4 new file mode 100644 index 00000000..dd5780b6 --- /dev/null +++ b/gl/m4/strndup.m4 | |||
@@ -0,0 +1,48 @@ | |||
1 | # strndup.m4 serial 11 | ||
2 | dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | AC_DEFUN([gl_FUNC_STRNDUP], | ||
8 | [ | ||
9 | dnl Persuade glibc <string.h> to declare strndup(). | ||
10 | AC_REQUIRE([AC_GNU_SOURCE]) | ||
11 | |||
12 | AC_CHECK_DECLS_ONCE([strndup]) | ||
13 | |||
14 | # 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, | ||
16 | [AC_RUN_IFELSE([ | ||
17 | AC_LANG_PROGRAM([#include <string.h> | ||
18 | #include <stdlib.h>], [[ | ||
19 | #ifndef HAVE_DECL_STRNDUP | ||
20 | extern char *strndup (const char *, size_t); | ||
21 | #endif | ||
22 | char *s; | ||
23 | s = strndup ("some longer string", 15); | ||
24 | free (s); | ||
25 | s = strndup ("shorter string", 13); | ||
26 | return s[13] != '\0';]])], | ||
27 | [gl_cv_func_strndup=yes], | ||
28 | [gl_cv_func_strndup=no], | ||
29 | [AC_CHECK_FUNC([strndup], | ||
30 | [AC_EGREP_CPP([too risky], [ | ||
31 | #ifdef _AIX | ||
32 | too risky | ||
33 | #endif | ||
34 | ], | ||
35 | [gl_cv_func_strndup=no], | ||
36 | [gl_cv_func_strndup=yes])], | ||
37 | [gl_cv_func_strndup=no])])]) | ||
38 | if test $gl_cv_func_strndup = yes; then | ||
39 | AC_DEFINE([HAVE_STRNDUP], 1, | ||
40 | [Define if you have the strndup() function and it works.]) | ||
41 | else | ||
42 | AC_LIBOBJ([strndup]) | ||
43 | gl_PREREQ_STRNDUP | ||
44 | fi | ||
45 | ]) | ||
46 | |||
47 | # Prerequisites of lib/strndup.c. | ||
48 | AC_DEFUN([gl_PREREQ_STRNDUP], [:]) | ||