Blame SOURCES/sharutils-4.15.2-fflush-adjust-to-glibc-2.28-libio.h-removal.patch

230fb9
From 0e2f412eeec2e1f7f5743ea23c62bdf98bf4102c Mon Sep 17 00:00:00 2001
230fb9
From: Paul Eggert <eggert@cs.ucla.edu>
230fb9
Date: Thu, 8 Mar 2018 16:42:45 -0800
230fb9
Subject: [PATCH] fflush: adjust to glibc 2.28 libio.h removal
230fb9
MIME-Version: 1.0
230fb9
Content-Type: text/plain; charset=UTF-8
230fb9
Content-Transfer-Encoding: 8bit
230fb9
230fb9
Petr Písař: Ported to sharutils-4.15.2 from:
230fb9
230fb9
commit 4af4a4a71827c0bc5e0ec67af23edef4f15cee8e
230fb9
Author: Paul Eggert <eggert@cs.ucla.edu>
230fb9
Date:   Mon Mar 5 10:56:29 2018 -0800
230fb9
230fb9
    fflush: adjust to glibc 2.28 libio.h removal
230fb9
230fb9
Problem reported by Daniel P. Berrangé in:
230fb9
https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
230fb9
* lib/fbufmode.c (fbufmode):
230fb9
* lib/fflush.c (clear_ungetc_buffer_preserving_position)
230fb9
(disable_seek_optimization, rpl_fflush):
230fb9
* lib/fpending.c (__fpending):
230fb9
* lib/fpurge.c (fpurge):
230fb9
* lib/freadable.c (freadable):
230fb9
* lib/freadahead.c (freadahead):
230fb9
* lib/freading.c (freading):
230fb9
* lib/freadptr.c (freadptr):
230fb9
* lib/freadseek.c (freadptrinc):
230fb9
* lib/fseeko.c (fseeko):
230fb9
* lib/fseterr.c (fseterr):
230fb9
* lib/fwritable.c (fwritable):
230fb9
* lib/fwriting.c (fwriting):
230fb9
Check _IO_EOF_SEEN instead of _IO_ftrylockfile.
230fb9
* lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]:
230fb9
Define if not already defined.
230fb9
230fb9
commit 74d9d6a293d7462dea8f83e7fc5ac792e956a0ad
230fb9
Author: Paul Eggert <eggert@cs.ucla.edu>
230fb9
Date:   Thu Mar 8 16:42:45 2018 -0800
230fb9
230fb9
    fflush: be more paranoid about libio.h change
230fb9
230fb9
Suggested by Eli Zaretskii in:
230fb9
https://lists.gnu.org/r/emacs-devel/2018-03/msg00270.html
230fb9
* lib/fbufmode.c (fbufmode):
230fb9
* lib/fflush.c (clear_ungetc_buffer_preserving_position)
230fb9
(disable_seek_optimization, rpl_fflush):
230fb9
* lib/fpending.c (__fpending):
230fb9
* lib/fpurge.c (fpurge):
230fb9
* lib/freadable.c (freadable):
230fb9
* lib/freadahead.c (freadahead):
230fb9
* lib/freading.c (freading):
230fb9
* lib/freadptr.c (freadptr):
230fb9
* lib/freadseek.c (freadptrinc):
230fb9
* lib/fseeko.c (fseeko):
230fb9
* lib/fseterr.c (fseterr):
230fb9
* lib/fwritable.c (fwritable):
230fb9
* lib/fwriting.c (fwriting):
230fb9
Look at _IO_ftrylockfile as well as at _IO_EOF_SEEN.
230fb9
230fb9
This is needed for glibc-2.28 (First spotted with
230fb9
glibc-2.27.9000-13.fc29 on Fedora).
230fb9
230fb9
Signed-off-by: Petr Písař <ppisar@redhat.com>
230fb9
---
230fb9
 lib/fflush.c     | 9 ++++++---
230fb9
 lib/fpurge.c     | 3 ++-
230fb9
 lib/freading.c   | 3 ++-
230fb9
 lib/fseeko.c     | 6 ++++--
230fb9
 lib/stdio-impl.h | 6 ++++++
230fb9
 5 files changed, 20 insertions(+), 7 deletions(-)
230fb9
230fb9
diff --git a/lib/fflush.c b/lib/fflush.c
230fb9
index 5ae3e41..d887ecb 100644
230fb9
--- a/lib/fflush.c
230fb9
+++ b/lib/fflush.c
230fb9
@@ -33,7 +33,8 @@
230fb9
 #undef fflush
