summaryrefslogtreecommitdiff
path: root/m4/getline.m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2010-01-31 17:30:24 +0100
committerBruno Haible <bruno@clisp.org>2010-01-31 17:30:24 +0100
commit1150c074e8e94a4f310915f336cb01d3f196788c (patch)
tree8aac7ff4344d03ec87872f3b989b41d972cfe8c0 /m4/getline.m4
parent6c53c9025551ed72e7011f8de83aca2639bc5bfa (diff)
downloadgnulib-1150c074e8e94a4f310915f336cb01d3f196788c.tar.gz
Work around getline() bug on FreeBSD 8.0.
Diffstat (limited to 'm4/getline.m4')
-rw-r--r--m4/getline.m435
1 files changed, 24 insertions, 11 deletions
diff --git a/m4/getline.m4 b/m4/getline.m4
index 5b8a712fbc..7fca58ecf2 100644
--- a/m4/getline.m4
+++ b/m4/getline.m4
@@ -1,4 +1,4 @@
-# getline.m4 serial 20
+# getline.m4 serial 21
dnl Copyright (C) 1998-2003, 2005-2007, 2009-2010 Free Software Foundation,
dnl Inc.
@@ -24,26 +24,39 @@ AC_DEFUN([gl_FUNC_GETLINE],
gl_getline_needs_run_time_check=no
AC_CHECK_FUNC([getline],
- dnl Found it in some library. Verify that it works.
- gl_getline_needs_run_time_check=yes,
- am_cv_func_working_getline=no)
+ [dnl Found it in some library. Verify that it works.
+ gl_getline_needs_run_time_check=yes],
+ [am_cv_func_working_getline=no])
if test $gl_getline_needs_run_time_check = yes; then
AC_CACHE_CHECK([for working getline function], [am_cv_func_working_getline],
- [echo fooN |tr -d '\012'|tr N '\012' > conftest.data
+ [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
AC_RUN_IFELSE([AC_LANG_SOURCE([[
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
int main ()
- { /* Based on a test program from Karl Heuer. */
- char *line = NULL;
- size_t siz = 0;
- int len;
+ {
FILE *in = fopen ("./conftest.data", "r");
if (!in)
return 1;
- len = getline (&line, &siz, in);
- exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
+ {
+ /* Test result for a NULL buffer and a zero size.
+ Based on a test program from Karl Heuer. */
+ char *line = NULL;
+ size_t siz = 0;
+ int len = getline (&line, &siz, in);
+ if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
+ return 1;
+ }
+ {
+ /* Test result for a NULL buffer and a non-zero size.
+ This crashes on FreeBSD 8.0. */
+ char *line = NULL;
+ size_t siz = (size_t)(~0) / 4;
+ if (getline (&line, &siz, in) == -1)
+ return 1;
+ }
+ return 0;
}
]])], [am_cv_func_working_getline=yes] dnl The library version works.
, [am_cv_func_working_getline=no] dnl The library version does NOT work.