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

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