OSDN Git Service

redesigned backends.
authormaqiyuan <maqiyuan@users.sourceforge.jp>
Sun, 1 Jun 2014 16:44:06 +0000 (00:44 +0800)
committermaqiyuan <maqiyuan@users.sourceforge.jp>
Sun, 1 Jun 2014 16:44:06 +0000 (00:44 +0800)
src/texsourc/itex.c
src/texsourc/local.c
src/texsourc/tex3.c
src/texsourc/tex4.c
src/texsourc/tex8.c
src/texsourc/tex9.c
src/texsourc/texd.h
src/texsourc/texmf.h
src/texsourc/yandytex.c
src/texsourc/yandytex.h

index 30b04b1..2d3a229 100644 (file)
@@ -2440,7 +2440,7 @@ int texbody (void)
   if (cs_token_flag + undefined_control_sequence > max_halfword)
     bad = 21;
 
-  if (format_default_length > PATHMAX)
+  if (format_default_length > PATH_MAX)
     bad = 31;
 
   if (max_halfword < (mem_top - mem_min) / 2)
index 5614c6d..c6dbddf 100644 (file)
@@ -2710,9 +2710,11 @@ int analyze_flag (int c, char *optarg)
           format_spec = xstrdup(optarg);
 
         if (!strcmp(format_spec, "pdf"))
-          pdf_output_flag = true;
+          pdf_output_flag = out_pdf_flag;
         else if (!strcmp(format_spec, "dvi"))
-          pdf_output_flag = false;
+          pdf_output_flag = out_dvi_flag;
+        else if (!strcmp(format_spec, "xdv"))
+          pdf_output_flag = out_xdv_flag;
         else
         {
           sprintf(log_line, "ERROR: Do not understand argument value `%s'\n", format_spec);
@@ -2828,7 +2830,7 @@ int read_command_line (int ac, char **av)
 
 int init_commands (int ac, char **av)
 {
-  pdf_output_flag   = false;
+  pdf_output_flag   = out_dvi_flag;
   is_initex         = false; 
   allow_patterns    = false;
   reset_exceptions  = false;
index 0baadff..51da359 100644 (file)
@@ -1664,7 +1664,7 @@ void pack_file_name_(str_number n, str_number a, str_number e)
     c = str_pool[j];
     incr(k);
 
-    if (k <= PATHMAX)
+    if (k <= PATH_MAX)
       name_of_file[k] = xchr[c];
   }
 
@@ -1673,7 +1673,7 @@ void pack_file_name_(str_number n, str_number a, str_number e)
     c = str_pool[j];
     incr(k);
 
-    if (k <= PATHMAX)
+    if (k <= PATH_MAX)
       name_of_file[k] = xchr[c];
   }
 
@@ -1682,20 +1682,20 @@ void pack_file_name_(str_number n, str_number a, str_number e)
     c = str_pool[j];
     incr(k);
 
-    if (k <= PATHMAX)
+    if (k <= PATH_MAX)
       name_of_file[k] = xchr[c];
   }
 
-  if (k < PATHMAX)
+  if (k < PATH_MAX)
     name_length = k;
   else
-    name_length = PATHMAX - 1;
+    name_length = PATH_MAX - 1;
 
 /*  pad it out with spaces ... what for ? in case we modify and forget  ? */
-  for (k = name_length + 1; k <= PATHMAX; k++)
+  for (k = name_length + 1; k <= PATH_MAX; k++)
     name_of_file[k] = ' ';
 
-  name_of_file[PATHMAX] = '\0';    /* paranoia 94/Mar/24 */
+  name_of_file[PATH_MAX] = '\0';    /* paranoia 94/Mar/24 */
 
   {
     name_of_file [name_length+1] = '\0';
@@ -1719,8 +1719,8 @@ void pack_buffered_name_(small_number n, integer a, integer b)
   ASCII_code c;
   integer j;
 
-  if (n + b - a + 5 > PATHMAX)
-    b = a + PATHMAX - n - 5;
+  if (n + b - a + 5 > PATH_MAX)
+    b = a + PATH_MAX - n - 5;
 
   k = 0;
 
@@ -1730,7 +1730,7 @@ void pack_buffered_name_(small_number n, integer a, integer b)
     c = xord[TEX_format_default[j]];
     incr(k);
 
-    if (k <= PATHMAX)
+    if (k <= PATH_MAX)
       name_of_file[k] = xchr[c];
   }
 /*  This loop kicks in when we want a specififed format name */
