diff options
author | Bruno Haible <bruno@clisp.org> | 2023-04-24 19:48:47 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-04-27 18:21:40 +0200 |
commit | c82e48bd6a8c0810cd590f64c1e9380acb68ae36 (patch) | |
tree | 420cabe4d97a78e86ee48412d254b32e7b0c7875 | |
parent | 3f2c306452430cf8126aea24b64d881b2f644afe (diff) | |
download | gnulib-c82e48bd6a8c0810cd590f64c1e9380acb68ae36.tar.gz |
ftell, ftello: Fix recognition of pipes on native Windows.
* m4/lseek.m4 (gl_FUNC_LSEEK): Update comment.
* m4/ftello.m4 (gl_FUNC_FTELLO): On native Windows, set REPLACE_FTELLO=1
always.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | m4/ftello.m4 | 15 | ||||
-rw-r--r-- | m4/lseek.m4 | 10 |
3 files changed, 26 insertions, 6 deletions
@@ -1,5 +1,12 @@ 2023-04-24 Bruno Haible <bruno@clisp.org> + ftell, ftello: Fix recognition of pipes on native Windows. + * m4/lseek.m4 (gl_FUNC_LSEEK): Update comment. + * m4/ftello.m4 (gl_FUNC_FTELLO): On native Windows, set REPLACE_FTELLO=1 + always. + +2023-04-24 Bruno Haible <bruno@clisp.org> + lseek: Fix module dependencies (regression 2021-11-15). * modules/lseek (Depends-on): Re-enable the msvc-nothrow dependency also when WINDOWS_64_BIT_OFF_T is 0. diff --git a/m4/ftello.m4 b/m4/ftello.m4 index 4901b16835..e13fcd93d2 100644 --- a/m4/ftello.m4 +++ b/m4/ftello.m4 @@ -1,4 +1,4 @@ -# ftello.m4 serial 14 +# ftello.m4 serial 15 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -37,13 +37,24 @@ AC_DEFUN([gl_FUNC_FTELLO], if test $gl_cv_var_stdin_large_offset = no; then REPLACE_FTELLO=1 fi + AC_REQUIRE([AC_CANONICAL_HOST]) + if test $REPLACE_FTELLO = 0; then + dnl On native Windows, in some circumstances, ftell(), ftello(), + dnl fgetpos(), lseek(), _lseeki64() all succeed on devices of type + dnl FILE_TYPE_PIPE. However, to match POSIX behaviour, we want + dnl ftell(), ftello(), fgetpos(), lseek() to fail when the argument fd + dnl designates a pipe. See also + dnl https://github.com/python/cpython/issues/78961#issuecomment-1093800325 + case "$host_os" in + mingw*) REPLACE_FTELLO=1 ;; + esac + fi if test $REPLACE_FTELLO = 0; then dnl Detect bug on Solaris. dnl ftell and ftello produce incorrect results after putc that followed a dnl getc call that reached EOF on Solaris. This is because the _IOREAD dnl flag does not get cleared in this case, even though _IOWRT gets set, dnl and ftell and ftello look whether the _IOREAD flag is set. - AC_REQUIRE([AC_CANONICAL_HOST]) AC_CACHE_CHECK([whether ftello works], [gl_cv_func_ftello_works], [ diff --git a/m4/lseek.m4 b/m4/lseek.m4 index 6e1ab6ffaa..0da458804f 100644 --- a/m4/lseek.m4 +++ b/m4/lseek.m4 @@ -1,4 +1,4 @@ -# lseek.m4 serial 13 +# lseek.m4 serial 14 dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -17,9 +17,11 @@ AC_DEFUN([gl_FUNC_LSEEK], dnl Native Windows. dnl The result of lseek (fd, (off_t)0, SEEK_CUR) or dnl SetFilePointer(handle, 0, NULL, FILE_CURRENT) - dnl for a pipe depends on the environment: In a Cygwin 1.5 - dnl environment it succeeds (wrong); in a Cygwin 1.7 environment - dnl it fails with a wrong errno value. + dnl for a pipe depends on the environment: + dnl In a Cygwin 1.5 environment it succeeds (wrong); + dnl in a Cygwin 1.7 environment it fails with a wrong errno value; + dnl in a Cygwin 2.9.0 environment it fails correctly; + dnl in a Cygwin 3.4.6 environment it succeeds again (wrong). gl_cv_func_lseek_pipe=no ;; *) |