Fix typo in comment.
[gnulib.git] / m4 / getline.m4
1 #serial 2
2
3 dnl See if there's a working, system-supplied version of the getline function.
4 dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
5 dnl have a function by that name in -linet that doesn't have anything
6 dnl to do with the function we need.
7 AC_DEFUN(AM_FUNC_GETLINE,
8 [dnl
9   am_getline_needs_run_time_check=no
10   am_cv_func_working_getline=yes
11   AC_CHECK_FUNC(getline,
12                 dnl Found it in some library.  Verify that it works.
13                 am_getline_needs_run_time_check=yes,
14                 am_cv_func_working_getline=no)
15   if test $am_getline_needs_run_time_check = yes; then
16     AC_CHECK_HEADERS(string.h)
17     AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline,
18     [echo fooN |tr -d '\012'|tr N '\012' > conftestdata
19     AC_TRY_RUN([
20 #    include <stdio.h>
21 #    include <sys/types.h>
22 #    if HAVE_STRING_H
23 #     include <string.h>
24 #    endif
25     int main ()
26     { /* Based on a test program from Karl Heuer.  */
27       char *line = NULL;
28       size_t siz = 0;
29       int len;
30       FILE *in = fopen ("./conftestdata", "r");
31       if (!in)
32         return 1;
33       len = getline (&line, &siz, in);
34       exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
35     }
36     ], am_cv_func_working_getline=yes dnl The library version works.
37     , am_cv_func_working_getline=no dnl The library version does NOT work.
38     , am_cv_func_working_getline=no dnl We're cross compiling.
39     )])
40   fi
41
42   if test $am_cv_func_working_getline = no; then
43     LIBOBJS="$LIBOBJS getline.o"
44     AC_SUBST(LIBOBJS)dnl
45   fi
46 ])