@@ -1739,7 +1739,7 @@ void pack_buffered_name_(small_number n, integer a, integer b)
     c = buffer[j];
     incr(k);
 
-    if (k <= PATHMAX)
+    if (k <= PATH_MAX)
       name_of_file[k] = xchr[c];
   }
 
@@ -1749,20 +1749,20 @@ void pack_buffered_name_(small_number n, integer a, integer b)
     c = xord[TEX_format_default[j]];
     incr(k);
 
-    if (k <= PATHMAX)
+    if (k <= PATH_MAX)
       name_of_file[k] = xchr[c];
   }
 
-  if (k < PATHMAX)
+  if (k < PATH_MAX)
     name_length = k;
   else
-    name_length = PATHMAX - 1;
+    name_length = PATH_MAX - 1;
 
  /*  pad it out with spaces ... what for ? */
-  for (k = name_length + 1; k <= PATHMAX; k++)
+  for (k = name_length + 1; k <= PATH_MAX; k++)
     name_of_file[k]= ' ';
 
-  name_of_file[PATHMAX] = '\0';    /* paranoia 94/Mar/24 */
+  name_of_file[PATH_MAX] = '\0';    /* paranoia 94/Mar/24 */
 }
 /* sec 0525 */
 str_number make_name_string (void)
@@ -2173,7 +2173,7 @@ void start_input(void)
     if ((cur_ext != 335) && a_open_in(input_file[cur_input.index_field], TEXINPUTPATH))
       goto lab30;
 
-    if ((cur_ext != 785) && (name_length + 5 < PATHMAX))
+    if ((cur_ext != 785) && (name_length + 5 < PATH_MAX))
     {
       name_of_file[name_length + 1] = '.';
       name_of_file[name_length + 2] = 't';
index 99f7813..5104767 100644 (file)
@@ -1293,10 +1293,16 @@ lab30:;
 }
 void ship_out_(halfword p)
 {
-  if (pdf_output_flag)
-    pdf_ship_out(p);
-  else
-    dvi_ship_out_(p);
+  switch (pdf_output_flag)
+  {
+    case out_pdf_flag:
+      pdf_ship_out(p);
+      break;
+    case out_dvi_flag:
+    case out_xdv_flag:
+      dvi_ship_out_(p);
+      break;
+  }
 }
 /* sec 0645 */
 void scan_spec_(group_code c, boolean three_codes)
index 7189775..c8cd06b 100644 (file)
@@ -957,7 +957,7 @@ void open_or_close_in (void)
 
     if ((cur_ext != 335) && a_open_in(read_file[n], TEXINPUTPATH))
       read_open[n] = 1;
-    else if ((cur_ext != 785) && (name_length + 5 < PATHMAX))
+    else if ((cur_ext != 785) && (name_length + 5 < PATH_MAX))
     {
       strncpy((char *) name_of_file + name_length + 1, ".tex ", 5);
       name_length = name_length + 4;
index 46a7c4d..3df0872 100644 (file)
@@ -309,139 +309,140 @@ void close_files_and_terminate (void)
   } /* end of if (log_opened) */ 
 #endif /* STAT */
 
