OSDN Git Service

modified some WINDOWS-only codes.
[putex/putex.git] / src / texsourc / itex.c
index b69cb2c..9ce9672 100644 (file)
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301 USA.  */
 
-#ifdef _WINDOWS
-  #define NOCOMM
-  #define NOSOUND
-  #define NODRIVERS
-  #define STRICT
-  #pragma warning(disable:4115) // kill rpcasync.h complaint
-  #include <windows.h>
-  #define MYLIBAPI __declspec(dllexport)
-#endif
-
-#include "texwin.h"
-
-#pragma warning(disable:4996)
-#pragma warning(disable:4131) // old style declarator
-#pragma warning(disable:4135) // conversion between different integral types
-#pragma warning(disable:4127) // conditional expression is constant
-
-#include <setjmp.h>
-
 #define EXTERN extern
 
 #include "texd.h"
 
 extern clock_t start_time, main_time, finish_time; /* in local.c */
 
-/* imported from pascal.h */
-/* localized here to avoid conflict with io.h in other code */
-
-#define read(f, b) ((b) = getc (f))
-#define readln(f) { register int c; while ((c = getc (f)) != '\n' && c != EOF); }
-
 #ifdef INITEX
-  void do_initex (void); /* later in this file */
+  void do_initex (void);
 #endif
 
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
 /* sec 0004 */
 void initialize (void)
 {
@@ -189,6 +163,7 @@ void initialize (void)
   shown_mode = 0;
   page_contents = 0;
   page_tail = page_head;
+
 #ifdef ALLOCATEMAIN
   if (is_initex) /* in iniTeX we did already allocate mem [] */
 #endif
@@ -271,14 +246,17 @@ void initialize (void)
   cur_loop = 0;
   cur_head = 0;
   cur_tail = 0;
+
+
 /*  *not* OK with ALLOCATEHYPHEN, since may not be allocated yet */
 #ifndef ALLOCATEHYPHEN
   for (z = 0; z <= hyphen_prime; z++)
   {
-    hyph_word[z]= 0;
-    hyph_list[z]= 0;
+    hyph_word[z] = 0;
+    hyph_list[z] = 0;
   }
 #endif
+
   hyph_count = 0;
   output_active = false;
   insert_penalties = 0;
@@ -295,19 +273,13 @@ void initialize (void)
     write_open[k] = false;
 
   edit_name_start = 0;
+
 #ifdef INITEX
-/* initex stuff split off for convenience of optimization adjustments */
   if (is_initex)
   {
     do_initex();
   }
-#else
-/* trap the -i on command line situation if INITEX was NOT defined */
-  if (is_initex)
-  {
-    show_line("Sorry, somebody forgot to make an INITEX!\n", 1);
-  }
-#endif /* not INITEX */
+#endif
 }
 
 /* do the part of initialize() that requires mem_top, mem_max or mem[] */
@@ -1036,7 +1008,7 @@ void prefixed_command (void)
   while (cur_cmd == prefix)
   {
     if (!odd(a / cur_chr))
-      a = a + cur_chr;      /*   small_number a;  */
+      a = a + cur_chr;
 
     do
       {
@@ -1922,6 +1894,7 @@ bool load_fmt_file (void)
       sprintf(log_line, "Read from fmt fmem_ptr = %d\n", x);
       show_line(log_line, 0);
     }
+
     if (x > current_font_mem_size) /* 93/Nov/28 dynamic allocate font_info */
     {
       if (trace_flag)
@@ -1959,7 +1932,7 @@ bool load_fmt_file (void)
       else
         font_ptr = x;
     }
-    frozenfontptr = font_ptr; /* remember number of fonts frozen into format */
+    frozen_font_ptr = font_ptr; /* remember number of fonts frozen into format */
     if (undumpthings(font_check[0], font_ptr + 1))
       return -1;
     if (undumpthings(font_size[0], font_ptr + 1))
@@ -2344,11 +2317,10 @@ int texbody (void)
 {
   history = 3;
 
-  set_paths(TEXFORMATPATHBIT + TEXINPUTPATHBIT + TFMFILEPATHBIT);
-
-  if (ready_already == 314159L) /* magic number */
+  if (ready_already == 314159L)
     goto lab1;
-/*  These tests are almost all compile time tests and so could be eliminated */
+
+  /*  These tests are almost all compile time tests and so could be eliminated */
   bad = 0;
 
   if ((half_error_line < 30) || (half_error_line > error_line - 15))
@@ -2397,8 +2369,7 @@ int texbody (void)
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
   if (mem_max > mem_top + mem_extra_high)     /* not compile time */
     bad = 14;       /* ha ha */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/*  if ((0 < 0)||(font_max > 255)) */
+
   if ((0 < min_quarterword) || (font_max > max_quarterword))  /* 93/Dec/3 */
     bad = 15;
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
@@ -2423,7 +2394,7 @@ int texbody (void)
 
   if (format_default_length > PATHMAX)
     bad = 31;
-/*  if (2 * 262143L < mem_top - mem_min) */
+
   if (max_halfword < (mem_top - mem_min) / 2)
     bad = 41;
 
@@ -2434,7 +2405,7 @@ int texbody (void)
     show_line(log_line, 1);
 
     if (!knuth_flag)
-      bad_formator_pool(format_file, "the format file", "TEXFORMATS");  /* 96/Jan/17 */
+      bad_formator_pool(format_file, "the format file", "TEXFORMATS");
 
     goto lab9999;     // abort
   }
@@ -2452,16 +2423,23 @@ int texbody (void)
     init_pool_ptr = pool_ptr;
     fix_date_and_time();
   }
