annotate m4/strndup.m4 @ 423:079d43b6967b 3.0-beta2 3.0-beta2

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