-  if (pdf_output_flag)
+  switch (pdf_output_flag)
   {
-    if (total_pages == 0)
-    {
-      print_nl("No pages of output.");
-    }
-    else
-    {
-      HPDF_SaveToFile(yandy_pdf, pdf_file_name);
-      
-      print_nl("Output written on ");
-
-      if (full_file_name_flag && pdf_file_name != NULL)
-        print_char_string((unsigned char *) pdf_file_name);
-      else
-        slow_print(output_file_name);
-
-      print_string(" (");
-      print_int(total_pages);
-      print_string(" page");
-
-      if (total_pages != 1)
-        print_char('s');
-
-      //print_string(", ");
-      //print_int(dvi_offset + dvi_ptr);
-      //print_int(yandy_pdf->mmgr->mpool->used_size);
-      //print_string(" bytes).");
-      print_string(").");
-      b_close(dvi_file);
-    }
-
-    HPDF_Free(yandy_pdf);
-    font_name_hash_free(gentbl);
-  }
-  else
-  {
-    while (cur_s > -1)
-    {
-      if (cur_s > 0) 
-        dvi_out(142);
-      else
+    case out_pdf_flag:
       {
-        dvi_out(eop);
-        incr(total_pages);
-      }
-
-      decr(cur_s);
-    }
-
-    if (total_pages == 0)
-      print_nl("No pages of output.");
-    else
-    {
-      dvi_out(post);
-      dvi_four(last_bop);
-      last_bop = dvi_offset + dvi_ptr - 5;
-      dvi_four(25400000L);
-      dvi_four(473628672L);
-      prepare_mag();
-      dvi_four(mag);
-      dvi_four(max_v);
-      dvi_four(max_h);
-      dvi_out(max_push / 256);
-      dvi_out(max_push % 256);
-
-      if (total_pages >= 65536)    // 99/Oct/10 dvi_t 16 bit problem
-      {
-        sprintf(log_line, "\nWARNING: page count (dvi_t) in DVI file will be %ld not %ld\n",
-          (total_pages % 65536), total_pages);
-
-        if (log_opened)
-          (void) fputs (log_line, log_file);
-
-        show_line(log_line, 1);
-      }
+        if (total_pages == 0)
+        {
+          print_nl("No pages of output.");
+        }
+        else
+        {
+          HPDF_SaveToFile(yandy_pdf, pdf_file_name);
+      
+          print_nl("Output written on ");
 
-      dvi_out((total_pages / 256) % 256);
-      dvi_out(total_pages % 256);
+          if (full_file_name_flag && pdf_file_name != NULL)
+            print_char_string((unsigned char *) pdf_file_name);
+          else
+            slow_print(output_file_name);
 
-      if (show_fonts_used && log_opened)     /* 97/Dec/24 */
-        show_font_info();           // now in local.c
+          print_string(" (");
+          print_int(total_pages);
+          print_string(" page");
 
-      while (font_ptr > 0)
-      {
-        if (font_used[font_ptr])
-          dvi_font_def(font_ptr);
+          if (total_pages != 1)
+            print_char('s');
+          
+          print_string(").");
+        }
 
-        decr(font_ptr);
+        HPDF_Free(yandy_pdf);
+        font_name_hash_free(gentbl);
       }
-
-      dvi_out(post_post);
-      dvi_four(last_bop);
-      dvi_out(id_byte);
-      k = 4 + ((dvi_buf_size - dvi_ptr) % 4);
-
-      while (k > 0)
+      break;
+    case out_dvi_flag:
+    case out_xdv_flag:
       {
-        dvi_out(223);
-        decr(k);
-      }
+        while (cur_s > -1)
+        {
+          if (cur_s > 0) 
+            dvi_out(142);
+          else
+          {
+            dvi_out(eop);
+            incr(total_pages);
+          }
+
+          decr(cur_s);
+        }
 
-      if (trace_flag) /* 93/Dec/28 - bkph */
-      {
-        sprintf(log_line, "\ndviwrite %d", dvi_gone);
-        show_line(log_line, 0);
+        if (total_pages == 0)
+          print_nl("No pages of output.");
+        else
+        {
+          dvi_out(post);
+          dvi_four(last_bop);
+          last_bop = dvi_offset + dvi_ptr - 5;
+          dvi_four(25400000L);
+          dvi_four(473628672L);
+          prepare_mag();
+          dvi_four(mag);
+          dvi_four(max_v);
+          dvi_four(max_h);
+          dvi_out(max_push / 256);
+          dvi_out(max_push % 256);
+
+          if (total_pages >= 65536)    // 99/Oct/10 dvi_t 16 bit problem
+          {
+            sprintf(log_line, "\nWARNING: page count (dvi_t) in DVI file will be %ld not %ld\n",
+              (total_pages % 65536), total_pages);
+
+            if (log_opened)
+              (void) fputs (log_line, log_file);
+
+            show_line(log_line, 1);
+          }
+
+          dvi_out((total_pages / 256) % 256);
+          dvi_out(total_pages % 256);
+
+          if (show_fonts_used && log_opened)     /* 97/Dec/24 */
+            show_font_info();           // now in local.c
+
+          while (font_ptr > 0)
+          {
+            if (font_used[font_ptr])
+              dvi_font_def(font_ptr);
+
+            decr(font_ptr);
+          }
+
+          dvi_out(post_post);
+          dvi_four(last_bop);
+          dvi_out(id_byte);
+          k = 4 + ((dvi_buf_size - dvi_ptr) % 4);
+
+          while (k > 0)
+          {
+            dvi_out(223);
+            decr(k);
+          }
+
+          if (trace_flag) /* 93/Dec/28 - bkph */
+          {
+            sprintf(log_line, "\ndviwrite %d", dvi_gone);
+            show_line(log_line, 0);
+          }
+
+          if (dvi_limit == half_buf)
+            write_dvi(half_buf, dvi_buf_size - 1);
+
+          if (dvi_ptr > 0)
+            write_dvi(0, dvi_ptr - 1); 
+
+          print_nl("Output written on ");
+
+          if (full_file_name_flag && dvi_file_name != NULL)
+            print_char_string((unsigned char *) dvi_file_name);
+          else
+            slow_print(output_file_name);
+
+          print_string(" (");
+          print_int(total_pages);
+          print_string(" page");
+
+          if (total_pages != 1)
+            print_char('s');
+
+          print_string(", ");
+          print_int(dvi_offset + dvi_ptr);
+          print_string(" bytes).");
+          b_close(dvi_file);
+        }
       }
-
-      if (dvi_limit == half_buf)
-        write_dvi(half_buf, dvi_buf_size - 1);
-
-      if (dvi_ptr > 0)
-        write_dvi(0, dvi_ptr - 1); 
-
-      print_nl("Output written on ");
-
-      if (full_file_name_flag && dvi_file_name != NULL)
-        print_char_string((unsigned char *) dvi_file_name);
-      else
-        slow_print(output_file_name);
-
-      print_string(" (");
-      print_int(total_pages);
-      print_string(" page");
-
-      if (total_pages != 1)
-        print_char('s');
-
-      print_string(", ");
-      print_int(dvi_offset + dvi_ptr);
-      print_string(" bytes).");
-      b_close(dvi_file);
-    }
+      break;
   }
 
   if (log_opened)
