summaryrefslogtreecommitdiff
path: root/m4/ftello.m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2023-04-24 19:48:47 +0200
committerBruno Haible <bruno@clisp.org>2023-04-24 19:48:47 +0200
commitc254399aae1fb663ff9d3038aa4725213afc2cc3 (patch)
tree6acd0c1e4371284a5d8099bc8c93995bd618f6fe /m4/ftello.m4
parentca5545a273810bb759fb854f70b8d228b6094ff0 (diff)
downloadgnulib-c254399aae1fb663ff9d3038aa4725213afc2cc3.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. * doc/posix-functions/ftello.texi: Mention the behaviour on pipes. * doc/posix-functions/ftell.texi: Likewise. * doc/posix-functions/fgetpos.texi: Likewise.
Diffstat (limited to 'm4/ftello.m4')
-rw-r--r--m4/ftello.m415
1 files changed, 13 insertions, 2 deletions
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],
[