Blame SOURCES/texinfo-4.12-zlib.patch

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