Add support to read compressed info pages using libzio. --- texinfo/install-info/install-info.c +++ texinfo/install-info/install-info.c @@ -21,6 +21,7 @@ #include #include #include +#include #define TAB_WIDTH 8 @@ -641,7 +642,7 @@ The first time you invoke Info you start off looking at this node.\n\ FILE * open_possibly_compressed_file (char *filename, void (*create_callback) (char *), - char **opened_filename, char **compression_program, int *is_pipe) + char **opened_filename, char **compression_program) { char *local_opened_filename, *local_compression_program; int nread; @@ -654,22 +655,22 @@ open_possibly_compressed_file (char *filename, opened_filename = &local_opened_filename; *opened_filename = filename; - f = fopen (*opened_filename, FOPEN_RBIN); + f = fzopen (*opened_filename, FOPEN_RBIN); if (!f) { *opened_filename = concat (filename, ".gz", ""); - f = fopen (*opened_filename, FOPEN_RBIN); + f = fzopen (*opened_filename, FOPEN_RBIN); if (!f) { free (*opened_filename); *opened_filename = concat (filename, ".bz2", ""); - f = fopen (*opened_filename, FOPEN_RBIN); + f = fzopen (*opened_filename, FOPEN_RBIN); } if (!f) { free (*opened_filename); *opened_filename = concat (filename, ".lzma", ""); - f = fopen (*opened_filename, FOPEN_RBIN); + f = fzopen (*opened_filename, FOPEN_RBIN); } #ifdef __MSDOS__ @@ -677,13 +678,13 @@ open_possibly_compressed_file (char *filename, { free (*opened_filename); *opened_filename = concat (filename, ".igz", ""); - f = fopen (*opened_filename, FOPEN_RBIN); + f = fzopen (*opened_filename, FOPEN_RBIN); } if (!f) { free (*opened_filename); *opened_filename = concat (filename, ".inz", ""); - f = fopen (*opened_filename, FOPEN_RBIN); + f = fzopen (*opened_filename, FOPEN_RBIN); } #endif if (!f) @@ -695,7 +696,7 @@ open_possibly_compressed_file (char *filename, /* And try opening it again. */ free (*opened_filename); *opened_filename = filename; - f = fopen (*opened_filename, FOPEN_RBIN); + f = fzopen (*opened_filename, FOPEN_RBIN); if (!f) pfatal_with_name (filename); } @@ -704,6 +705,7 @@ open_possibly_compressed_file (char *filename, } } +#if 0 /* Read first few bytes of file rather than relying on the filename. If the file is shorter than this it can't be usable anyway. */ nread = fread (data, sizeof (data), 1, f); @@ -778,6 +780,7 @@ open_possibly_compressed_file (char *filename, #endif *is_pipe = 0; } +#endif return f; } @@ -797,7 +800,6 @@ readfile (char *filename, int *sizep, { char *real_name; FILE *f; - int pipe_p; int filled = 0; int data_size = 8192; char *data = xmalloc (data_size); @@ -806,7 +808,7 @@ readfile (char *filename, int *sizep, f = open_possibly_compressed_file (filename, create_callback, opened_filename ? opened_filename : &real_name, - compression_program, &pipe_p); + compression_program); for (;;) { @@ -829,10 +831,7 @@ readfile (char *filename, int *sizep, /* We need to close the stream, since on some systems the pipe created by popen is simulated by a temporary file which only gets removed inside pclose. */ - if (pipe_p) - pclose (f); - else - fclose (f); + fclose (f); *sizep = filled; return data; @@ -846,19 +845,13 @@ readfile (char *filename, int *sizep, static void output_dirfile (char *dirfile, int dir_nlines, struct line_data *dir_lines, int n_entries_to_add, struct spec_entry *entries_to_add, - struct spec_section *input_sections, char *compression_program) + struct spec_section *input_sections) { int n_entries_added = 0; int i; FILE *output; - if (compression_program) - { - char *command = concat (compression_program, ">", dirfile); - output = popen (command, "w"); - } - else - output = fopen (dirfile, "w"); + output = fopen (dirfile, "w"); if (!output) { @@ -969,10 +962,7 @@ output_dirfile (char *dirfile, int dir_nlines, struct line_data *dir_lines, /* Some systems, such as MS-DOS, simulate pipes with temporary files. On those systems, the compressor actually gets run inside pclose, so we must call pclose. */ - if (compression_program) - pclose (output); - else - fclose (output); + fclose (output); } /* Parse the input to find the section names and the entry names it @@ -2542,7 +2532,7 @@ There is NO WARRANTY, to the extent permitted by law.\n"), else output_dirfile (opened_dirfilename, dir_nlines, dir_lines, n_entries_to_add, entries_to_add, - input_sections, compression_program); + input_sections); xexit (0); return 0; /* Avoid bogus warnings. */ --- texinfo/install-info/Makefile.am +++ texinfo/install-info/Makefile.am @@ -28,4 +28,4 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/gnulib/lib \ -I$(top_builddir)/gnulib/lib \ -DLOCALEDIR=\"$(localedir)\" -LDADD = ../lib/libtxi.a $(top_builddir)/gnulib/lib/libgnu.a $(LIBINTL) +LDADD = ../lib/libtxi.a $(top_builddir)/gnulib/lib/libgnu.a $(LIBINTL) -lzio