annotate m4/strndup.m4 @ 436:4c272633fce2 3.0 3.0

Added missing files
author lost@l-w.ca
date Fri, 29 Oct 2010 19:28:54 -0600
parents b8bf63962a99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
434
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
1 # strndup.m4 serial 17
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
2 dnl Copyright (C) 2002-2003, 2005-2010 Free Software Foundation, Inc.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
6
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_STRNDUP],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
8 [
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
9 dnl Persuade glibc <string.h> to declare strndup().
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
10 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
11
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
13 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
14 AC_CHECK_DECLS_ONCE([strndup])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
15 AC_CHECK_FUNCS_ONCE([strndup])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
16 if test $ac_cv_have_decl_strndup = no; then
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
17 HAVE_DECL_STRNDUP=0
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
18 fi
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
19
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
20 if test $ac_cv_func_strndup = yes; then
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
21 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
22 AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup_works],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
23 [AC_RUN_IFELSE([
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
24 AC_LANG_PROGRAM([[#include <string.h>
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
25 #include <stdlib.h>]], [[
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
26 #ifndef HAVE_DECL_STRNDUP
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
27 extern char *strndup (const char *, size_t);
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
28 #endif
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
29 char *s;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
30 s = strndup ("some longer string", 15);
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
31 free (s);
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
32 s = strndup ("shorter string", 13);
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
33 return s[13] != '\0';]])],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
34 [gl_cv_func_strndup_works=yes],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
35 [gl_cv_func_strndup_works=no],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
36 [case $host_os in
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
37 aix*) gl_cv_func_strndup_works="guessing no";;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
38 *) gl_cv_func_strndup_works="guessing yes";;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
39 esac])])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
40 case $gl_cv_func_strndup_works in
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
41 *no)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
42 REPLACE_STRNDUP=1
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
43 AC_LIBOBJ([strndup])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
44 ;;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
45 esac
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
46 else
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
47 AC_LIBOBJ([strndup])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
48 fi
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
49 ])