bc2165c
diff -up texinfo-6.5.91/install-info/install-info.c.orig texinfo-6.5.91/install-info/install-info.c
bc2165c
--- texinfo-6.5.91/install-info/install-info.c.orig	2019-01-13 12:43:10.000000000 +0100
bc2165c
+++ texinfo-6.5.91/install-info/install-info.c	2019-01-14 09:31:45.322849494 +0100
bc2165c
@@ -19,6 +19,7 @@
e34f792
 #include <getopt.h>
21e91be
 #include <regex.h>
0415479
 #include <argz.h>
e34f792
+#include <zlib.h>
e34f792
 
0415479
 #define TAB_WIDTH 8
e34f792
 
bc2165c
@@ -681,15 +682,15 @@ The first time you invoke Info you start
e576f69
    
d267005
    Return either stdin reading the file, or a non-stdin pipe reading
d267005
    the output of the compression program.  */
e34f792
-FILE *
e34f792
+void *
e34f792
 open_possibly_compressed_file (char *filename,
e34f792
     void (*create_callback) (char *),
d267005
-    char **opened_filename, char **compression_program) 
bea7cd4
+    char **opened_filename, char **compression_program, int *is_pipe)
d267005
 {
e34f792
   char *local_opened_filename, *local_compression_program;
e34f792
   int nread;
0415479
   char data[13];
e34f792
-  FILE *f;
e34f792
+  gzFile *f;
e34f792
 
e34f792
   /* We let them pass NULL if they don't want this info, but it's easier
e34f792
      to always determine it.  */
bc2165c
@@ -697,48 +698,48 @@ open_possibly_compressed_file (char *fil
e34f792
     opened_filename = &local_opened_filename;
e34f792
 
e34f792
   *opened_filename = filename;
e34f792
-  f = fopen (*opened_filename, FOPEN_RBIN);
e34f792
+  f = gzopen (*opened_filename, FOPEN_RBIN);
e34f792
   if (!f)
e34f792
     {
e34f792
       *opened_filename = concat (filename, ".gz", "");
e34f792
-      f = fopen (*opened_filename, FOPEN_RBIN);
e34f792
+      f = gzopen (*opened_filename, FOPEN_RBIN);
e576f69
     }
e576f69
   if (!f)
e576f69
     {
e576f69
       free (*opened_filename);
e576f69
       *opened_filename = concat (filename, ".xz", "");
e576f69
-      f = fopen (*opened_filename, FOPEN_RBIN);
e576f69
+      f = gzopen (*opened_filename, FOPEN_RBIN);
e576f69
     }
e34f792
   if (!f)
e34f792
     {
e34f792
       free (*opened_filename);
e34f792
       *opened_filename = concat (filename, ".bz2", "");
e34f792
-      f = fopen (*opened_filename, FOPEN_RBIN);
e34f792
+      f = gzopen (*opened_filename, FOPEN_RBIN);
e34f792
     }
0415479
   if (!f)
0415479
     {
e1f2073
       free (*opened_filename);
e1f2073
       *opened_filename = concat (filename, ".lz", "");
e1f2073
-      f = fopen (*opened_filename, FOPEN_RBIN);
e1f2073
+      f = gzopen (*opened_filename, FOPEN_RBIN);
e1f2073
     }
e1f2073
   if (!f)
e1f2073
     {
0415479
      free (*opened_filename);
0415479
      *opened_filename = concat (filename, ".lzma", "");
0415479
-     f = fopen (*opened_filename, FOPEN_RBIN);
0415479
+     f = gzopen (*opened_filename, FOPEN_RBIN);
0415479
     }
e34f792
 #ifdef __MSDOS__
e576f69
   if (!f)
e576f69
     {
e576f69
       free (*opened_filename);
e576f69
       *opened_filename = concat (filename, ".igz", "");
e576f69
-      f = fopen (*opened_filename, FOPEN_RBIN);
e576f69
+      f = gzopen (*opened_filename, FOPEN_RBIN);
e576f69
     }
e576f69
   if (!f)
e576f69
     {
e576f69
       free (*opened_filename);
e576f69
       *opened_filename = concat (filename, ".inz", "");
e576f69
-      f = fopen (*opened_filename, FOPEN_RBIN);
e576f69
+      f = gzopen (*opened_filename, FOPEN_RBIN);
e576f69
     }
e576f69
 #endif /* __MSDOS__ */
d267005
   if (!f)
bc2165c
@@ -754,7 +755,7 @@ open_possibly_compressed_file (char *fil
d267005
           (*create_callback) (filename);
d267005
 
d267005
           /* And try opening it again.  */
d267005
-          f = fopen (*opened_filename, FOPEN_RBIN);
d267005
+          f = gzopen (*opened_filename, FOPEN_RBIN);
d267005
           if (!f)
d267005
             return 0;
d267005
         }
bc2165c
@@ -764,26 +765,26 @@ open_possibly_compressed_file (char *fil
e34f792
 
e34f792
   /* Read first few bytes of file rather than relying on the filename.
e34f792
      If the file is shorter than this it can't be usable anyway.  */
e34f792
-  nread = fread (data, sizeof (data), 1, f);
e34f792
-  if (nread != 1)
e34f792
+  nread = gzread (f, data, sizeof (data));
e34f792
+  if (nread != sizeof (data))
e34f792
     {
e34f792
-      if (nread == 0)
e34f792
+      if (nread >= 0)
bea7cd4
         {
bea7cd4
           /* Try to create the file if its empty. */
bea7cd4
-          if (feof (f) && create_callback)
bea7cd4
+          if (gzeof (f) && create_callback)
bea7cd4
             {
bea7cd4
-              if (fclose (f) != 0)
bea7cd4
+              if (gzclose (f) < 0)
bea7cd4
                 return 0; /* unknown error closing file */
bea7cd4
 
bea7cd4
               if (remove (filename) != 0)
bea7cd4
                 return 0; /* unknown error deleting file */
bea7cd4
 
bea7cd4
               (*create_callback) (filename);
bea7cd4
-              f = fopen (*opened_filename, FOPEN_RBIN);
bea7cd4
+              f = gzopen (*opened_filename, FOPEN_RBIN);
bea7cd4
               if (!f)
bea7cd4
                 return 0;
bea7cd4
-              nread = fread (data, sizeof (data), 1, f);
bea7cd4
-              if (nread == 0)
bea7cd4
+              nread = gzread (f, data, sizeof (data));
bea7cd4
+              if (nread <= 0)
bea7cd4
                 return 0;
bea7cd4
               goto determine_file_type; /* success */
bea7cd4
             }
bc2165c
@@ -854,35 +855,40 @@ determine_file_type:
d267005
     *compression_program = NULL;
d267005
 
d267005
   /* Seek back over the magic bytes.  */
d267005
-  if (fseek (f, 0, 0) < 0)
d267005
+  if (gzseek (f, 0, SEEK_SET) == -1)
d267005
     return 0;
e34f792
 
e34f792
   if (*compression_program)
d267005
     { /* It's compressed, so open a pipe.  */
e34f792
+      FILE *p;
d267005
       char *command = concat (*compression_program, " -d", "");
d267005
 
e34f792
-      if (fclose (f) < 0)
e34f792
+      if (gzclose (f) < 0)
d267005
         return 0;
d267005
-      f = freopen (*opened_filename, FOPEN_RBIN, stdin);
d267005
-      if (!f)
d267005
+      p = freopen (*opened_filename, FOPEN_RBIN, stdin);
d267005
+      if (!p)
d267005
         return 0;
e34f792
-      f = popen (command, "r");
d267005
-      if (!f)
e34f792
+      p = popen (command, "r");
d267005
+      if (!p)
d267005
         {
d267005
           /* Used for error message in calling code. */
d267005
           *opened_filename = command;
d267005
           return 0;
d267005
         }
d267005
+      else
d267005
+        *is_pipe = 1;
e34f792
+      return p;
e34f792
     }
e34f792
   else
d267005
     {
e34f792
-#if O_BINARY
e34f792
+#if 0 && O_BINARY
e34f792
       /* Since this is a text file, and we opened it in binary mode,
e34f792
          switch back to text mode.  */
e34f792
       f = freopen (*opened_filename, "r", f);
d267005
       if (! f)
d267005
 	return 0;
d267005
 #endif
d267005
+      *is_pipe = 0;
d267005
     }
d267005
 
d267005
   return f;
bc2165c
@@ -901,7 +907,8 @@ readfile (char *filename, int *sizep,
d267005
     void (*create_callback) (char *), char **opened_filename,
e34f792
     char **compression_program)
e34f792
 {
e34f792
-  FILE *f;
e34f792
+  void *f;
d267005
+  int pipe_p;
e34f792
   int filled = 0;
e34f792
   int data_size = 8192;
d267005
   char *data = xmalloc (data_size);
bc2165c
@@ -909,14 +916,20 @@ readfile (char *filename, int *sizep,
d267005
   /* If they passed the space for the file name to return, use it.  */
d267005
   f = open_possibly_compressed_file (filename, create_callback,
d267005
                                      opened_filename,
d267005
-                                     compression_program);
d267005
+                                     compression_program,
d267005
+                                     &pipe_p);
d267005
 
d267005
   if (!f)
d267005
     return 0;
e34f792
 
e34f792
   for (;;)
e34f792
     {
e34f792
-      int nread = fread (data + filled, 1, data_size - filled, f);
e34f792
+      int nread;
e576f69
+
e34f792
+      if (pipe_p)
e1f2073
+        nread = fread (data + filled, 1, data_size - filled, f);
e34f792
+      else
e1f2073
+        nread = gzread (f, data + filled, data_size - filled);
e34f792
       if (nread < 0)
d267005
         return 0;
e34f792
       if (nread == 0)
bc2165c
@@ -935,8 +948,10 @@ readfile (char *filename, int *sizep,
d267005
   /* We need to close the stream, since on some systems the pipe created
d267005
      by popen is simulated by a temporary file which only gets removed
d267005
      inside pclose.  */
d267005
-  if (f != stdin)
d267005
+  if (pipe_p)
e34f792
     pclose (f);
d267005
+  else
e34f792
+    gzclose (f);
e34f792
 
e34f792
   *sizep = filled;
e34f792
   return data;
bc2165c
diff -up texinfo-6.5.91/install-info/Makefile.in.orig texinfo-6.5.91/install-info/Makefile.in
bc2165c
--- texinfo-6.5.91/install-info/Makefile.in.orig	2019-01-14 09:32:31.729895052 +0100
bc2165c
+++ texinfo-6.5.91/install-info/Makefile.in	2019-01-14 09:32:52.574914503 +0100
bc2165c
@@ -218,7 +218,7 @@ am__installdirs = "$(DESTDIR)$(bindir)"
e576f69
 PROGRAMS = $(bin_PROGRAMS)
e576f69
 am_ginstall_info_OBJECTS = install-info.$(OBJEXT)
e576f69
 ginstall_info_OBJECTS = $(am_ginstall_info_OBJECTS)
e576f69
-ginstall_info_LDADD = $(LDADD)
e576f69
+ginstall_info_LDADD = $(LDADD) -lz
e576f69
 am__DEPENDENCIES_1 =
e576f69
 ginstall_info_DEPENDENCIES = $(top_builddir)/gnulib/lib/libgnu.a \
bc2165c
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)