index b0983d1..7e4e7b3 100644 (file)
 /* also: should split use of quarterword for (i) font from (ii) char */
 /* for example, xeq_level ? hyphenation trie_trc ? */
 #define INCREASEFONTS
-/* make font_info array fmemoryword == 32 bit instead of memory_word = 64 bit */
 #define SHORTFONTINFO
-/* 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
 
@@ -33,7 +30,6 @@
 
 #define block_size 1000 /* block_size for variable length node alloc */
 
-/* min_quarterword assumed 0 -- i.e. we use unsigned types for quarterword */
 #define min_quarterword 0
 #ifdef INCREASEFONTS
   #define max_quarterword 65535L
@@ -143,12 +139,8 @@ EXTERN integer max_buf_stack;
   #define dvi_buf_size 16384
 #endif
 
-/* #define hash_size 9500  */
-/* #define hash_size 25000 */
-#define hash_size 32768
-/* trick to try and get around eqtb_extra problem */
+#define hash_size 32768 // 9500 25000
 #define hash_extra (255 - font_max)
-/* hash prime about 85% of hash_size (+ hash_extra) */
 #define hash_prime 27197
 
 #if (hash_extra != 255 - font_max)
@@ -203,7 +195,7 @@ typedef integer hyph_pointer;
 EXTERN integer bad;
 EXTERN ASCII_code xord[256];
 EXTERN ASCII_code xchr[256];
