diff options
Diffstat (limited to 'gl/m4/ftello.m4')
| -rw-r--r-- | gl/m4/ftello.m4 | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/gl/m4/ftello.m4 b/gl/m4/ftello.m4 index 4901b168..35d30f98 100644 --- a/gl/m4/ftello.m4 +++ b/gl/m4/ftello.m4 | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | # ftello.m4 serial 14 | 1 | # ftello.m4 |
| 2 | dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. | 2 | # serial 17 |
| 3 | dnl Copyright (C) 2007-2025 Free Software Foundation, Inc. | ||
| 3 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 5 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 6 | dnl with or without modifications, as long as this notice is preserved. |
| 7 | dnl This file is offered as-is, without any warranty. | ||
| 6 | 8 | ||
| 7 | AC_DEFUN([gl_FUNC_FTELLO], | 9 | AC_DEFUN([gl_FUNC_FTELLO], |
| 8 | [ | 10 | [ |
| @@ -37,13 +39,24 @@ AC_DEFUN([gl_FUNC_FTELLO], | |||
| 37 | if test $gl_cv_var_stdin_large_offset = no; then | 39 | if test $gl_cv_var_stdin_large_offset = no; then |
| 38 | REPLACE_FTELLO=1 | 40 | REPLACE_FTELLO=1 |
| 39 | fi | 41 | fi |
| 42 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
| 43 | if test $REPLACE_FTELLO = 0; then | ||
| 44 | dnl On native Windows, in some circumstances, ftell(), ftello(), | ||
| 45 | dnl fgetpos(), lseek(), _lseeki64() all succeed on devices of type | ||
| 46 | dnl FILE_TYPE_PIPE. However, to match POSIX behaviour, we want | ||
| 47 | dnl ftell(), ftello(), fgetpos(), lseek() to fail when the argument fd | ||
| 48 | dnl designates a pipe. See also | ||
| 49 | dnl https://github.com/python/cpython/issues/78961#issuecomment-1093800325 | ||
| 50 | case "$host_os" in | ||
| 51 | mingw* | windows*) REPLACE_FTELLO=1 ;; | ||
| 52 | esac | ||
| 53 | fi | ||
| 40 | if test $REPLACE_FTELLO = 0; then | 54 | if test $REPLACE_FTELLO = 0; then |
| 41 | dnl Detect bug on Solaris. | 55 | dnl Detect bug on Solaris. |
| 42 | dnl ftell and ftello produce incorrect results after putc that followed a | 56 | dnl ftell and ftello produce incorrect results after putc that followed a |
| 43 | dnl getc call that reached EOF on Solaris. This is because the _IOREAD | 57 | dnl getc call that reached EOF on Solaris. This is because the _IOREAD |
| 44 | dnl flag does not get cleared in this case, even though _IOWRT gets set, | 58 | dnl flag does not get cleared in this case, even though _IOWRT gets set, |
| 45 | dnl and ftell and ftello look whether the _IOREAD flag is set. | 59 | dnl and ftell and ftello look whether the _IOREAD flag is set. |
| 46 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
| 47 | AC_CACHE_CHECK([whether ftello works], | 60 | AC_CACHE_CHECK([whether ftello works], |
| 48 | [gl_cv_func_ftello_works], | 61 | [gl_cv_func_ftello_works], |
| 49 | [ | 62 | [ |
| @@ -51,12 +64,12 @@ AC_DEFUN([gl_FUNC_FTELLO], | |||
| 51 | dnl be opened. | 64 | dnl be opened. |
| 52 | changequote(,)dnl | 65 | changequote(,)dnl |
| 53 | case "$host_os" in | 66 | case "$host_os" in |
| 54 | # Guess no on Solaris. | 67 | # Guess no on Solaris. |
| 55 | solaris*) gl_cv_func_ftello_works="guessing no" ;; | 68 | solaris*) gl_cv_func_ftello_works="guessing no" ;; |
| 56 | # Guess yes on native Windows. | 69 | # Guess yes on native Windows. |
| 57 | mingw*) gl_cv_func_ftello_works="guessing yes" ;; | 70 | mingw* | windows*) gl_cv_func_ftello_works="guessing yes" ;; |
| 58 | # Guess yes otherwise. | 71 | # Guess yes otherwise. |
| 59 | *) gl_cv_func_ftello_works="guessing yes" ;; | 72 | *) gl_cv_func_ftello_works="guessing yes" ;; |
| 60 | esac | 73 | esac |
| 61 | changequote([,])dnl | 74 | changequote([,])dnl |
| 62 | AC_RUN_IFELSE( | 75 | AC_RUN_IFELSE( |
| @@ -145,6 +158,10 @@ main (void) | |||
| 145 | # Prerequisites of lib/ftello.c. | 158 | # Prerequisites of lib/ftello.c. |
| 146 | AC_DEFUN([gl_PREREQ_FTELLO], | 159 | AC_DEFUN([gl_PREREQ_FTELLO], |
| 147 | [ | 160 | [ |
| 161 | if test $gl_cv_func_ftello != no; then | ||
| 162 | AC_DEFINE([HAVE_FTELLO], [1], | ||
| 163 | [Define to 1 if the system has the ftello function.]) | ||
| 164 | fi | ||
| 148 | dnl Native Windows has the function _ftelli64. mingw hides it, but mingw64 | 165 | dnl Native Windows has the function _ftelli64. mingw hides it, but mingw64 |
| 149 | dnl makes it usable again. | 166 | dnl makes it usable again. |
| 150 | AC_CHECK_FUNCS([_ftelli64]) | 167 | AC_CHECK_FUNCS([_ftelli64]) |