-#endif /* INITEX */
-  ready_already = 314159L;      /* magic number */
+#endif
+
+  ready_already = 314159L; /* magic number */
 
-lab1:     /* get here directly if ready_already already set ... */
+lab1:
   selector = term_only;
   tally = 0;
   term_offset = 0;
   file_offset = 0;
   show_line(tex_version, 0);
-  sprintf(log_line, " (%s %s)", application, yandyversion);
+
+#ifdef _WIN64
+  sprintf(log_line, " (%s %s/Windows 64bit)", application, yandyversion);
+#else
+  sprintf(log_line, " (%s %s/Windows 32bit)", application, yandyversion);
+#endif
+
   show_line(log_line, 0);
 
   if (format_ident > 0)
@@ -2491,14 +2469,12 @@ lab1:     /* get here directly if ready_already already set ... */
       max_param_stack = 0;
 
 #ifdef ALLOCATEBUFFER
-/*    first = current_buf_size; */
-      memset (buffer, 0, current_buf_size); /* redundant */
+      memset (buffer, 0, current_buf_size);
 #else
-/*    first = buf_size; */
-      memset (buffer, 0, buf_size);     /* redundant ? */
+      memset (buffer, 0, buf_size);
 #endif
-      first = 0;              /* 1999/Jan/22 */
 
+      first = 0;              /* 1999/Jan/22 */
       scanner_status = 0;
       warning_index = 0; /* warning_index:=null; l.7068 */
       first = 1;
@@ -2516,7 +2492,7 @@ lab1:     /* get here directly if ready_already already set ... */
       cur_input.limit_field = last;
       first = last + 1;
     }
-/*    if ((format_ident == 0)||(buffer[cur_input.loc_field]== 38)) */
+
 /*    For Windows NT, lets allow + instead of & for format specification */
     if ((format_ident == 0) ||
         (buffer[cur_input.loc_field] == '&') ||
@@ -2541,10 +2517,6 @@ lab1:     /* get here directly if ready_already already set ... */
         incr(cur_input.loc_field);
     }
 
-#ifdef CHECKEQTB
-    if (debug_flag)
-      check_eqtb("after format"); /* debugging 94/Apr/5 */
-#endif
     if ((end_line_char < 0) || (end_line_char > 255))
       decr(cur_input.limit_field);
     else
@@ -2552,8 +2524,8 @@ lab1:     /* get here directly if ready_already already set ... */
 
     fix_date_and_time();
 
-    magic_offset = str_start[886] - 9 * ord_noad;  /* following: */
-/*  "0234000122*4000133**3**344*0400400*000000234000111*1111112341011" */
+    magic_offset = str_start[886] - 9 * ord_noad;
+    /* "0234000122*4000133**3**344*0400400*000000234000111*1111112341011" */
 
     if (interaction == batch_mode)
       selector = no_print;
@@ -2599,15 +2571,13 @@ lab9999:
       code = 1;
     else
       code = 0;
-//    now return instead of exit to allow cleanup in local.c
+
     return code;
-//    uexit(code);
   }
-} /* end of texbody */
+}
 
 #ifdef ALLOCATEMAIN
 /* add a block of variable size node space below mem_bot */