-EXTERN unsigned char name_of_file[PATHMAX + 4];
+EXTERN unsigned char name_of_file[PATH_MAX + 4];
 EXTERN integer name_length;
 
 #ifdef ALLOCATESTRING
index 659829b..49dee9e 100644 (file)
 
 #include "yandytex.h"
 
-#ifdef _MSC_VER
-  #define INLINE __inline
-#else
-  #define INLINE inline
-#endif
+enum {
+  out_dvi_flag = (1 << 0),
+  out_pdf_flag = (1 << 1),
+  out_xdv_flag = (1 << 2),
+};
+
+#define INLINE inline
 
 #define dump_file  fmt_file
 #define out_file   dvi_file
 
-/* File types. */
-typedef FILE * byte_file;
-typedef FILE * word_file;
-
 /* Read a line of input as quickly as possible.  */
 extern boolean input_line (FILE *);
 #define input_ln(stream, flag) input_line(stream)
@@ -127,6 +125,4 @@ extern int do_undump (char *, int, int, FILE *);
 /* these, of course are useless definitions since parameters not given */
 
 /* Declare routines in texmf.c.  */
-extern void get_date_and_time();
-extern void t_open_in();
-extern boolean input_line();
+extern void t_open_in();
\ No newline at end of file
index 4986f74..adeeeff 100644 (file)
@@ -31,8 +31,8 @@
 extern char * replacement[];
 
 /* The main program, etc.  */
+/* What we were invoked as and with. */
 
-/* What we were invoked as and with.  */
 static char *program_name = NULL;
 int    gargc;   /* number of args - set to zero after initialization */
 char **gargv;   /* char *gargv[] -- bkph ? */
@@ -44,7 +44,7 @@ int main_init(int, char **);     /* in local.c */
 
 int jump_used = 0;
 
-jmp_buf jumpbuffer;   // for non-local jumps
+jmp_buf jumpbuffer;
 
 int main (int ac, char *av[])
 {
@@ -244,8 +244,7 @@ void get_date_and_time (integer *sys_minutes,
   }
 }
 
-/* I/O for TeX and Metafont.  */ /* give file name ? */
-
+/* I/O for TeX and Metafont.  */
 void complain_line (FILE *output)
 {
   show_line("\n", 0);
@@ -562,9 +561,8 @@ boolean input_line (FILE *f)
   return input_line_finish();
 }
 
-\f
 /* This string specifies what the `e' option does in response to an
-   error message.  */ 
+   error message.  */
 
 static char *edit_value = "c:\\yandy\\WinEdt\\WinEdt.exe [Open('%s');SelLine(%d,7)]";
 
@@ -753,7 +751,6 @@ void call_edit (ASCII_code *stringpool, pool_pointer fnstart, integer fnlength,
   uexit(1);
 }
 
-\f
 /* Read and write format (for TeX) or base (for Metafont) files.  In
    tex.web, these files are architecture dependent; specifically,
    BigEndian and LittleEndian architectures produce different files.
@@ -888,7 +885,6 @@ int do_undump (char *p, int item_size, int nitems, FILE *in_file)
   return 0;
 }
 
-\f
 #ifdef FUNNY_CORE_DUMP
 /* This procedure is due to chris@mimsy.umd.edu.  It makes a core dump
    without any sort of error status (abort(2) does return an error status,
@@ -924,4 +920,4 @@ void funny_core_dump (void)
       exit (1);
   }
 }
-#endif /* FUNNY_CORE_DUMP */
\ No newline at end of file
+#endif /* FUNNY_CORE_DUMP */
index 4b41e6a..ee4a955 100644 (file)
@@ -63,7 +63,9 @@
 typedef long long   integer;
 typedef double      glue_ratio;
 typedef double      real;
-typedef FILE *      alpha_file;
+typedef FILE * alpha_file;
+typedef FILE * byte_file;
+typedef FILE * word_file;
 typedef unsigned char  ASCII_code;
 typedef unsigned short KANJI_code;
 typedef unsigned char  eight_bits;
@@ -95,7 +97,6 @@ typedef enum
 #define decr(x)  --(x)
 #define incr(x)  ++(x)
 #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_out(f)   open_output (&(f), FOPEN_W_MODE)