230fb9
 
230fb9
 
230fb9
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
230fb9
+/* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
 
230fb9
 /* Clear the stream's ungetc buffer, preserving the value of ftello (fp).  */
230fb9
 static void
230fb9
@@ -72,7 +73,8 @@ clear_ungetc_buffer (FILE *fp)
230fb9
 
230fb9
 #endif
230fb9
 
230fb9
-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
230fb9
+#if ! (defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1)
230fb9
+/* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
 
230fb9
 # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
230fb9
 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
230fb9
@@ -148,7 +150,8 @@ rpl_fflush (FILE *stream)
230fb9
   if (stream == NULL || ! freading (stream))
230fb9
     return fflush (stream);
230fb9
 
230fb9
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
230fb9
+  /* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
 
230fb9
   clear_ungetc_buffer_preserving_position (stream);
230fb9
 
230fb9
diff --git a/lib/fpurge.c b/lib/fpurge.c
230fb9
index f313b22..a760c4d 100644
230fb9
--- a/lib/fpurge.c
230fb9
+++ b/lib/fpurge.c
230fb9
@@ -62,7 +62,8 @@ fpurge (FILE *fp)
230fb9
   /* Most systems provide FILE as a struct and the necessary bitmask in
230fb9
      <stdio.h>, because they need it for implementing getc() and putc() as
230fb9
      fast macros.  */
230fb9
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
+# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
230fb9
+  /* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
   fp->_IO_read_end = fp->_IO_read_ptr;
230fb9
   fp->_IO_write_ptr = fp->_IO_write_base;
230fb9
   /* Avoid memory leak when there is an active ungetc buffer.  */
230fb9
diff --git a/lib/freading.c b/lib/freading.c
230fb9
index 0512b19..2341577 100644
230fb9
--- a/lib/freading.c
230fb9
+++ b/lib/freading.c
230fb9
@@ -31,7 +31,8 @@ freading (FILE *fp)
230fb9
   /* Most systems provide FILE as a struct and the necessary bitmask in
230fb9
      <stdio.h>, because they need it for implementing getc() and putc() as
230fb9
      fast macros.  */
230fb9
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
+# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
230fb9
+  /* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
   return ((fp->_flags & _IO_NO_WRITES) != 0
230fb9
           || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
230fb9
               && fp->_IO_read_base != NULL));
230fb9
diff --git a/lib/fseeko.c b/lib/fseeko.c
230fb9
index 1c65d2a..1b1cc2f 100644
230fb9
--- a/lib/fseeko.c
230fb9
+++ b/lib/fseeko.c
230fb9
@@ -47,7 +47,8 @@ fseeko (FILE *fp, off_t offset, int whence)
230fb9
 #endif
230fb9
 
230fb9
   /* These tests are based on fpurge.c.  */
230fb9
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
230fb9
+  /* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
   if (fp->_IO_read_end == fp->_IO_read_ptr
230fb9
       && fp->_IO_write_ptr == fp->_IO_write_base
230fb9
       && fp->_IO_save_base == NULL)
230fb9
@@ -123,7 +124,8 @@ fseeko (FILE *fp, off_t offset, int whence)
230fb9
           return -1;
230fb9
         }
230fb9
 
230fb9
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
230fb9
+      /* GNU libc, BeOS, Haiku, Linux libc5 */
230fb9
       fp->_flags &= ~_IO_EOF_SEEN;
230fb9
       fp->_offset = pos;
230fb9
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
230fb9
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
230fb9
index 502d891..ea38ee2 100644
230fb9
--- a/lib/stdio-impl.h
230fb9
+++ b/lib/stdio-impl.h
230fb9
@@ -18,6 +18,12 @@
230fb9
    the same implementation of stdio extension API, except that some fields
230fb9
    have different naming conventions, or their access requires some casts.  */
230fb9
 
230fb9
+/* Glibc 2.28 made _IO_IN_BACKUP private.  For now, work around this
230fb9
+   problem by defining it ourselves.  FIXME: Do not rely on glibc
230fb9
+   internals.  */
230fb9
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
230fb9
+# define _IO_IN_BACKUP 0x100
230fb9
+#endif
230fb9
 
230fb9
 /* BSD stdio derived implementations.  */
230fb9
 
230fb9
-- 
230fb9
2.14.3
230fb9