OSDN Git Service

compress .fmt files to .gz via zlib.
authormaqiyuan <maqiyuan@users.sourceforge.jp>
Wed, 14 May 2014 15:48:29 +0000 (23:48 +0800)
committermaqiyuan <maqiyuan@users.sourceforge.jp>
Wed, 14 May 2014 15:48:29 +0000 (23:48 +0800)
src/texsourc/itex.c
src/texsourc/makefile
src/texsourc/openinou.c
src/texsourc/texd.h
src/texsourc/texmf.h
src/texsourc/yandytex.c
src/texsourc/yandytex.h

index 00dd9a4..32b1539 100644 (file)
@@ -2493,11 +2493,19 @@ lab1:
 
       if (!load_fmt_file ())
       {
+#ifdef COMPACTFORMAT
+        gzclose(gz_fmt_file);
+#else
         w_close(fmt_file);
+#endif
         goto lab9999;
       }
 
+#ifdef COMPACTFORMAT
+      gzclose(gz_fmt_file);
+#else
       w_close(fmt_file);
+#endif
 
       while ((cur_input.loc_field < cur_input.limit_field) &&
           (buffer[cur_input.loc_field] == ' '))
@@ -3608,6 +3616,7 @@ void store_fmt_file (void)
   print_int(dyn_used);
 
   k = active_base;
+
   do
     {
       j = k;
@@ -3880,12 +3889,17 @@ lab32:
       dump_int(trie_used[k]);
     }
   }
+
   dump_int(interaction);
   dump_int(format_ident);
   dump_int(ENDFMTCHECKSUM); /* magic checksum end of FMT file --- change ??? */ 
   tracing_stats = 0;
 
+#ifdef COMPACTFORMAT
+  gzclose(gz_fmt_file);
+#else
   w_close(fmt_file);
+#endif
 }
 #endif /* INITEX */
 
index 0a5c7c0..c8cd8d6 100644 (file)
@@ -25,7 +25,7 @@ RC = rc
 # Release version
 # CFLAGS=/c /Ge /Gy /Gf /Ox /W4 /DMSDOS /DTeX /DPHARLAP /DNDEBUG /Ilib /YX
 CFLAGS=/nologo /c /MT /GF /Gy /Ox /W4 /DMSDOS /DTeX /DPHARLAP /DNDEBUG \
-       /I"kpathsea" /I"libharu/include" /I"libharu/win32/include"
+       /I"kpathsea" /I"libharu/include" /I"libharu/win32/include" /I"zlib"
 # Debugging version
 # CFLAGS=/c /Ge /Gy /Gf /Od /Zi /W4 /DMSDOS /DTeX /DPHARLAP /Ilib /YX
 
index 7cef4f8..f570747 100644 (file)
@@ -263,6 +263,10 @@ bool open_input (FILE **f, path_constant_type path_index, char *fopen_mode)
       {
         format_file = xstrdup((char *) name_of_file + 1);
       }
+
+#ifdef COMPACTFORMAT
+      gz_fmt_file = gzdopen(fileno(*f), "rbR9");
+#endif
     }
     else if (strstr((char *)name_of_file+1, ".tfm") != NULL)
     {
@@ -425,6 +429,13 @@ bool open_output (FILE **f, char *fopen_mode)
     }
   }
 
+#ifdef COMPACTFORMAT
+  if (strstr((char *) name_of_file + 1, ".fmt") != NULL)
+  {
+    gz_fmt_file = gzdopen(fileno(*f), "wbR9");
+  }
+#endif
+
   if (strstr((char *) name_of_file + 1, ".dvi") != NULL)
   {
     if (qualified(name_of_file + 1))
index 7a10615..d95117d 100644 (file)
@@ -22,6 +22,7 @@
 /* make hash table htwo_halves == 32 bit instead of two_halves == 64 bit */
 /* increase trie_op_size from 751 to 3001 96/Oct/12 */
 #define INCREASETRIEOP
+#define COMPACTFORMAT
 
 
 /* With old PharLap linker it was important to avoid large fixed allocation */
@@ -976,6 +977,7 @@ EXTERN halfword after_token;
 EXTERN bool long_help_seen;
 EXTERN str_number format_ident;
 EXTERN word_file fmt_file;
+EXTERN gzFile gz_fmt_file;
 EXTERN integer ready_already;
 
 EXTERN alpha_file write_file[16]; /* hard wired limit in TeX */
index b44e3fc..aa035a4 100644 (file)
@@ -50,6 +50,7 @@ extern bool input_line (FILE *);
 #define w_open_out    b_open_out
 #define b_close       a_close
 #define w_close       a_close
+#define gz_w_close    gzclose
 
 /* sec 0241 */
 #define fix_date_and_time() get_date_and_time (&(tex_time), &(day), &(month), &(year))
index be5c2d3..39ea2d7 100644 (file)
 #define dump_default_length format_default_length
 #define main_program        texbody
 #define edit_value          tex_edit_value
-#define edit_var            "UFYFEJU" /* shrouded 93/Nov/20 */
+#define edit_var            "UFYFEJU"
 
 
-extern char * replacement[];    /* pointers to replacement strings */
+extern char * replacement[];
 
 #ifdef FUNNY_CORE_DUMP
   void funny_core_dump (void);
@@ -898,7 +898,11 @@ int do_dump (char *p, int item_size, int nitems, FILE *out_file)
   swap_items (p, nitems, item_size);
 #endif
 
+#ifdef COMPACTFORMAT
+  if (gzwrite(gz_fmt_file, p, (item_size * nitems)) != (item_size * nitems))
+#else
   if ((int) fwrite (p, item_size, nitems, out_file) != nitems)
+#endif
   {
     show_line("\n", 0);
     sprintf(log_line, "! Could not write %d %d-byte item%s.\n",
@@ -920,7 +924,11 @@ int do_dump (char *p, int item_size, int nitems, FILE *out_file)
 /* Here is the dual of the writing routine.  */
 int do_undump (char *p, int item_size, int nitems, FILE *in_file)
 {
+#ifdef COMPACTFORMAT
+  if (gzread(gz_fmt_file, (void *) p, (unsigned int) (item_size * nitems)) <= 0)
+#else
   if ((int) fread((void *) p, item_size, nitems, in_file) != nitems)
+#endif
   {
     show_line("\n", 0);
     sprintf(log_line, "! Could not read %d %d-byte item%s.\n",
index 077afec..5769fff 100644 (file)
@@ -54,6 +54,7 @@
 #else
   #include <unistd.h>
 #endif
+#include <zlib.h>
 #include "hpdf.h"
 #include "hpdf_utils.h"
 
@@ -100,9 +101,9 @@ typedef enum
 #define fabs(x)  ((x) >= 0.0 ? (x) : -(x))
 #define PATHMAX  PATH_MAX
 #define toint(x) ((integer) (x))
-#define a_open_in(f,p) open_input (&(f), p, FOPEN_R_MODE)
+#define a_open_in(f, p) open_input (&(f), p, FOPEN_R_MODE)
 #define a_open_out(f)   open_output (&(f), FOPEN_W_MODE)
-#define a_close(f)     check_fclose (f)
+#define a_close(f)         check_fclose (f)
 
 #define MAXLINE 256 // for log_line buffer