Mercurial > gnulib
annotate m4/ungetc.m4 @ 40233:331ec5f027a2
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Wed, 13 Mar 2019 11:14:26 -0700 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
19479
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
1 # ungetc.m4 serial 6 |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
2 dnl Copyright (C) 2009-2019 Free Software Foundation, Inc. |
11215
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
3 dnl This file is free software; the Free Software Foundation |
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
4 dnl gives unlimited permission to copy and/or distribute it, |
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
5 dnl with or without modifications, as long as this notice is preserved. |
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
6 |
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
7 AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS], |
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
8 [ |
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
9 AC_REQUIRE([AC_PROG_CC]) |
16823
c663938a6408
fseeko-tests, ftello-tests: Avoid "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
11215
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
11 |
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
12 AC_CACHE_CHECK([whether ungetc works on arbitrary bytes], |
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
13 [gl_cv_func_ungetc_works], |
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
14 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
15 #include <stdio.h> |
12224
ba9f6f755aa8
maint: avoid compiler warnings in m4 macros
Eric Blake <ebb9@byu.net>
parents:
11215
diff
changeset
|
16 ]], [FILE *f; |
18935
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
17 if (!(f = fopen ("conftest.tmp", "w+"))) |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
18 return 1; |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
19 if (fputs ("abc", f) < 0) |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
20 { fclose (f); return 2; } |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12224
diff
changeset
|
21 rewind (f); |
18935
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
22 if (fgetc (f) != 'a') |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
23 { fclose (f); return 3; } |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
24 if (fgetc (f) != 'b') |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
25 { fclose (f); return 4; } |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
26 if (ungetc ('d', f) != 'd') |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
27 { fclose (f); return 5; } |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
28 if (ftell (f) != 1) |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
29 { fclose (f); return 6; } |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
30 if (fgetc (f) != 'd') |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
31 { fclose (f); return 7; } |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
32 if (ftell (f) != 2) |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
33 { fclose (f); return 8; } |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
34 if (fseek (f, 0, SEEK_CUR) != 0) |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
35 { fclose (f); return 9; } |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
36 if (ftell (f) != 2) |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
37 { fclose (f); return 10; } |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
38 if (fgetc (f) != 'c') |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
39 { fclose (f); return 11; } |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
40 fclose (f); |
ec3c62e83a8b
Avoid wrong configure results with gcc -fsanitize=address.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
41 remove ("conftest.tmp");])], |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12224
diff
changeset
|
42 [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no], |
16823
c663938a6408
fseeko-tests, ftello-tests: Avoid "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
43 [case "$host_os" in |
19479
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
44 # Guess yes on glibc and bionic systems. |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
45 *-gnu* | gnu* | *-android*) gl_cv_func_ungetc_works="guessing yes" ;; |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
46 # Guess yes on native Windows. |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
47 mingw*) gl_cv_func_ungetc_works="guessing yes" ;; |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
48 # If we don't know, assume the worst. |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
49 *) gl_cv_func_ungetc_works="guessing no" ;; |
16823
c663938a6408
fseeko-tests, ftello-tests: Avoid "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
50 esac |
c663938a6408
fseeko-tests, ftello-tests: Avoid "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
51 ]) |
11215
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
52 ]) |
16823
c663938a6408
fseeko-tests, ftello-tests: Avoid "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
53 case "$gl_cv_func_ungetc_works" in |
c663938a6408
fseeko-tests, ftello-tests: Avoid "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
54 *yes) ;; |
c663938a6408
fseeko-tests, ftello-tests: Avoid "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
55 *) |
c663938a6408
fseeko-tests, ftello-tests: Avoid "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
56 AC_DEFINE([FUNC_UNGETC_BROKEN], [1], |
c663938a6408
fseeko-tests, ftello-tests: Avoid "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
57 [Define to 1 if ungetc is broken when used on arbitrary bytes.]) |
c663938a6408
fseeko-tests, ftello-tests: Avoid "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
58 ;; |
c663938a6408
fseeko-tests, ftello-tests: Avoid "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
59 esac |
11215
92a6ab18ea18
tests: skip fseek/ftell tests if ungetc is broken
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
60 ]) |