70f88b
diff -up texinfo-6.4/install-info/install-info.c.orig texinfo-6.4/install-info/install-info.c
70f88b
--- texinfo-6.4/install-info/install-info.c.orig	2016-03-04 18:52:26.000000000 +0100
70f88b
+++ texinfo-6.4/install-info/install-info.c	2017-06-27 15:14:20.167998983 +0200
70f88b
@@ -22,6 +22,7 @@
70f88b
 #include <getopt.h>
70f88b
 #include <regex.h>
70f88b
 #include <argz.h>
70f88b
+#include <zlib.h>
70f88b
 
70f88b
 #define TAB_WIDTH 8
70f88b
 
70f88b
@@ -684,15 +685,15 @@ The first time you invoke Info you start
70f88b
    
70f88b
    Return either stdin reading the file, or a non-stdin pipe reading
70f88b
    the output of the compression program.  */
70f88b
-FILE *
70f88b
+void *
70f88b
 open_possibly_compressed_file (char *filename,
70f88b
     void (*create_callback) (char *),
70f88b
-    char **opened_filename, char **compression_program) 
70f88b
+    char **opened_filename, char **compression_program, int *is_pipe)
70f88b
 {
70f88b
   char *local_opened_filename, *local_compression_program;
70f88b
   int nread;
70f88b
   char data[13];
70f88b
-  FILE *f;
70f88b
+  gzFile *f;
70f88b
 
70f88b
   /* We let them pass NULL if they don't want this info, but it's easier
70f88b
      to always determine it.  */
70f88b
@@ -700,48 +701,48 @@ open_possibly_compressed_file (char *fil
70f88b
     opened_filename = &local_opened_filename;
70f88b
 
70f88b
   *opened_filename = filename;
70f88b
-  f = fopen (*opened_filename, FOPEN_RBIN);
70f88b
+  f = gzopen (*opened_filename, FOPEN_RBIN);
70f88b
   if (!f)
70f88b
     {
70f88b
       *opened_filename = concat (filename, ".gz", "");
70f88b
-      f = fopen (*opened_filename, FOPEN_RBIN);
70f88b
+      f = gzopen (*opened_filename, FOPEN_RBIN);
70f88b
     }
70f88b
   if (!f)
70f88b
     {
70f88b
       free (*opened_filename);
70f88b
       *opened_filename = concat (filename, ".xz", "");
70f88b
-      f = fopen (*opened_filename, FOPEN_RBIN);
70f88b
+      f = gzopen (*opened_filename, FOPEN_RBIN);
70f88b
     }
70f88b
   if (!f)
70f88b
     {
70f88b
       free (*opened_filename);
70f88b
       *opened_filename = concat (filename, ".bz2", "");
70f88b
-      f = fopen (*opened_filename, FOPEN_RBIN);
70f88b
+      f = gzopen (*opened_filename, FOPEN_RBIN);
70f88b
     }
70f88b
   if (!f)
70f88b
     {
70f88b
       free (*opened_filename);
70f88b
       *opened_filename = concat (filename, ".lz", "");
70f88b
-      f = fopen (*opened_filename, FOPEN_RBIN);
70f88b
+      f = gzopen (*opened_filename, FOPEN_RBIN);
70f88b
     }
70f88b
   if (!f)
70f88b
     {
70f88b
      free (*opened_filename);
70f88b
      *opened_filename = concat (filename, ".lzma", "");
70f88b
-     f = fopen (*opened_filename, FOPEN_RBIN);
70f88b
+     f = gzopen (*opened_filename, FOPEN_RBIN);
70f88b
     }
70f88b
 #ifdef __MSDOS__
70f88b
   if (!f)
70f88b
     {
70f88b
       free (*opened_filename);
70f88b
       *opened_filename = concat (filename, ".igz", "");
70f88b
-      f = fopen (*opened_filename, FOPEN_RBIN);
70f88b
+      f = gzopen (*opened_filename, FOPEN_RBIN);
70f88b
     }
70f88b
   if (!f)
70f88b
     {
70f88b
       free (*opened_filename);
70f88b
       *opened_filename = concat (filename, ".inz", "");
70f88b
-      f = fopen (*opened_filename, FOPEN_RBIN);
70f88b
+      f = gzopen (*opened_filename, FOPEN_RBIN);
70f88b
     }
70f88b
 #endif /* __MSDOS__ */
70f88b
   if (!f)
70f88b
@@ -757,7 +758,7 @@ open_possibly_compressed_file (char *fil
70f88b
           (*create_callback) (filename);
70f88b
 
70f88b
           /* And try opening it again.  */
70f88b
-          f = fopen (*opened_filename, FOPEN_RBIN);
70f88b
+          f = gzopen (*opened_filename, FOPEN_RBIN);
70f88b
           if (!f)
70f88b
             return 0;
70f88b
         }
70f88b
@@ -767,26 +768,26 @@ open_possibly_compressed_file (char *fil
70f88b
 
70f88b
   /* Read first few bytes of file rather than relying on the filename.
70f88b
      If the file is shorter than this it can't be usable anyway.  */
70f88b
-  nread = fread (data, sizeof (data), 1, f);
70f88b
-  if (nread != 1)
70f88b
+  nread = gzread (f, data, sizeof (data));
70f88b
+  if (nread != sizeof (data))
70f88b
     {
70f88b
-      if (nread == 0)
70f88b
+      if (nread >= 0)
70f88b
         {
70f88b
           /* Try to create the file if its empty. */
70f88b
-          if (feof (f) && create_callback)
70f88b
+          if (gzeof (f) && create_callback)
70f88b
             {
70f88b
-              if (fclose (f) != 0)
70f88b
+              if (gzclose (f) < 0)
70f88b
                 return 0; /* unknown error closing file */
70f88b
 
70f88b
               if (remove (filename) != 0)
70f88b
                 return 0; /* unknown error deleting file */
70f88b
 
70f88b
               (*create_callback) (filename);
70f88b
-              f = fopen (*opened_filename, FOPEN_RBIN);
70f88b
+              f = gzopen (*opened_filename, FOPEN_RBIN);
70f88b
               if (!f)
70f88b
                 return 0;
70f88b
-              nread = fread (data, sizeof (data), 1, f);
70f88b
-              if (nread == 0)
70f88b
+              nread = gzread (f, data, sizeof (data));
70f88b
+              if (nread <= 0)
70f88b
                 return 0;
70f88b
               goto determine_file_type; /* success */
70f88b
             }
70f88b
@@ -857,35 +858,40 @@ determine_file_type:
70f88b
     *compression_program = NULL;
70f88b
 
70f88b
   /* Seek back over the magic bytes.  */
70f88b
-  if (fseek (f, 0, 0) < 0)
70f88b
+  if (gzseek (f, 0, SEEK_SET) == -1)
70f88b
     return 0;
70f88b
 
70f88b
   if (*compression_program)
70f88b
     { /* It's compressed, so open a pipe.  */
70f88b
+      FILE *p;
70f88b
       char *command = concat (*compression_program, " -d", "");
70f88b
 
70f88b
-      if (fclose (f) < 0)
70f88b
+      if (gzclose (f) < 0)
70f88b
         return 0;
70f88b
-      f = freopen (*opened_filename, FOPEN_RBIN, stdin);
70f88b
-      if (!f)
70f88b
+      p = freopen (*opened_filename, FOPEN_RBIN, stdin);
70f88b
+      if (!p)
70f88b
         return 0;
70f88b
-      f = popen (command, "r");
70f88b
-      if (!f)
70f88b
+      p = popen (command, "r");
70f88b
+      if (!p)
70f88b
         {
70f88b
           /* Used for error message in calling code. */
70f88b
           *opened_filename = command;
70f88b
           return 0;
70f88b
         }
70f88b
+      else
70f88b
+        *is_pipe = 1;
70f88b
+      return p;
70f88b
     }
70f88b
   else
70f88b
     {
70f88b
-#if O_BINARY
70f88b
+#if 0 && O_BINARY
70f88b
       /* Since this is a text file, and we opened it in binary mode,
70f88b
          switch back to text mode.  */
70f88b
       f = freopen (*opened_filename, "r", f);
70f88b
       if (! f)
70f88b
 	return 0;
70f88b
 #endif
70f88b
+      *is_pipe = 0;
70f88b
     }
70f88b
 
70f88b
   return f;
70f88b
@@ -904,7 +910,8 @@ readfile (char *filename, int *sizep,
70f88b
     void (*create_callback) (char *), char **opened_filename,
70f88b
     char **compression_program)
70f88b
 {
70f88b
-  FILE *f;
70f88b
+  void *f;
70f88b
+  int pipe_p;
70f88b
   int filled = 0;
70f88b
   int data_size = 8192;
70f88b
   char *data = xmalloc (data_size);
70f88b
@@ -912,14 +919,20 @@ readfile (char *filename, int *sizep,
70f88b
   /* If they passed the space for the file name to return, use it.  */
70f88b
   f = open_possibly_compressed_file (filename, create_callback,
70f88b
                                      opened_filename,
70f88b
-                                     compression_program);
70f88b
+                                     compression_program,
70f88b
+                                     &pipe_p);
70f88b
 
70f88b
   if (!f)
70f88b
     return 0;
70f88b
 
70f88b
   for (;;)
70f88b
     {
70f88b
-      int nread = fread (data + filled, 1, data_size - filled, f);
70f88b
+      int nread;
70f88b
+
70f88b
+      if (pipe_p)
70f88b
+        nread = fread (data + filled, 1, data_size - filled, f);
70f88b
+      else
70f88b
+        nread = gzread (f, data + filled, data_size - filled);
70f88b
       if (nread < 0)
70f88b
         return 0;
70f88b
       if (nread == 0)
70f88b
@@ -938,8 +951,10 @@ readfile (char *filename, int *sizep,
70f88b
   /* We need to close the stream, since on some systems the pipe created
70f88b
      by popen is simulated by a temporary file which only gets removed
70f88b
      inside pclose.  */
70f88b
-  if (f != stdin)
70f88b
+  if (pipe_p)
70f88b
     pclose (f);
70f88b
+  else
70f88b
+    gzclose (f);
70f88b
 
70f88b
   *sizep = filled;
70f88b
   return data;
70f88b
diff -up texinfo-6.4/install-info/Makefile.in.orig texinfo-6.4/install-info/Makefile.in
70f88b
--- texinfo-6.4/install-info/Makefile.in.orig	2017-06-23 08:04:39.000000000 +0200
70f88b
+++ texinfo-6.4/install-info/Makefile.in	2017-06-27 15:14:20.167998983 +0200
70f88b
@@ -221,7 +221,7 @@ am__installdirs = "$(DESTDIR)$(bindir)"
70f88b
 PROGRAMS = $(bin_PROGRAMS)
70f88b
 am_ginstall_info_OBJECTS = install-info.$(OBJEXT)
70f88b
 ginstall_info_OBJECTS = $(am_ginstall_info_OBJECTS)
70f88b
-ginstall_info_LDADD = $(LDADD)
70f88b
+ginstall_info_LDADD = $(LDADD) -lz
70f88b
 am__DEPENDENCIES_1 =
70f88b
 ginstall_info_DEPENDENCIES = $(top_builddir)/gnulib/lib/libgnu.a \
70f88b
 	$(am__DEPENDENCIES_1)