2N/Adnl Copyright (C) 2005-2007, 2009-2010 Free Software Foundation, Inc.
2N/Adnl This file is free software; the Free Software Foundation
2N/Adnl gives unlimited permission to copy
and/or distribute it,
2N/Adnl with or without modifications, as long as this notice is preserved.
2N/AAC_DEFUN([gl_FUNC_GETDELIM],
2N/A AC_REQUIRE([gl_STDIO_H_DEFAULTS])
2N/A dnl Persuade glibc <
stdio.h> to declare getdelim().
2N/A AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
2N/A AC_CHECK_DECLS_ONCE([getdelim])
2N/A AC_CHECK_FUNCS_ONCE([getdelim])
2N/A if test $ac_cv_func_getdelim = yes; then
2N/A dnl Found it in some library. Verify that it works.
2N/A AC_CACHE_CHECK([for working getdelim function], [gl_cv_func_working_getdelim],
2N/A AC_RUN_IFELSE([AC_LANG_SOURCE([[
2N/A /* Test result for a NULL buffer and a zero size.
2N/A Based on a test program from Karl Heuer. */
2N/A int len = getdelim (&line, &siz, '\n', in);
2N/A if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
2N/A /* Test result for a NULL buffer and a non-zero size.
2N/A This crashes on FreeBSD 8.0. */
2N/A size_t siz = (size_t)(~0) / 4;
2N/A if (getdelim (&line, &siz, '\n', in) == -1)
2N/A ]])], [gl_cv_func_working_getdelim=yes] dnl The library version works.
2N/A , [gl_cv_func_working_getdelim=no] dnl The library version does NOT work.
2N/A , dnl We're cross compiling. Assume it works on glibc2 systems.
2N/A [AC_EGREP_CPP([Lucky GNU user],
2N/A#ifdef __GNU_LIBRARY__
2N/A #if (__GLIBC__ >= 2)
2N/A [gl_cv_func_working_getdelim=yes],
2N/A [gl_cv_func_working_getdelim=no])]
2N/A gl_cv_func_working_getdelim=no
2N/A if test $ac_cv_have_decl_getdelim = no; then
2N/A HAVE_DECL_GETDELIM=0
2N/A if test $gl_cv_func_working_getdelim = no; then
2N/A if test $ac_cv_func_getdelim = yes; then
2N/A AC_LIBOBJ([getdelim])
2N/AAC_DEFUN([gl_PREREQ_GETDELIM],
2N/A AC_CHECK_FUNCS([flockfile funlockfile])
2N/A AC_CHECK_DECLS([getc_unlocked])