summaryrefslogtreecommitdiff
path: root/m4/strnlen.m4
blob: a5bd2ef0075bd3b4f79f4501041980fe5be36c6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#serial 1

# This is already in cvs autoconf -- what will be 2.52g.
# Define it here for those who aren't on the bleeding edge.
# FIXME: remove this file once the next autoconf release comes out.

undefine([AC_FUNC_STRNLEN])

# AC_FUNC_STRNLEN
# --------------
AC_DEFUN([AC_FUNC_STRNLEN],
[AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
[AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[
#define S "foobar"
#define S_LEN (sizeof S - 1)

  /* At least one implementation is buggy: that of AIX 4.3.  */
  int i;
  for (i = 0; i < S_LEN + 1; ++i)
    {
      int result = i <= S_LEN ? i : S_LEN;
      if (strnlen (S, i) != result)
	exit (1);
    }
  exit (0);
]])],
               [ac_cv_func_strnlen_working=yes],
               [ac_cv_func_strnlen_working=no],
               [ac_cv_func_strnlen_working=no])])
test $ac_cv_func_strnlen_working = no && AC_LIBOBJ([strnlen])
])# AC_FUNC_STRNLEN