annotate m4/strndup.m4 @ 272:d5392bb5da3c 2.5

Added generated files
author lost
date Sun, 16 Aug 2009 17:16:49 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
272
d5392bb5da3c Added generated files
lost
parents:
diff changeset
1 # strndup.m4 serial 15
d5392bb5da3c Added generated files
lost
parents:
diff changeset
2 dnl Copyright (C) 2002-2003, 2005-2008 Free Software Foundation, Inc.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
d5392bb5da3c Added generated files
lost
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
d5392bb5da3c Added generated files
lost
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
6
d5392bb5da3c Added generated files
lost
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_STRNDUP],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
8 [
d5392bb5da3c Added generated files
lost
parents:
diff changeset
9 dnl Persuade glibc <string.h> to declare strndup().
d5392bb5da3c Added generated files
lost
parents:
diff changeset
10 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
11
d5392bb5da3c Added generated files
lost
parents:
diff changeset
12 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
13 AC_CHECK_DECLS_ONCE([strndup])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
14 if test $ac_cv_have_decl_strndup = no; then
d5392bb5da3c Added generated files
lost
parents:
diff changeset
15 HAVE_DECL_STRNDUP=0
d5392bb5da3c Added generated files
lost
parents:
diff changeset
16 fi
d5392bb5da3c Added generated files
lost
parents:
diff changeset
17
d5392bb5da3c Added generated files
lost
parents:
diff changeset
18 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
19 AC_CACHE_CHECK([for working strndup], gl_cv_func_strndup,
d5392bb5da3c Added generated files
lost
parents:
diff changeset
20 [AC_RUN_IFELSE([
d5392bb5da3c Added generated files
lost
parents:
diff changeset
21 AC_LANG_PROGRAM([[#include <string.h>
d5392bb5da3c Added generated files
lost
parents:
diff changeset
22 #include <stdlib.h>]], [[
d5392bb5da3c Added generated files
lost
parents:
diff changeset
23 #ifndef HAVE_DECL_STRNDUP
d5392bb5da3c Added generated files
lost
parents:
diff changeset
24 extern char *strndup (const char *, size_t);
d5392bb5da3c Added generated files
lost
parents:
diff changeset
25 #endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
26 char *s;
d5392bb5da3c Added generated files
lost
parents:
diff changeset
27 s = strndup ("some longer string", 15);
d5392bb5da3c Added generated files
lost
parents:
diff changeset
28 free (s);
d5392bb5da3c Added generated files
lost
parents:
diff changeset
29 s = strndup ("shorter string", 13);
d5392bb5da3c Added generated files
lost
parents:
diff changeset
30 return s[13] != '\0';]])],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
31 [gl_cv_func_strndup=yes],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
32 [gl_cv_func_strndup=no],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
33 [AC_CHECK_FUNC([strndup],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
34 [AC_EGREP_CPP([too risky], [
d5392bb5da3c Added generated files
lost
parents:
diff changeset
35 #ifdef _AIX
d5392bb5da3c Added generated files
lost
parents:
diff changeset
36 too risky
d5392bb5da3c Added generated files
lost
parents:
diff changeset
37 #endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
38 ],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
39 [gl_cv_func_strndup=no],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
40 [gl_cv_func_strndup=yes])],
d5392bb5da3c Added generated files
lost
parents:
diff changeset
41 [gl_cv_func_strndup=no])])])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
42 if test $gl_cv_func_strndup = yes; then
d5392bb5da3c Added generated files
lost
parents:
diff changeset
43 AC_DEFINE([HAVE_STRNDUP], 1,
d5392bb5da3c Added generated files
lost
parents:
diff changeset
44 [Define if you have the strndup() function and it works.])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
45 else
d5392bb5da3c Added generated files
lost
parents:
diff changeset
46 HAVE_STRNDUP=0
d5392bb5da3c Added generated files
lost
parents:
diff changeset
47 AC_LIBOBJ([strndup])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
48 gl_PREREQ_STRNDUP
d5392bb5da3c Added generated files
lost
parents:
diff changeset
49 fi
d5392bb5da3c Added generated files
lost
parents:
diff changeset
50 ])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
51
d5392bb5da3c Added generated files
lost
parents:
diff changeset
52 # Prerequisites of lib/strndup.c.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
53 AC_DEFUN([gl_PREREQ_STRNDUP], [:])