Mercurial > hg > octave-kai > gnulib-hg
annotate m4/getdelim.m4 @ 14434:7624b26aea3d
sys_socket, netdb: Document problem with socklen_t.
* doc/posix-headers/sys_socket.texi: Mention lack of socklen_t on some
platforms.
* doc/posix-headers/netdb.texi: Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 19 Mar 2011 13:39:12 +0100 |
parents | 97fc9a21a8fb |
children | 20685414cb63 |
rev | line source |
---|---|
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13885
diff
changeset
|
1 # getdelim.m4 serial 8 |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
2 |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
13918
diff
changeset
|
3 dnl Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc. |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
4 dnl |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
5 dnl This file is free software; the Free Software Foundation |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
6 dnl gives unlimited permission to copy and/or distribute it, |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
7 dnl with or without modifications, as long as this notice is preserved. |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
8 |
9511
740cd2f7aaa1
Let these macros work also with autoconf-2.59.
Jim Meyering <meyering@redhat.com>
parents:
9209
diff
changeset
|
9 AC_PREREQ([2.59]) |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
10 |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
11 AC_DEFUN([gl_FUNC_GETDELIM], |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
12 [ |
9161
c5cedfcd0db0
Move getline and getdelim into stdio.h, per POSIX 200x.
Eric Blake <ebb9@byu.net>
parents:
7180
diff
changeset
|
13 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
14 |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
15 dnl Persuade glibc <stdio.h> to declare getdelim(). |
9209
5a0294ce5372
Track CVS Autoconf on AC_USE_SYSTEM_EXTENSIONS.
Eric Blake <ebb9@byu.net>
parents:
9164
diff
changeset
|
16 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
17 |
9164 | 18 AC_CHECK_DECLS_ONCE([getdelim]) |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
19 |
12839
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
20 AC_CHECK_FUNCS_ONCE([getdelim]) |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
21 if test $ac_cv_func_getdelim = yes; then |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
22 dnl Found it in some library. Verify that it works. |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
23 AC_CACHE_CHECK([for working getdelim function], [gl_cv_func_working_getdelim], |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
24 [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
25 AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
26 # include <stdio.h> |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
27 # include <stdlib.h> |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
28 # include <string.h> |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
29 int main () |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
30 { |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
31 FILE *in = fopen ("./conftest.data", "r"); |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
32 if (!in) |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
33 return 1; |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
34 { |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
35 /* Test result for a NULL buffer and a zero size. |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
36 Based on a test program from Karl Heuer. */ |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
37 char *line = NULL; |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
38 size_t siz = 0; |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
39 int len = getdelim (&line, &siz, '\n', in); |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
40 if (!(len == 4 && line && strcmp (line, "foo\n") == 0)) |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13885
diff
changeset
|
41 return 2; |
12839
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
42 } |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
43 { |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
44 /* Test result for a NULL buffer and a non-zero size. |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
45 This crashes on FreeBSD 8.0. */ |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
46 char *line = NULL; |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
47 size_t siz = (size_t)(~0) / 4; |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
48 if (getdelim (&line, &siz, '\n', in) == -1) |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13885
diff
changeset
|
49 return 3; |
12839
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
50 } |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
51 return 0; |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
52 } |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
53 ]])], [gl_cv_func_working_getdelim=yes] dnl The library version works. |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
54 , [gl_cv_func_working_getdelim=no] dnl The library version does NOT work. |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
55 , dnl We're cross compiling. Assume it works on glibc2 systems. |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
56 [AC_EGREP_CPP([Lucky GNU user], |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
57 [ |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
58 #include <features.h> |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
59 #ifdef __GNU_LIBRARY__ |
13885 | 60 #if (__GLIBC__ >= 2) && !defined __UCLIBC__ |
12839
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
61 Lucky GNU user |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
62 #endif |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
63 #endif |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
64 ], |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
65 [gl_cv_func_working_getdelim=yes], |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
66 [gl_cv_func_working_getdelim=no])] |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
67 )]) |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
68 else |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
69 gl_cv_func_working_getdelim=no |
9164 | 70 fi |
71 | |
72 if test $ac_cv_have_decl_getdelim = no; then | |
9161
c5cedfcd0db0
Move getline and getdelim into stdio.h, per POSIX 200x.
Eric Blake <ebb9@byu.net>
parents:
7180
diff
changeset
|
73 HAVE_DECL_GETDELIM=0 |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
74 fi |
12839
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
75 |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
76 if test $gl_cv_func_working_getdelim = no; then |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
77 if test $ac_cv_func_getdelim = yes; then |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
78 REPLACE_GETDELIM=1 |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
79 fi |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
80 AC_LIBOBJ([getdelim]) |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
81 gl_PREREQ_GETDELIM |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
82 fi |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
83 ]) |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
84 |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
85 # Prerequisites of lib/getdelim.c. |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
86 AC_DEFUN([gl_PREREQ_GETDELIM], |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
87 [ |
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
88 AC_CHECK_FUNCS([flockfile funlockfile]) |
10366
d41011f37051
use unlocked I/O in getdelim
Paolo Bonzini <bonzini@gnu.org>
parents:
9511
diff
changeset
|
89 AC_CHECK_DECLS([getc_unlocked]) |
6011
cf3d0bf4fc6f
2005-08-02 Simon Josefsson <jas@extundo.com>
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
90 ]) |