3
dnl Copyright (C) 2005, 2006, 2007 Free Software dnl Foundation, Inc.
3
dnl Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
5
5
dnl This file is free software; the Free Software Foundation
6
6
dnl gives unlimited permission to copy and/or distribute it,
15
15
dnl Persuade glibc <stdio.h> to declare getdelim().
16
16
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
18
AC_REPLACE_FUNCS([getdelim])
19
18
AC_CHECK_DECLS_ONCE([getdelim])
21
if test $ac_cv_func_getdelim = no; then
20
AC_CHECK_FUNCS_ONCE([getdelim])
21
if test $ac_cv_func_getdelim = yes; then
23
dnl Found it in some library. Verify that it works.
24
AC_CACHE_CHECK([for working getdelim function], [gl_cv_func_working_getdelim],
25
[echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
26
AC_RUN_IFELSE([AC_LANG_SOURCE([[
32
FILE *in = fopen ("./conftest.data", "r");
36
/* Test result for a NULL buffer and a zero size.
37
Based on a test program from Karl Heuer. */
40
int len = getdelim (&line, &siz, '\n', in);
41
if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
45
/* Test result for a NULL buffer and a non-zero size.
46
This crashes on FreeBSD 8.0. */
48
size_t siz = (size_t)(~0) / 4;
49
if (getdelim (&line, &siz, '\n', in) == -1)
54
]])], [gl_cv_func_working_getdelim=yes] dnl The library version works.
55
, [gl_cv_func_working_getdelim=no] dnl The library version does NOT work.
56
, dnl We're cross compiling. Assume it works on glibc2 systems.
57
[AC_EGREP_CPP([Lucky GNU user],
60
#ifdef __GNU_LIBRARY__
61
#if (__GLIBC__ >= 2) && !defined __UCLIBC__
66
[gl_cv_func_working_getdelim=yes],
67
[gl_cv_func_working_getdelim=no])]
69
if test $gl_cv_func_working_getdelim = no; then
25
76
if test $ac_cv_have_decl_getdelim = no; then