From 96d93be957d6fcdea51eba1f31a45a24a898354a Mon Sep 17 00:00:00 2001
From: Rene Luria <rene.luria@infomaniak.com>
Date: Tue, 4 Dec 2018 22:53:08 +0100
Subject: [PATCH] Use __GNU_LIBRARY__ == 6 instead of 1

we do not patch lib/fflush.c because it would use obsolete libio
includes
---
 debian/changelog                                |  7 ++++
 debian/patches/gnulibrary-glibc-detection.patch | 54 +++++++++++++++++++++++++
 debian/patches/series                           |  1 +
 3 files changed, 62 insertions(+)
 create mode 100644 debian/patches/gnulibrary-glibc-detection.patch

diff --git a/debian/changelog b/debian/changelog
index 6b91304..9693114 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+gzip (1.9-2.2) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Use __GNU_LIBRARY__ == 6 instead of 1 to detect glibc (Closes: #915151)
+
+ -- Rene Luria <rene.luria@infomaniak.com>  Tue, 04 Dec 2018 22:52:20 +0100
+
 gzip (1.9-2.1) unstable; urgency=medium
 
   * Non-maintainer upload.
diff --git a/debian/patches/gnulibrary-glibc-detection.patch b/debian/patches/gnulibrary-glibc-detection.patch
new file mode 100644
index 0000000..1b1aa81
--- /dev/null
+++ b/debian/patches/gnulibrary-glibc-detection.patch
@@ -0,0 +1,54 @@
+Use __GNU_LIBRARY__ == 6 instead of 1 to detect glibc
+--- a/lib/fpurge.c
++++ b/lib/fpurge.c
+@@ -62,7 +62,7 @@
+   /* Most systems provide FILE as a struct and the necessary bitmask in
+      <stdio.h>, because they need it for implementing getc() and putc() as
+      fast macros.  */
+-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
++# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 6 /* GNU libc, BeOS, Haiku, Linux libc5 */
+   fp->_IO_read_end = fp->_IO_read_ptr;
+   fp->_IO_write_ptr = fp->_IO_write_base;
+   /* Avoid memory leak when there is an active ungetc buffer.  */
+--- a/lib/freading.c
++++ b/lib/freading.c
+@@ -31,7 +31,7 @@
+   /* Most systems provide FILE as a struct and the necessary bitmask in
+      <stdio.h>, because they need it for implementing getc() and putc() as
+      fast macros.  */
+-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
++# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 6 /* GNU libc, BeOS, Haiku, Linux libc5 */
+   return ((fp->_flags & _IO_NO_WRITES) != 0
+           || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
+               && fp->_IO_read_base != NULL));
+--- a/lib/fseeko.c
++++ b/lib/fseeko.c
+@@ -47,7 +47,7 @@
+ #endif
+ 
+   /* These tests are based on fpurge.c.  */
+-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
++#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 6 /* GNU libc, BeOS, Haiku, Linux libc5 */
+   if (fp->_IO_read_end == fp->_IO_read_ptr
+       && fp->_IO_write_ptr == fp->_IO_write_base
+       && fp->_IO_save_base == NULL)
+@@ -123,7 +123,7 @@
+           return -1;
+         }
+ 
+-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
++#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 6 /* GNU libc, BeOS, Haiku, Linux libc5 */
+       fp->_flags &= ~_IO_EOF_SEEN;
+       fp->_offset = pos;
+ #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+--- a/lib/fseterr.c
++++ b/lib/fseterr.c
+@@ -29,7 +29,7 @@
+   /* Most systems provide FILE as a struct and the necessary bitmask in
+      <stdio.h>, because they need it for implementing getc() and putc() as
+      fast macros.  */
+-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
++#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 6 /* GNU libc, BeOS, Haiku, Linux libc5 */
+   fp->_flags |= _IO_ERR_SEEN;
+ #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
diff --git a/debian/patches/series b/debian/patches/series
index 69f81e3..6adfd37 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,4 @@ gzip_reproducible_build.diff
 zgrep-syntax-error.diff
 0001-gzip-port-better-to-mingw.patch
 0001-gzip-port-better-to-mingw-again.patch
+gnulibrary-glibc-detection.patch
-- 
2.11.0

