Blame SOURCES/texinfo-4.12-zlib.patch

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