File texinfo-zlib.patch of Package texinfo

From: Werner Fink <werner@suse.de>
Date: 2004-04-21 13:02:06 +0200
Subject: Use libzio to avoid spawning external programs in install-info
References:
Upstream: never

This commit adds compression logic to texinfo, to handle the decompression
of info files via zio instead of spawning external programs.
---
 install-info/Makefile.in    |  2 +-
 install-info/install-info.c | 43 ++++++++++++++++++++++++++-----------
 2 files changed, 32 insertions(+), 13 deletions(-)

Index: texinfo-7.3/install-info/Makefile.in
===================================================================
--- texinfo-7.3.orig/install-info/Makefile.in
+++ texinfo-7.3/install-info/Makefile.in
@@ -284,7 +284,7 @@ am__installdirs = "$(DESTDIR)$(bindir)"
 PROGRAMS = $(bin_PROGRAMS)
 am_ginstall_info_OBJECTS = install-info.$(OBJEXT)
 ginstall_info_OBJECTS = $(am_ginstall_info_OBJECTS)
-ginstall_info_LDADD = $(LDADD)
+ginstall_info_LDADD = $(LDADD) -lzio
 am__DEPENDENCIES_1 =
 ginstall_info_DEPENDENCIES = $(top_builddir)/gnulib/lib/libgnu.a \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
Index: texinfo-7.3/install-info/install-info.c
===================================================================
--- texinfo-7.3.orig/install-info/install-info.c
+++ texinfo-7.3/install-info/install-info.c
@@ -26,6 +26,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <zio.h>
 
 
 /* From gnulib */
@@ -838,23 +839,42 @@ determine_file_type:
 
   if (*compression_program)
     {
-      /* Redirect stdin to the file and fork the decompression process
-         reading from stdin.  This allows shell metacharacters in filenames. */
+      FILE *fz = f;
 
       if (fclose (f) < 0)
         return 0;
-      if (!freopen (*opened_filename, FOPEN_RBIN, stdin))
-        return 0;
-      char *command = concat (*compression_program, " -d", "");
-      f = popen (command, "r");
-      fclose (stdin);
-      if (!f)
+
+      if (**compression_program == 'g' || **compression_program == 'z')
+        fz = fzopen (*opened_filename, "rg");
+      if (**compression_program == 'b')
+        fz = fzopen (*opened_filename, "rb");
+      if (**compression_program == 'Z')
+        fz = fzopen (*opened_filename, "rZ");
+      if (**compression_program == 'l')
+        fz = fzopen (*opened_filename, "rl");
+      if (**compression_program == 'x')
+        fz = fzopen (*opened_filename, "rx");
+      if (!fz)
         {
-          /* Used for error message in calling code. */
-          *opened_filename = command;
-          return 0;
+          /* Redirect stdin to the file and fork the decompression process
+             reading from stdin.  This allows shell metacharacters in filenames. */
+
+          FILE *f2 = freopen (*opened_filename, FOPEN_RBIN, stdin);
+          if (!f2)
+            return 0;
+          char *command = concat (*compression_program, " -d", "");
+          f = popen (command, "r");
+          fclose (f2);
+          if (!f)
+            {
+              /* Used for error message in calling code. */
+              *opened_filename = command;
+              return 0;
+            }
+          free (command);
         }
-      free (command);
+      else
+        f = fz;
     }
   else
     {
openSUSE Build Service is sponsored by