1 From 4af4a4a71827c0bc5e0ec67af23edef4f15cee8e Mon Sep 17 00:00:00 2001
2 From: Paul Eggert <eggert@cs.ucla.edu>
3 Date: Mon, 5 Mar 2018 10:56:29 -0800
4 Subject: fflush: adjust to glibc 2.28 libio.h removal
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Problem reported by Daniel P. Berrangé in:
10 https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
11 * lib/fbufmode.c (fbufmode):
12 * lib/fflush.c (clear_ungetc_buffer_preserving_position)
13 (disable_seek_optimization, rpl_fflush):
14 * lib/fpending.c (__fpending):
15 * lib/fpurge.c (fpurge):
16 * lib/freadable.c (freadable):
17 * lib/freadahead.c (freadahead):
18 * lib/freading.c (freading):
19 * lib/freadptr.c (freadptr):
20 * lib/freadseek.c (freadptrinc):
21 * lib/fseeko.c (fseeko):
22 * lib/fseterr.c (fseterr):
23 * lib/fwritable.c (fwritable):
24 * lib/fwriting.c (fwriting):
25 Check _IO_EOF_SEEN instead of _IO_ftrylockfile.
26 * lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]:
27 Define if not already defined.
29 ChangeLog | 23 +++++++++++++++++++++++
31 lib/fflush.c | 6 +++---
34 lib/freadable.c | 2 +-
35 lib/freadahead.c | 2 +-
38 lib/freadseek.c | 2 +-
41 lib/fwritable.c | 2 +-
43 lib/stdio-impl.h | 6 ++++++
44 15 files changed, 45 insertions(+), 16 deletions(-)
46 diff --git a/lib/fflush.c b/lib/fflush.c
47 index 983ade0..a6edfa1 100644
54 -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
55 +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
57 /* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */
59 @@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp)
63 -#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
64 +#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
66 # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
67 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
68 @@ -148,7 +148,7 @@ rpl_fflush (FILE *stream)
69 if (stream == NULL || ! freading (stream))
70 return fflush (stream);
72 -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
73 +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
75 clear_ungetc_buffer_preserving_position (stream);
77 diff --git a/lib/fpurge.c b/lib/fpurge.c
78 index b1d417c..3aedcc3 100644
81 @@ -62,7 +62,7 @@ fpurge (FILE *fp)
82 /* Most systems provide FILE as a struct and the necessary bitmask in
83 <stdio.h>, because they need it for implementing getc() and putc() as
85 -# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
86 +# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
87 fp->_IO_read_end = fp->_IO_read_ptr;
88 fp->_IO_write_ptr = fp->_IO_write_base;
89 /* Avoid memory leak when there is an active ungetc buffer. */
90 diff --git a/lib/freading.c b/lib/freading.c
91 index 73c28ac..c24d0c8 100644
94 @@ -31,7 +31,7 @@ freading (FILE *fp)
95 /* Most systems provide FILE as a struct and the necessary bitmask in
96 <stdio.h>, because they need it for implementing getc() and putc() as
98 -# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
99 +# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
100 return ((fp->_flags & _IO_NO_WRITES) != 0
101 || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
102 && fp->_IO_read_base != NULL));
103 diff --git a/lib/fseeko.c b/lib/fseeko.c
104 index 0101ab5..193f4e8 100644
107 @@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int whence)
110 /* These tests are based on fpurge.c. */
111 -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
112 +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
113 if (fp->_IO_read_end == fp->_IO_read_ptr
114 && fp->_IO_write_ptr == fp->_IO_write_base
115 && fp->_IO_save_base == NULL)
116 @@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int whence)
120 -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
121 +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
122 fp->_flags &= ~_IO_EOF_SEEN;
124 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
125 diff --git a/lib/fseterr.c b/lib/fseterr.c
126 index 82649c3..adb6372 100644
129 @@ -29,7 +29,7 @@ fseterr (FILE *fp)
130 /* Most systems provide FILE as a struct and the necessary bitmask in
131 <stdio.h>, because they need it for implementing getc() and putc() as
133 -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
134 +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
135 fp->_flags |= _IO_ERR_SEEN;
136 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
137 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
138 diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
139 index 78d896e..05c5752 100644
140 --- a/lib/stdio-impl.h
141 +++ b/lib/stdio-impl.h
143 the same implementation of stdio extension API, except that some fields
144 have different naming conventions, or their access requires some casts. */
146 +/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
147 + problem by defining it ourselves. FIXME: Do not rely on glibc
149 +#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
150 +# define _IO_IN_BACKUP 0x100
153 /* BSD stdio derived implementations. */