* lib/stdint_.h: Fix typo: _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H was
[gnulib.git] / lib / ftello.c
index 7054dd5..3edc0fb 100644 (file)
 /* Specification.  */
 #include <stdio.h>
 
+/* Get lseek.  */
+#include <unistd.h>
+
 #undef ftello
 #if !HAVE_FTELLO
+# undef ftell
 # define ftello ftell
 #endif
 
 off_t
 rpl_ftello (FILE *fp)
 {
+#if LSEEK_PIPE_BROKEN
+  /* mingw gives bogus answers rather than failure on non-seekable files.  */
+  if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
+    return -1;
+#endif
+
 #if defined __SL64 && defined __SCLE /* Cygwin */
   if ((fp->_flags & __SL64) == 0)
     {