-/* used in tex0.c, local.c, itex.c */
 void add_variable_space(int size)
 {
   halfword p;
@@ -2615,29 +2585,30 @@ void add_variable_space(int size)
   integer t;
 
   if (mem_min == 0)
-    t = mem_min;  /* bottom of present block */
+    t = mem_min;
   else
     t = mem_min + 1;
 
   mem_min = t - (size + 1);     /* first word in new block - 1 */
-/*  mem_min = mem_start; */     /* allocate all of it at once */
+
   if (mem_min < mem_start)      /* sanity test */
   {
     if (trace_flag)
       show_line("WARNING: mem_min < mem_start!\n", 0);
+
     mem_min = mem_start;
   }
 
-  p = mem[rover + 1].hh.v.LH;
+  p = llink(rover);
   q = mem_min + 1;
-  mem[mem_min].hh.v.RH = 0; /* insert blank word below ??? */
-  mem[mem_min].hh.v.LH = 0; /* insert blank word below ??? */
-  mem[p + 1].hh.v.RH = q;
-  mem[rover + 1].hh.v.LH = q;
-  mem[q + 1].hh.v.RH = rover;
-  mem[q + 1].hh.v.LH = p;
-  mem[q].hh.v.RH = empty_flag;
-  mem[q].hh.v.LH = t - q; /* block size */
+  link(mem_min) = 0; /* insert blank word below ??? */
+  info(mem_min) = 0; /* insert blank word below ??? */
+  rlink(p) = q;
+  llink(rover) = q;
+  rlink(q) = rover;
+  llink(q) = p;
+  link(q) = empty_flag;
+  info(q) = t - q; /* block size */
   rover = q;
 }
 #endif
@@ -2672,7 +2643,7 @@ void reset_hyphen (void)
   for (z = 0; z <= hyphen_prime; z++)
   {
     hyph_word[z] = 0;
-    hyph_list[z] = 0; /* hyph_list[z]:=null; l.18131 */
+    hyph_list[z] = 0;
   }
 
   hyph_count = 0;
@@ -2860,10 +2831,7 @@ void do_initex (void)
   font_glue[null_font]        = 0;
   font_params[null_font]      = 7;
   param_base[null_font]       = -1;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***  */
-  reset_trie();         /* shared 93/Nov/26 */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***  */
-
+  reset_trie();
   text(frozen_protection) = 1184; /* "inaccessible" */
   format_ident = 1251;
   text(end_write) = 1290;
@@ -2871,7 +2839,7 @@ void do_initex (void)
   eq_type(end_write) = outer_call;
   equiv(end_write) = 0;
 }
-#endif /* INITEX */
+#endif
 
 #ifdef INITEX
 /* sec 0047 */
@@ -2908,7 +2876,7 @@ bool get_strings_started (void)
     g = make_string();
   }
 
-  g = load_pool_strings(pool_size - stringvacancies);
+  g = load_pool_strings(pool_size - string_vacancies);
 
   if (g == 0)
   {
@@ -3017,9 +2985,7 @@ void primitive_ (str_number s, quarterword c, halfword o)
   eq_type(cur_val) = c;
   equiv(cur_val) = o;
 }
-#endif /* INITEX */
-
-/* more weird constants ? page 394 */
+#endif
 
 #ifdef INITEX
 /* sec 0944 */
@@ -3143,7 +3109,6 @@ void first_fit_ (trie_pointer p)
     {
       if (trie_size <= h + 256)
       {
-        /* pattern memory - NOT DYNAMIC */
         overflow("pattern memory", trie_size);
 /*      not dynamic ---- but can be set -h=... from command line in ini-TeX */
         return;     // abort_flag set
@@ -4259,11 +4224,11 @@ void init_prim (void)
   primitive("skipdef", shorthand_def, 4);
   primitive("muskipdef", shorthand_def, 5);
   primitive("toksdef", shorthand_def, 6);
-  primitive("catcode", def_code, (hash_size + 1883));
-  primitive("mathcode", def_code, (hash_size + 2907));
-  primitive("lccode", def_code, (hash_size + 2139));
-  primitive("uccode", def_code, (hash_size + 2395));
-  primitive("sfcode", def_code, (hash_size + 2651));
+  primitive("catcode", def_code, cat_code_base);
+  primitive("mathcode", def_code, math_code_base);
+  primitive("lccode", def_code, lc_code_base);
+  primitive("uccode", def_code, uc_code_base);
+  primitive("sfcode", def_code, sf_code_base);
   primitive("delcode", def_code, (hash_size + 3474));
   primitive("textfont", def_family, (hash_size + 1835));
   primitive("scriptfont", def_family, (hash_size + 1851));