Mercurial > gnulib
annotate m4/fopen.m4 @ 40186:8964917f9574
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Mon, 18 Feb 2019 08:02:49 -0800 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
18935
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
1 # fopen.m4 serial 10 |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
2 dnl Copyright (C) 2007-2019 Free Software Foundation, Inc. |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 dnl This file is free software; the Free Software Foundation |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 dnl gives unlimited permission to copy and/or distribute it, |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 dnl with or without modifications, as long as this notice is preserved. |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 AC_DEFUN([gl_FUNC_FOPEN], |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 [ |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 AC_REQUIRE([AC_CANONICAL_HOST]) |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 case "$host_os" in |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 mingw* | pw*) |
11032
58b810e18aa8
Fix test-fopen failure on mingw.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
13 dnl Replace fopen, for handling of "/dev/null". |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 REPLACE_FOPEN=1 |
11032
58b810e18aa8
Fix test-fopen failure on mingw.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
15 dnl fopen on mingw also has the trailing slash bug. |
58b810e18aa8
Fix test-fopen failure on mingw.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
16 gl_cv_func_fopen_slash="guessing no" |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 ;; |
10376
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
18 *) |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
19 dnl fopen("foo/", "w") should not create a file when the file name has a |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
20 dnl trailing slash. |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
21 AC_CACHE_CHECK([whether fopen recognizes a trailing slash], |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
22 [gl_cv_func_fopen_slash], |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
23 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13490
diff
changeset
|
24 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13490
diff
changeset
|
25 [AC_LANG_SOURCE([[ |
10376
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
26 #include <stddef.h> |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
27 #include <stdio.h> |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
28 int main () |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
29 { |
18935
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
30 FILE *fp = fopen ("conftest.sl/", "w"); |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
31 int result = (fp != NULL); |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
32 if (fp != NULL) |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
33 fclose (fp); |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
34 return result; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13490
diff
changeset
|
35 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13490
diff
changeset
|
36 [gl_cv_func_fopen_slash=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13490
diff
changeset
|
37 [gl_cv_func_fopen_slash=no], |
10376
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
38 [ |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
39 changequote(,)dnl |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
40 case "$host_os" in |
13972
258e995bb973
Fix cross-compilation guesses on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
41 aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*) |
13490
e04f4ee19c1b
open, fopen: Update regarding AIX.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
42 gl_cv_func_fopen_slash="guessing no" ;; |
e04f4ee19c1b
open, fopen: Update regarding AIX.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
43 *) |
e04f4ee19c1b
open, fopen: Update regarding AIX.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
44 gl_cv_func_fopen_slash="guessing yes" ;; |
10376
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
45 esac |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
46 changequote([,])dnl |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
47 ]) |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
48 rm -f conftest.sl |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
49 ]) |
8532ecccedda
Work around bug with trailing slash on Solaris 9 and HP-UX 11.00.
Bruno Haible <bruno@clisp.org>
parents:
9301
diff
changeset
|
50 ;; |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 esac |
11032
58b810e18aa8
Fix test-fopen failure on mingw.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
52 case "$gl_cv_func_fopen_slash" in |
58b810e18aa8
Fix test-fopen failure on mingw.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
53 *no) |
58b810e18aa8
Fix test-fopen failure on mingw.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
54 AC_DEFINE([FOPEN_TRAILING_SLASH_BUG], [1], |
58b810e18aa8
Fix test-fopen failure on mingw.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
55 [Define to 1 if fopen() fails to recognize a trailing slash.]) |
58b810e18aa8
Fix test-fopen failure on mingw.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
56 REPLACE_FOPEN=1 |
58b810e18aa8
Fix test-fopen failure on mingw.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
57 ;; |
58b810e18aa8
Fix test-fopen failure on mingw.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
58 esac |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 ]) |
10531
e83a90adf243
Override fopen more carefully.
Bruno Haible <bruno@clisp.org>
parents:
10376
diff
changeset
|
60 |
e83a90adf243
Override fopen more carefully.
Bruno Haible <bruno@clisp.org>
parents:
10376
diff
changeset
|
61 # Prerequisites of lib/fopen.c. |
17185
dd46d4e6beea
dup, execute, fatal-signal, etc.: no 'static inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
62 AC_DEFUN([gl_PREREQ_FOPEN], [:]) |