e1f2073
diff -up texinfo-5.1/install-info/install-info.c.orig texinfo-5.1/install-info/install-info.c
e1f2073
--- texinfo-5.1/install-info/install-info.c.orig	2013-03-09 03:21:55.000000000 +0100
e1f2073
+++ texinfo-5.1/install-info/install-info.c	2013-03-18 12:47:02.721136885 +0100
e576f69
@@ -22,6 +22,7 @@
e34f792
 #include <getopt.h>
21e91be
 #include <regex.h>
0415479
 #include <argz.h>
e34f792
+#include <zlib.h>
e34f792
 
0415479
 #define TAB_WIDTH 8
e34f792
 
e1f2073
@@ -670,7 +671,7 @@ The first time you invoke Info you start
e576f69
    
e576f69
    MAGIC number, not the filename.  */
e34f792
 
e34f792
-FILE *
e34f792
+void *
e34f792
 open_possibly_compressed_file (char *filename,
e34f792
     void (*create_callback) (char *),
e34f792
     char **opened_filename, char **compression_program, int *is_pipe) 
e1f2073
@@ -678,7 +679,7 @@ open_possibly_compressed_file (char *fil
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.  */
e1f2073
@@ -686,48 +687,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__ */
e576f69
    if (!f)
e1f2073
@@ -739,7 +740,7 @@ open_possibly_compressed_file (char *fil
e576f69
            /* And try opening it again.  */
e576f69
            free (*opened_filename);
e576f69
            *opened_filename = filename;
e576f69
-           f = fopen (*opened_filename, FOPEN_RBIN);
e576f69
+           f = gzopen (*opened_filename, FOPEN_RBIN);
e576f69
            if (!f)
e576f69
              pfatal_with_name (filename);
e576f69
          }
e1f2073
@@ -749,12 +750,12 @@ 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
       /* Empty files don't set errno, so we get something like
e34f792
          "install-info: No error for foo", which is confusing.  */
e34f792
-      if (nread == 0)
e34f792
+      if (nread >= 0)
e576f69
         fatal (_("%s: empty file"), *opened_filename);
e34f792
       pfatal_with_name (*opened_filename);
e34f792
     }
e1f2073
@@ -821,20 +822,22 @@ open_possibly_compressed_file (char *fil
e34f792
 
e34f792
   if (*compression_program)
e34f792
     { /* It's compressed, so fclose the file and then open a pipe.  */
e34f792
+      FILE *p;
e34f792
       char *command = concat (*compression_program," -cd <", *opened_filename);
e34f792
-      if (fclose (f) < 0)
e34f792
+      if (gzclose (f) < 0)
e34f792
         pfatal_with_name (*opened_filename);
e34f792
-      f = popen (command, "r");
e34f792
-      if (f)
e34f792
+      p = popen (command, "r");
e34f792
+      if (p)
e34f792
         *is_pipe = 1;
e34f792
       else
e34f792
         pfatal_with_name (command);
e34f792
+      return p;
e34f792
     }
e34f792
   else
e34f792
     { /* It's a plain file, seek back over the magic bytes.  */
e34f792
-      if (fseek (f, 0, 0) < 0)
e34f792
+      if (gzseek (f, 0, SEEK_SET) < 0)
e34f792
         pfatal_with_name (*opened_filename);
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);
e1f2073
@@ -859,7 +862,7 @@ readfile (char *filename, int *sizep,
e34f792
     char **compression_program)
e34f792
 {
e34f792
   char *real_name;
e34f792
-  FILE *f;
e34f792
+  void *f;
e34f792
   int pipe_p;
e34f792
   int filled = 0;
e34f792
   int data_size = 8192;
e1f2073
@@ -873,7 +876,12 @@ readfile (char *filename, int *sizep,
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)
e34f792
         pfatal_with_name (real_name);
e34f792
       if (nread == 0)
e1f2073
@@ -895,7 +903,7 @@ readfile (char *filename, int *sizep,
e34f792
   if (pipe_p)
e34f792
     pclose (f);
e34f792
   else
e34f792
-    fclose (f);
e34f792
+    gzclose (f);
e34f792
 
e34f792
   *sizep = filled;
e34f792
   return data;
e1f2073
diff -up texinfo-5.1/install-info/Makefile.in.orig texinfo-5.1/install-info/Makefile.in
e1f2073
--- texinfo-5.1/install-info/Makefile.in.orig	2013-03-12 23:56:43.000000000 +0100
e1f2073
+++ texinfo-5.1/install-info/Makefile.in	2013-03-18 12:42:57.165767101 +0100
e1f2073
@@ -171,7 +171,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 \
e576f69
 	$(am__DEPENDENCIES_1)