OSDN Git Service

pdf_set_rule.
[putex/putex.git] / src / texsourc / local.c
index 364f925..5614c6d 100644 (file)
 
 #include "texd.h"
 
-/* Most Y & Y changes are localized here -- init() */
-
-#define USEOUREALLOC      /* 96/Jan/20 */
-
-#define USEMEMSET       /* 98/Jan/23 */
+#define USEOUREALLOC
+#define USEMEMSET
 
 #ifdef USEOUREALLOC
   #define REALLOC ourrealloc
@@ -37,7 +34,6 @@ int wantcopyrght = 1;
 char *compiletime  =  __TIME__;
 char *compiledate  =  __DATE__;
 char *www          = "http://www.tug.org/yandy";
-char *rights       = "All Rights Reserved.";
 char *copyright    = "\nCopyright (C) 1993--2000 Y&Y, Inc.\n"
                      "Copyright (C) 2007 TeX Users Group.\n"
                      "Copyright (C) 2014 Clerk Ma.\n\n"
@@ -45,7 +41,7 @@ char *copyright    = "\nCopyright (C) 1993--2000 Y&Y, Inc.\n"
                      "it under the terms of the GNU General Public License as published by\n"
                      "the Free Software Foundation; either version 2 of the License, or\n"
                      "(at your option) any later version.\n\n  ";
-char *yandyversion = "2.2.4";
+char *yandyversion = "2.3.0";
 char *application  = "Y&Y TeX";
 char *tex_version  = "This is TeX, Version 3.14159265";
 
@@ -64,7 +60,7 @@ char log_line[MAXLINE];  // used also in tex9.c
 int mem_spec_flag     = 0;    /* non-zero if `-m=...' was used */ 
 int format_spec       = 0;    /* non-zero if a format specified on command line */
 int closed_already    = 0;    /* make sure we don't try this more than once */
-bool reorder_arg_flag = true; /* put command line flags/arguments first */
+boolean reorder_arg_flag = true; /* put command line flags/arguments first */
 
 /* Mapping from Windows ANSI to DOS code page 850 96/Jan/20 */
 /* Used in tex0.c with wintodos[c-128]                      */
@@ -94,26 +90,38 @@ void show_usage (void)
   char * s = log_line;
 
   sprintf (s, "\n"
-      " yandytex [-?ivnwdrzpK] [-m=ini_mem] [-e=hyph_size] [-h=trie_size]\n"
-      "          [-x=xchr_file] [-k=key_file] [-o=dvi_dir] [-l=log_dir] [-a=aux_dir]\n"
-      "          [+format_file] [tex_file]\n\n"
-      "    --help    -?    show this usage summary\n"
-      "    --initex  -i    start up as iniTeX (create format file)\n"
-      "    --verbose -v    be verbose (show implementation version number)\n"
+      " Useage: yanytex [OPTION]... [+format_file] [tex_file]\n\n"
+      "    --help    -?\n"
+      "        show this usage summary\n"
+      "    --initex  -i\n"
+      "        start up as iniTeX (create format file)\n"
+      "    --verbose -v\n"
+      "        be verbose (show implementation version number)\n"
       "    -n    do not allow `non ASCII' characters in input files (complain instead)\n"
-      "    -w    do not show `non ASCII' characters in hexadecimal (show as is)\n"
+      "    --showhex -w\n"
+      "        do not show `non ASCII' characters in hexadecimal (show as is)\n"
       "    -d    do not allow DOS style file names - i.e. do not convert \\ to /\n"
       "    -r    do not allow Mac style termination - i.e. do not convert \\r to \\n\n"
-      "    -p    allow use of \\patterns after loading format (iniTeX only)\n"
-      "    -K    disable all extensions to basic TeX\n"
-      "    -m    initial main memory size in kilo words (iniTeX only)\n"
-      "    -e    hyphenation exception dictionary size (iniTeX only)\n"
-      "    -h    hyphenation pattern trie size (iniTeX only)\n"
-      "    -x    use `non ASCII' character mapping (xchr[]) defined in file\n"
-      "    -k    use `key replacement' defined in file\n"
-      "    -o    write DVI file in specified directory (default current directory)\n"
-      "    -l    write LOG file in specified directory (default current directory)\n"
-      "    -a    write AUX file in specified directory (default current directory)\n");
+      "    --patterns    -p\n"
+      "        allow use of \\patterns after loading format (iniTeX only)\n"
+      "    --knuthify    -K\n"
+      "        disable all extensions to basic TeX\n"
+      "    --main-memory -m\n"
+      "        initial main memory size in kilo words (iniTeX only)\n"
+      "    --hyph-size   -e\n"
+      "        hyphenation exception dictionary size (iniTeX only)\n"
+      "    --trie-size   -h\n"
+      "        hyphenation pattern trie size (iniTeX only)\n"
+      "    --xchr-file   -x\n"
+      "        use `non ASCII' character mapping (xchr[]) defined in file\n"
+      "    --key-file    -k\n"
+      "        use `key replacement' defined in file\n"
+      "    --dvi-dir     -o\n"
+      "        write DVI file in specified directory (default current directory)\n"
+      "    --log-dir     -l\n"
+      "        write LOG file in specified directory (default current directory)\n"
+      "    --aux-dir     -a\n"
+      "        write AUX file in specified directory (default current directory)\n");
   show_line(log_line, 1);
 
 #ifndef _WINDOWS
@@ -389,10 +397,7 @@ int read_xchr_file (char *filename, int flag, char *argv[])
     show_line(log_line, 0);
   }
 
-  if (share_flag == 0)
-    pinput = fopen (infile, "r");
-  else
-    pinput = _fsopen (infile, "r", share_flag);    /* 94/July/12 */
+  pinput = fopen (infile, "r");
 
   if (pinput == NULL)
   {
@@ -408,17 +413,14 @@ int read_xchr_file (char *filename, int flag, char *argv[])
         sprintf(log_line, "Trying %s\n", infile);
         show_line(log_line, 0);
       }
-
-      if (share_flag == 0)
-        pinput = fopen (infile, "r");
-      else
-        pinput = _fsopen (infile, "r", share_flag);  /* 94/July/12 */
+      
+      pinput = fopen (infile, "r");
     }
   }
 
   if (pinput == NULL)
   {
-    strcpy (infile, argv[0]);     /* try TeX program path */
+    strcpy(infile, argv[0]);     /* try TeX program path */
 
     if ((s = strrchr (infile, '\\')) != NULL) *(s+1) = '\0';
     else if ((s = strrchr (infile, '/')) != NULL) *(s+1) = '\0';
@@ -432,10 +434,7 @@ int read_xchr_file (char *filename, int flag, char *argv[])
       show_line(log_line, 0);
     }
 
-    if (share_flag == 0)
-      pinput = fopen (infile, "r");
-    else
-      pinput = _fsopen (infile, "r", share_flag);    /* 94/July/12 */
+    pinput = fopen (infile, "r");
 
     if (pinput == NULL)
     {
@@ -452,10 +451,7 @@ int read_xchr_file (char *filename, int flag, char *argv[])
           show_line(log_line, 0);
         }
 
-        if (share_flag == 0)
-          pinput = fopen (infile, "r");
-        else
-          pinput = _fsopen (infile, "r", share_flag); /* 94/July/12 */
+        pinput = fopen (infile, "r");
       }
     }
   }
@@ -477,10 +473,7 @@ int read_xchr_file (char *filename, int flag, char *argv[])
       show_line(log_line, 0);
     }
 
-    if (share_flag == 0)
-      pinput = fopen (infile, "r");
-    else
-      pinput = _fsopen (infile, "r", share_flag);
+    pinput = fopen (infile, "r");
 
     if (pinput == NULL)
     {
@@ -497,10 +490,7 @@ int read_xchr_file (char *filename, int flag, char *argv[])
           show_line(log_line, 0);
         }
 
-        if (share_flag == 0)
-          pinput = fopen (infile, "r");
-        else
-          pinput = _fsopen (infile, "r", share_flag);
+        pinput = fopen (infile, "r");
       }
     }
   }
@@ -529,26 +519,6 @@ int read_xchr_file (char *filename, int flag, char *argv[])
 
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
 
-/* Following may be useful if link without floating point emulation */
-
-#ifdef DEBUG
-void testfloating (void)
-{
-  double dx = 1.0;
-  double dxold = 0.0;
-  int k = 0;
-
-  while (1.0 + dx != 1.0)
-  {
-    dxold = dx;
-    dx = dx / 2.0;
-    k++;
-  }
-  sprintf(log_line, "Floating test: dx = %lg (k = %d)\n", dxold, k - 1);
-  show_line(log_line, 0);
-}
-#endif
-
 #define MAXSPLITS 3
 
 /* ad hoc default minimum growth in memory realloc is 62% */
@@ -562,9 +532,7 @@ int max_address     = 0;  /* maximum address seen in allocated memory */
 void show_maximums (FILE *output)
 {
   sprintf(log_line, "Max allocated %d --- max address %d\n", total_allocated, max_address);
-//  if (output != NULL) fputs(log_line, output); // log file
-//  else if (flag == 0) show_line(log_line, 0); // informative
-//  else if (flag == 1) show_line(log_line, 1); // error
+
   if (output == stderr)
     show_line(log_line, 1);
   else if (output == stdout)
@@ -581,20 +549,29 @@ void *ourrealloc (void *old, size_t new_size)
 {
   void * mnew;
   size_t old_size, overlap;
-
-/*  round up to nearest multiple of four bytes *//* avoid unlikely alignment */
+  
+  /*  round up to nearest multiple of four bytes */
+  /* avoid unlikely alignment */
   if ((new_size % 4) != 0)
     new_size = ((new_size / 4) + 1) * 4;
 
   if (old == NULL)
     return malloc (new_size);  /* no old block - use malloc */
 
+#ifdef _WIN32
   old_size = _msize (old);
+#else
+  old_size = malloc_usable_size (old);
+#endif
 
   if (old_size >= new_size && old_size < new_size + 4)
     return old;
 
-  mnew = _expand (old, new_size);      /* first try and expand in place */
+#ifdef _WIN32
+  mnew = _expand (old, new_size); /* first try and expand in place MSVC */
+#else
+  mnew = realloc (old, new_size);
+#endif
 
   if (mnew != NULL)
   {
@@ -604,17 +581,18 @@ void *ourrealloc (void *old, size_t new_size)
           mnew, new_size, old, old_size);
       show_line(log_line, 0);
     }
+
     return mnew;
   }
-/*  *********************************************************************** */
-/*  do this if you want to call the real realloc next -  */
+
+  /*  do this if you want to call the real realloc next -  */
   mnew = realloc (old, new_size);
 
   if (mnew != NULL)
     return mnew;
-/*  we are screwed typically if we ever drop through here - no more space */
-/*  *********************************************************************** */
-  mnew = malloc (new_size);          /* otherwise find new space */
+
+  /*  we are screwed typically if we ever drop through here - no more space */
+  mnew = malloc (new_size); /* otherwise find new space */
 
   if (mnew == NULL)
     return mnew;        /* if unable to allocate */
@@ -624,8 +602,9 @@ void *ourrealloc (void *old, size_t new_size)
   else
     overlap = new_size;
 
-  memcpy (mnew, old, overlap);         /* copy old data to new area */
-  free(old);                  /* free the old area */
+  memcpy (mnew, old, overlap); /* copy old data to new area */
+  free(old); /* free the old area */
+
   return mnew;
 }
 #endif
@@ -693,25 +672,20 @@ size_t roundup (size_t n)
 int allocate_tries (int trie_max)
 {
   int n, nl, no, nc;
-/*  if (trie_max > trie_size) {
-    sprintf(log_line, "ERROR: invalid trie size (%d > %d)\n",
-      trie_max, trie_size);
-      show_line(log_line, 1);
-    exit (1);
-  } */ /* ??? removed 1993/dec/17 */
+
   if (trie_max > 1000000)
-    trie_max = 1000000; /* some sort of sanity limit */
-/*  important + 1 because original was halfword trie_trl[trie_size + 1] etc. */
-  nl = (trie_max + 1) * sizeof(halfword);    /* trie_trl[trie_size + 1] */
-  no = (trie_max + 1) * sizeof(halfword);    /* trie_tro[trie_size + 1] */
-  nc = (trie_max + 1) * sizeof(quarterword); /* trie_trc[trie_size + 1] */
+    trie_max = 1000000;
+
+  nl = (trie_max + 1) * sizeof(halfword);
+  no = (trie_max + 1) * sizeof(halfword);
+  nc = (trie_max + 1) * sizeof(quarterword);
   n = nl + no + nc;
 
   if (trace_flag)
     trace_memory("hyphen trie", n);
 
-  trie_trl = (halfword *)    malloc (roundup(nl));
-  trie_tro = (halfword *)    malloc (roundup(no));
+  trie_trl = (halfword *) malloc (roundup(nl));
+  trie_tro = (halfword *) malloc (roundup(no));
   trie_trc = (quarterword *) malloc (roundup(nc));
 
   if (trie_trl == NULL || trie_tro == NULL || trie_trc == NULL)
@@ -726,22 +700,23 @@ int allocate_tries (int trie_max)
     show_line(log_line, 0);
   }
 
-  update_statistics ((int) trie_trl, nl, 0);
-  update_statistics ((int) trie_tro, no, 0);
-  update_statistics ((int) trie_trc, nc, 0);
-/*  sprintf(log_line, "trie_size %d trie_max %d\n", trie_size, trie_max); */ /* debug */
-  trie_size = trie_max;           /* BUG FIX 98/Jan/5 */
+  update_statistics((int) trie_trl, nl, 0);
+  update_statistics((int) trie_tro, no, 0);
+  update_statistics((int) trie_trc, nc, 0);
+
+  trie_size = trie_max;
 
   if (trace_flag)
-    probe_show();     /* 94/Mar/25 */
-  return 0;               // success
+    probe_show();
+
+  return 0; // success
 }
 #endif
 
 #ifdef ALLOCATEHYPHEN
-bool prime (int);       /* test function later in this file */
+boolean prime (int); /* test function later in this file */
 
-int current_prime = 0;         /* remember in case reallocated later */
+int current_prime = 0; /* remember in case reallocated later */
 
 /* we don't return an address here, since TWO memory regions allocated */
 /* plus, we don't really reallocate, we FLUSH the old information totally */
@@ -757,6 +732,7 @@ int realloc_hyphen (int hyphen_prime)
     show_line(log_line, 1);
     return -1;
   }
+
 /*  need not/cannot preserve old contents when hyphen prime is changed */
 /*  if (hyph_list != NULL) free(hyph_list); */
 /*  if (hyph_word != NULL) free(hyph_word); */
@@ -768,12 +744,8 @@ int realloc_hyphen (int hyphen_prime)
   if (trace_flag)
     trace_memory("hyphen exception", n);
 
-/*  initially hyph_word will be NULL so this acts like malloc */
-/*  hyph_word = (str_number *) malloc (nw); */
-  hyph_word = (str_number *) REALLOC (hyph_word, nw);  /* 94/Mar/24 */
-/*  initially hyph_list will be NULL so this acts like malloc */
-/*  hyph_list = (halfword *) malloc (nl); */
-  hyph_list = (halfword *) REALLOC (hyph_list, nl);   /* 94/Mar/24 */
+  hyph_word = (str_number *) REALLOC (hyph_word, nw);
+  hyph_list = (halfword *) REALLOC (hyph_list, nl);
 
   if (hyph_word == NULL || hyph_list == NULL)
   {
@@ -786,6 +758,7 @@ int realloc_hyphen (int hyphen_prime)
     sprintf(log_line, "Addresses hyph_word %d hyph_list %d\n", hyph_word, hyph_list);
     show_line(log_line, 0);
   }
+
 /*  cannot preserve old contents when hyphen prime is changed */
 #ifdef USEMEMSET
   memset(hyph_word, 0, (hyphen_prime + 1) * sizeof (hyph_word[0]));
@@ -798,24 +771,26 @@ int realloc_hyphen (int hyphen_prime)
 #else
   for (k = 0; k <= hyphen_prime; k++) hyph_list[k]= 0;
 #endif
-  hyph_count = 0;   /* or use reset_hyphen() in itex.c */
+
+  hyph_count = 0;
 
   if (current_prime != 0)
   {
-    update_statistics ((int) hyph_word, nw, (current_prime + 1) * sizeof(str_number));
-    update_statistics ((int) hyph_list, nl, (current_prime + 1) * sizeof(halfword));
+    update_statistics((int) hyph_word, nw, (current_prime + 1) * sizeof(str_number));
+    update_statistics((int) hyph_list, nl, (current_prime + 1) * sizeof(halfword));
   }
   else
   {
-    update_statistics ((int) hyph_word, nw, 0);
-    update_statistics ((int) hyph_list, nl, 0);
+    update_statistics((int) hyph_word, nw, 0);
+    update_statistics((int) hyph_list, nl, 0);
   }
+
   current_prime = hyphen_prime;
 
   if (trace_flag)
-    probe_show();     /* 94/Mar/25 */
+    probe_show();
 
-  return 0;               // success
+  return 0; // success
 }
 #endif
 
@@ -833,31 +808,14 @@ memory_word *allocate_main_memory (int size)
 {
   int n;
 
-/*  Using -i *and* pre-loading format */ /* in this case get called twice */
-/*  Get rid of initial blank memory again or use realloc ... */
-/*  Could we avoid this by detecting presence of & before allocating ? */
-/*  Also, if its already large enough, maybe we can avoid this ? */
-/*  don't bother if current_mem_size == mem_max - mem_start ? */
-  if (mainmemory != NULL)
+  if (main_memory != NULL)
   {
     if (trace_flag)
       show_line("Reallocating initial memory allocation\n", 1);
   }
 
   mem_top = mem_bot + size;
-
-#ifdef ALLOCATEHIGH         /* NOT USED ANYMORE */
-  if (mem_extra_high != 0 && !is_initex)
-    mem_max = mem_top + mem_extra_high;
-#endif
-
   mem_max = mem_top;
-
-#ifdef ALLOCATELOW          /* NOT USED ANYMORE */
-  if (mem_extra_low != 0 && !is_initex)
-    mem_start = mem_bot - mem_extra_low;  /* increase main memory */
-#endif
-
   mem_start = 0;     /* bottom of memory allocated by system */
 /*  mem_min = mem_start; */ /* bottom of area made available to TeX */
   mem_min = 0;       /* bottom of area made available to TeX */
@@ -866,11 +824,9 @@ memory_word *allocate_main_memory (int size)
   if (trace_flag)
     trace_memory("main memory", n);
 
-/*  mainmemory = (memory_word *) malloc (n); */  /* 94/March/24 */
-/*  normally mainmemory == NULL here so acts like malloc ... */
-  mainmemory = (memory_word *) REALLOC (mainmemory, n);
+  main_memory = (memory_word *) REALLOC (main_memory, n);
 
-  if (mainmemory == NULL)
+  if (main_memory == NULL)
   {
     memory_error("initial main memory", n);
 //    exit (1);             /* serious error */
@@ -879,32 +835,31 @@ memory_word *allocate_main_memory (int size)
 
   if (trace_flag)
   {
-    sprintf(log_line, "Address main memory == %d\n", mainmemory);
+    sprintf(log_line, "Address main memory == %d\n", main_memory);
     show_line(log_line, 0);
   }
 
-  zzzaa = mainmemory;
+  mem = main_memory;
 
   if (mem_start != 0 && !is_initex)
-    zzzaa = mainmemory - mem_start;
+    mem = main_memory - mem_start;
 
   if (trace_flag)
   {
-    sprintf(log_line, "Offset address main memory == %d\n", zzzaa);
+    sprintf(log_line, "Offset address main memory == %d\n", mem);
     show_line(log_line, 0);
   }
 
-  update_statistics ((int) mainmemory, n,
-    (current_mem_size + 1) * sizeof (memory_word));
+  update_statistics ((int) main_memory, n, (current_mem_size + 1) * sizeof (memory_word));
 /*  current_mem_size = (mem_max - mem_start + 1); */
   current_mem_size = mem_max - mem_start;   /* total number of words - 1 */
 
   if (trace_flag)
     probe_show();     /* 94/Mar/25 */
 
-  return zzzaa;             /* same as zmem, mem 94/Jan/24 */
+  return mem;
 }
-#endif  /* end of ALLOCATEMAIN */
+#endif
 
 #ifdef ALLOCATEMAIN
 /* int firstallocation = 1; */
@@ -916,12 +871,9 @@ memory_word *allocate_main_memory (int size)
 memory_word *realloc_main (int losize, int hisize)
 {  
   int k, minsize;
-  int newsize = 0;        /* to quieten compiler */
-  int n = 0;          /* to quieten compiler */
-  memory_word * newmemory = NULL; /* to quieten compiler */
-
-/*  if (losize == 0 && hisize > 0) runawayflag = 1;
-  else runawayflag = 0; */ /* 94/Jan/22 */
+  int newsize = 0;
+  int n = 0;
+  memory_word * newmemory = NULL;
 
   if (trace_flag)
   {
@@ -941,16 +893,18 @@ memory_word *realloc_main (int losize, int hisize)
 
   if (trace_flag)
   {
-    sprintf(log_line, "Old Address %s == %d\n", "main memory", mainmemory);
+    sprintf(log_line, "Old Address %s == %d\n", "main memory", main_memory);
     show_line(log_line, 0);
   }
 
-  if (current_mem_size + 1 == max_mem_size) /* if we REALLY run up to limit ! */
+  /* if we REALLY run up to limit ! */
+  if (current_mem_size + 1 == max_mem_size)
   {
     memory_error("main memory", (max_mem_size + 1) * sizeof(memory_word));
 //    abort_flag++;  // ???
     return NULL;
   }
+
 /*  first allocation should expand *both* lo and hi */
   if (hisize == 0 && mem_end == mem_max)
     hisize = losize;
@@ -998,7 +952,7 @@ memory_word *realloc_main (int losize, int hisize)
     if (trace_flag)
       trace_memory("main memory", n);
 
-    newmemory = (memory_word *) REALLOC (mainmemory, n);
+    newmemory = (memory_word *) REALLOC (main_memory, n);
 
     if (newmemory != NULL)
       break; /* did we get it ? */
@@ -1012,7 +966,7 @@ memory_word *realloc_main (int losize, int hisize)
   if (newmemory == NULL)
   {
     memory_error("main memory", n);
-    return zzzaa;           /* try and continue with TeX !!! */
+    return mem;
   }
 
   if (trace_flag)
@@ -1034,7 +988,7 @@ memory_word *realloc_main (int losize, int hisize)
       (current_mem_size + 1) * sizeof(memory_word));
 /*  could reduce words moved by (mem_max - mem_end) */
   }
-  mainmemory = newmemory;       /* remember for free later */
+  main_memory = newmemory;       /* remember for free later */
 
   if (losize > 0)
     mem_start = mem_start - losize; /* update lower limit */
@@ -1042,7 +996,7 @@ memory_word *realloc_main (int losize, int hisize)
   if (hisize > 0)
     mem_max = mem_max + hisize;   /* update upper limit */
 
-  update_statistics ((int) mainmemory, n,
+  update_statistics ((int) main_memory, n,
     (current_mem_size + 1) * sizeof (memory_word));
   current_mem_size = newsize;
 
@@ -1052,14 +1006,14 @@ memory_word *realloc_main (int losize, int hisize)
   }
 
   if (mem_start != 0)
-    zzzaa = mainmemory - mem_start; /* ??? sign ??? */
+    mem = main_memory - mem_start;
   else
-    zzzaa = mainmemory;
+    mem = main_memory;
 
   if (trace_flag)
-    probe_show();     /* 94/Mar/25 */
+    probe_show();
 
-  return zzzaa;
+  return mem;
 }
 #endif
 
@@ -1069,12 +1023,12 @@ memory_word *realloc_main (int losize, int hisize)
 int current_font_mem_size = 0;
 
 /* fmemoryword can be either halfword or memory_word */
-fmemoryword * realloc_font_info (int size)
+memory_word * realloc_font_info (int size)
 {
-  fmemoryword *newfontinfo = NULL;
+  memory_word *newfontinfo = NULL;
   int k, minsize;
-  int newsize = 0;  /* to quieten compiler */
-  int n = 0;        /* to quieten compiler */
+  int newsize = 0;
+  int n = 0;
 
   if (trace_flag)
   {
@@ -1107,12 +1061,12 @@ fmemoryword * realloc_font_info (int size)
       newsize = font_mem_size; /* bump against limit */
 
 /*    important + 1 since fmemoryword font_info[font_mem_size + 1]  original */
-    n = (newsize + 1) * sizeof (fmemoryword);
+    n = (newsize + 1) * sizeof (memory_word);
 
     if (trace_flag)
       trace_memory("font_info", n);
 
-    newfontinfo = (fmemoryword *) REALLOC (font_info, n);
+    newfontinfo = (memory_word *) REALLOC (font_info, n);
 
     if (newfontinfo != NULL)
       break;   /* did we get it ? */
@@ -1137,11 +1091,12 @@ fmemoryword * realloc_font_info (int size)
     show_line(log_line, 0);
   }
 
-  update_statistics ((int) font_info, n, current_font_mem_size * sizeof(fmemoryword));
+  update_statistics ((int) font_info, n, current_font_mem_size * sizeof(memory_word));
   current_font_mem_size = newsize;
 
   if (trace_flag)
-    probe_show();     /* 94/Mar/25 */
+    probe_show();
+
   return font_info;
 }
 #endif
@@ -1168,20 +1123,35 @@ packed_ASCII_code * realloc_str_pool (int size)
 /*    exit (1); */
     return str_pool;   /* pass it back to TeX 99/Fabe/4 */
   }
-/*  minsize =  current_pool_size / 2; */
+
   minsize =  current_pool_size / 100 * percent_grow;
-  if (size < minsize) size = minsize;
-  if (size < initial_pool_size) size = initial_pool_size;
 
-  for (k = 0; k < MAXSPLITS; k++) {
+  if (size < minsize)
+    size = minsize;
+
+  if (size < initial_pool_size)
+    size = initial_pool_size;
+
+  for (k = 0; k < MAXSPLITS; k++)
+  {
     newsize = current_pool_size + size;
-    if (newsize > pool_size) newsize = pool_size;
+
+    if (newsize > pool_size)
+      newsize = pool_size;
 /* important + 1 since  packed_ASCII_code str_pool[pool_size + 1]; in original */
     n = (newsize + 1) * sizeof (packed_ASCII_code);
-    if (trace_flag) trace_memory("str_pool", n);
+
+    if (trace_flag)
+      trace_memory("str_pool", n);
+
     newstrpool = (packed_ASCII_code *) REALLOC (str_pool, n); /* 95/Sep/24 */
-    if (newstrpool != NULL) break;    /* did we get it ? */
-    if (current_pool_size == 0) break;  /* initial allocation must work */
+
+    if (newstrpool != NULL)
+      break;    /* did we get it ? */
+
+    if (current_pool_size == 0)
+      break;  /* initial allocation must work */
+
     size = size / 2;          /* else can retry smaller */
   }
 
@@ -1202,7 +1172,7 @@ packed_ASCII_code * realloc_str_pool (int size)
   }
   
   if (trace_flag)
-    probe_show();     /* 94/Mar/25 */
+    probe_show();
 
   return str_pool;
 }
@@ -1214,8 +1184,8 @@ int current_max_strings = 0;
 pool_pointer *realloc_str_start (int size)
 {
   int k, minsize;
-  int n=0;
-  int newsize=0;
+  int n = 0;
+  int newsize = 0;
   pool_pointer *newstrstart=NULL;
 
   if (trace_flag)
@@ -1230,86 +1200,115 @@ pool_pointer *realloc_str_start (int size)
 /*    exit (1); */
     return str_start;    /* pass it back to TeX 99/Fabe/4 */
   }
-/*  minsize = current_max_strings / 2; */
+
   minsize = current_max_strings / 100 * percent_grow;
-  if (size < minsize) size = minsize;
-  if (size < initial_max_strings) size = initial_max_strings;
+
+  if (size < minsize)
+    size = minsize;
+
+  if (size < initial_max_strings)
+    size = initial_max_strings;
 
   for (k = 0; k < MAXSPLITS; k++)
   {
     newsize = current_max_strings + size;
-    if (newsize > max_strings) newsize = max_strings;
+
+    if (newsize > max_strings)
+      newsize = max_strings;
 /*    important + 1 since str_start[maxstring + 1] originally */
     n = (newsize + 1) * sizeof (pool_pointer);
-    if (trace_flag) trace_memory("str_start", n);
+
+    if (trace_flag)
+      trace_memory("str_start", n);
+
     newstrstart = (pool_pointer *) REALLOC (str_start, n);
-    if (newstrstart != NULL) break;   /* did we get it ? */
-    if (current_max_strings == 0) break;  /* initial allocation must work */
+
+    if (newstrstart != NULL)
+      break;   /* did we get it ? */
+
+    if (current_max_strings == 0)
+      break;  /* initial allocation must work */
+
     size = size / 2;          /* otherwise can try smaller */
   }
 
-  if (newstrstart == NULL) {
+  if (newstrstart == NULL)
+  {
     memory_error("string pointer", n);
     return str_start;          /* try and continue */
   }
+
   str_start = newstrstart;
   update_statistics((int) str_start, n, current_max_strings * sizeof (pool_pointer));
   current_max_strings = newsize;
-  if (trace_flag) {
+
+  if (trace_flag)
+  {
     sprintf(log_line, "New Address %s == %d\n", "string start", str_start);
     show_line(log_line, 0);
   }
-  if (trace_flag)  probe_show();     /* 94/Mar/25 */
+
+  if (trace_flag)
+    probe_show();
+
   return str_start;
 }
 #endif
 
 #ifdef ALLOCATEINI
-
 /* returns -1 if it fails */
 /* size == trie_size */
 int allocate_ini (int size)
 {
   int n, nl, no, nc, nr, nh, nt;
-    nh = nr = nl = (size + 1) *  sizeof(trie_pointer);
-    no = (size + 1) *  sizeof(trie_op_code);
-    nc = (size + 1) *  sizeof(packed_ASCII_code);
-/*    nt = (size + 1) *  sizeof(bool); */
-    nt = (size + 1) *  sizeof(char);
-    n = nl + no + nc + nr + nh + nt;
+
+  nh = nr = nl = (size + 1) *  sizeof(trie_pointer);
+  no = (size + 1) *  sizeof(trie_op_code);
+  nc = (size + 1) *  sizeof(packed_ASCII_code);
+/*    nt = (size + 1) *  sizeof(boolean); */
+  nt = (size + 1) *  sizeof(char);
+  n = nl + no + nc + nr + nh + nt;
 /*    n = (size + 1) * (sizeof(packed_ASCII_code) + sizeof(trie_op_code) +
       3 *  sizeof(trie_pointer) + sizeof (char)); */
-    if (trace_flag) trace_memory ("iniTeX hyphen trie", n);
-    trie_l = (trie_pointer *) malloc (roundup(nl));
-    trie_o = (trie_op_code *) malloc (roundup(no));
-    trie_c = (packed_ASCII_code *) malloc (roundup(nc));
-    trie_r = (trie_pointer *) malloc (roundup(nr));
-    trie_hash = (trie_pointer *) malloc (roundup(nh));
-/*    trie_taken = (bool *) malloc (nt); */
-    trie_taken = (char *) malloc (roundup(nt));
-    if (trie_c == NULL || trie_o == NULL || trie_l == NULL || trie_r == NULL ||
-      trie_hash == NULL || trie_taken == NULL) {
-      memory_error("iniTeX hyphen trie", n);
-//      exit (1);           /* serious error */     
-      return -1;
-    }
-    if (trace_flag) {
-      sprintf(log_line, "Addresses trie_l %d trie_o %d trie_c %d\n", 
-          trie_l, trie_o, trie_c);
-      show_line(log_line, 0);
-      sprintf(log_line, "Addresses trie_r %d trie_hash %d trie_taken %d\n", 
-          trie_r, trie_hash, trie_taken);
-      show_line(log_line, 0);
-    }
-    update_statistics ((int) trie_l, nl, 0);
-    update_statistics ((int) trie_o, no, 0);
-    update_statistics ((int) trie_c, nc, 0);
-    update_statistics ((int) trie_r, nr, 0);
-    update_statistics ((int) trie_hash, nh, 0);
-    update_statistics ((int) trie_taken, nt, 0);
+  if (trace_flag)
+    trace_memory ("iniTeX hyphen trie", n);
+
+  trie_l = (trie_pointer *) malloc (roundup(nl));
+  trie_o = (trie_op_code *) malloc (roundup(no));
+  trie_c = (packed_ASCII_code *) malloc (roundup(nc));
+  trie_r = (trie_pointer *) malloc (roundup(nr));
+  trie_hash = (trie_pointer *) malloc (roundup(nh));
+  trie_taken = (char *) malloc (roundup(nt));
+  
+  if (trie_c == NULL || trie_o == NULL || trie_l == NULL || trie_r == NULL ||
+      trie_hash == NULL || trie_taken == NULL)
+  {
+    memory_error("iniTeX hyphen trie", n);
+//      exit (1);           /* serious error */
+    return -1;
+  }
+  
+  if (trace_flag)
+  {
+    sprintf(log_line, "Addresses trie_l %d trie_o %d trie_c %d\n",
+      trie_l, trie_o, trie_c);
+    show_line(log_line, 0);
+    sprintf(log_line, "Addresses trie_r %d trie_hash %d trie_taken %d\n",
+      trie_r, trie_hash, trie_taken);
+    show_line(log_line, 0);
+  }
+
+  update_statistics ((int) trie_l, nl, 0);
+  update_statistics ((int) trie_o, no, 0);
+  update_statistics ((int) trie_c, nc, 0);
+  update_statistics ((int) trie_r, nr, 0);
+  update_statistics ((int) trie_hash, nh, 0);
+  update_statistics ((int) trie_taken, nt, 0);
 /*    trie_size = size; */ /* ??? */
-    if (trace_flag)  probe_show();     /* 94/Mar/25 */
-    return 0;               // success
+  if (trace_flag)
+    probe_show();
+
+  return 0; // success
 }
 #endif
 
@@ -1319,8 +1318,8 @@ int current_save_size = 0;
 memory_word *realloc_save_stack (int size)
 {
   int k, minsize;
-  int n=0, newsize=0;
-  memory_word *newsave_stack=NULL;
+  int n = 0, newsize = 0;
+  memory_word *newsave_stack = NULL;
 
   if (trace_flag)
   {
@@ -1346,12 +1345,23 @@ memory_word *realloc_save_stack (int size)
   for (k = 0; k < MAXSPLITS; k++)
   {
     newsize = current_save_size + size;
-    if (newsize > save_size) newsize = save_size;
+
+    if (newsize > save_size)
+      newsize = save_size;
+
     n = (newsize + 1) * sizeof (memory_word); /* save_stack[save_size + 1] */
-    if (trace_flag) trace_memory("save_stack", n);
+
+    if (trace_flag)
+      trace_memory("save_stack", n);
+
     newsave_stack = (memory_word *) REALLOC (save_stack, n);
-    if (newsave_stack != NULL) break;    /* did we get it ? */
-    if (current_save_size == 0) break;  /* initial allocation must work */
+
+    if (newsave_stack != NULL)
+      break;    /* did we get it ? */
+
+    if (current_save_size == 0)
+      break;  /* initial allocation must work */
+
     size = size / 2;          /* else can retry smaller */
   }
 
@@ -1367,13 +1377,15 @@ memory_word *realloc_save_stack (int size)
 
   if (trace_flag)
   {
-    sprintf(log_line, "Current%s %d\n", "save_size", current_save_size);
+    sprintf(log_line, "Current %s %d\n", "save_size", current_save_size);
     show_line(log_line, 0);
     sprintf(log_line, "New Address %s == %d\n", "save stack", save_stack);
     show_line(log_line, 0);
   }
 
-  if (trace_flag) probe_show();      /* 94/Mar/25 */
+  if (trace_flag)
+    probe_show();
+
   return save_stack;
 }
 #endif
@@ -1384,47 +1396,74 @@ int current_stack_size = 0;       /* input stack size */
 in_state_record *realloc_input_stack (int size)
 {
   int k, minsize;
-  int n=0, newsize=0;
-  in_state_record *newinputstack=NULL;
+  int n = 0, newsize = 0;
+  in_state_record *newinputstack = NULL;
 
-  if (trace_flag) {
+  if (trace_flag)
+  {
     sprintf(log_line, "Old Address %s == %d\n",  "input stack", input_stack);
     show_line(log_line, 0);
   }
-  if (current_stack_size == stack_size) {  /* arbitrary limit */
+
+  if (current_stack_size == stack_size)  /* arbitrary limit */
+  {
 /*    memory_error ("input stack", (stack_size + 1) * sizeof(in_state_record)); */
 /*    exit (1); */
     return input_stack;
   }
+
   minsize =  current_stack_size / 100 * percent_grow;
-  if (size < minsize) size = minsize;
-  if (size < initial_stack_size) size = initial_stack_size;
 
-  for (k = 0; k < MAXSPLITS; k++) {
+  if (size < minsize)
+    size = minsize;
+
+  if (size < initial_stack_size)
+    size = initial_stack_size;
+
+  for (k = 0; k < MAXSPLITS; k++)
+  {
     newsize = current_stack_size + size;
-    if (newsize > stack_size) newsize = stack_size;
+
+    if (newsize > stack_size)
+      newsize = stack_size;
+
     n = (newsize + 1) * sizeof (in_state_record); /* input_stack[stack_size + 1] */
-    if (trace_flag) trace_memory("input_stack", n);
+
+    if (trace_flag)
+      trace_memory("input_stack", n);
+
     newinputstack = (in_state_record *) REALLOC (input_stack, n);
-    if (newinputstack != NULL) break;   /* did we get it ? */
-    if (current_stack_size == 0) break; /* initial allocation must work */
+
+    if (newinputstack != NULL)
+      break;   /* did we get it ? */
+
+    if (current_stack_size == 0)
+      break; /* initial allocation must work */
+
     size = size / 2;          /* else can retry smaller */
   }
 
-  if (newinputstack == NULL) {
+  if (newinputstack == NULL)
+  {
     memory_error("input stack", n);
     return input_stack;            /* try and continue !!! */
   }
+
   input_stack = newinputstack;
   update_statistics ((int) input_stack, n, current_stack_size);
   current_stack_size = newsize;
-  if (trace_flag) {
-    sprintf(log_line, "Current%s %d\n", "stack_size", current_stack_size);
+
+  if (trace_flag)
+  {
+    sprintf(log_line, "Current %s %d\n", "stack_size", current_stack_size);
     show_line(log_line, 0);
     sprintf(log_line, "New Address %s == %d\n", "input stack", input_stack);
     show_line(log_line, 0);
   }
-  if (trace_flag)  probe_show();     /* 94/Mar/25 */
+
+  if (trace_flag)
+    probe_show();     /* 94/Mar/25 */
+
   return input_stack;
 }
 #endif
@@ -1435,98 +1474,152 @@ int current_nest_size = 0;        /* current nest size */
 list_state_record *realloc_nest_stack (int size)
 {
   int k, minsize;
-  int n=0, newsize=0;
-  list_state_record *newnest=NULL;
+  int n = 0, newsize = 0;
+  list_state_record *newnest = NULL;
 
-  if (trace_flag) {
+  if (trace_flag)
+  {
     sprintf(log_line, "Old Address %s == %d\n",  "nest stack", nest);
     show_line(log_line, 0);
   }
-  if (current_nest_size == nest_size) {  /* arbitrary limit */
+
+  if (current_nest_size == nest_size)  /* arbitrary limit */
+  {
 /*    memory_error ("nest stack", (nest_size + 1) * sizeof(list_state_record)); */
 /*    exit (1); */
     return nest;        /* let TeX handle the error */
   }
+
   minsize =  current_nest_size / 100 * percent_grow;
-  if (size < minsize) size = minsize;
-  if (size < initial_nest_size) size = initial_nest_size;
 
-  for (k = 0; k < MAXSPLITS; k++) {
+  if (size < minsize)
+    size = minsize;
+
+  if (size < initial_nest_size)
+    size = initial_nest_size;
+
+  for (k = 0; k < MAXSPLITS; k++)
+  {
     newsize = current_nest_size + size;
-    if (newsize > nest_size) newsize = nest_size;
+
+    if (newsize > nest_size)
+      newsize = nest_size;
+
     n = (newsize + 1) * sizeof (list_state_record); /* nest[nest_size + 1] */
-    if (trace_flag) trace_memory("nest stack", n);
+
+    if (trace_flag)
+      trace_memory("nest stack", n);
+
     newnest = (list_state_record *) REALLOC (nest, n);
-    if (newnest != NULL) break;   /* did we get it ? */
-    if (current_nest_size == 0) break;  /* initial allocation must work */
+
+    if (newnest != NULL)
+      break;   /* did we get it ? */
+
+    if (current_nest_size == 0)
+      break;  /* initial allocation must work */
+
     size = size / 2;          /* else can retry smaller */
   }
 
-  if (newnest == NULL) {
+  if (newnest == NULL)
+  {
     memory_error("nest stack", n);
     return nest;            /* try and continue !!! */
   }
+
   nest = newnest;
   update_statistics ((int) nest, n, current_nest_size);
   current_nest_size = newsize;
-  if (trace_flag) {
-    sprintf(log_line, "Current%s %d\n", "nest_size", current_nest_size);
+
+  if (trace_flag)
+  {
+    sprintf(log_line, "Current %s %d\n", "nest_size", current_nest_size);
     show_line(log_line, 0);
     sprintf(log_line, "New Address %s == %d\n", "nest stack", nest);
     show_line(log_line, 0);
   }
-  if (trace_flag)  probe_show();     /* 94/Mar/25 */
+
+  if (trace_flag)
+    probe_show();
+
   return nest;
 }
 #endif
 
 #ifdef ALLOCATEPARAMSTACK
-int current_param_size=0;       /* current param size */
+int current_param_size = 0;
 
 halfword *realloc_param_stack (int size)
 {
   int k, minsize;
-  int n=0, newsize=0;
-  halfword *newparam=NULL;
+  int n = 0, newsize = 0;
+  halfword *newparam = NULL;
 
-  if (trace_flag) {
+  if (trace_flag)
+  {
     sprintf(log_line, "Old Address %s == %d\n",  "param stack", param_stack);
     show_line(log_line, 0);
   }
-  if (current_param_size == param_size) {  /* arbitrary limit */
+
+  if (current_param_size == param_size) /* arbitrary limit */
+  {
 /*    memory_error ("param stack", (param_size + 1) * sizeof(halfword)); */
 /*    exit (1); */
     return param_stack;        /* let TeX handle the error */
   }
+
   minsize =  current_param_size / 100 * percent_grow;
-  if (size < minsize) size = minsize;
-  if (size < initial_param_size) size = initial_param_size;
 
-  for (k = 0; k < MAXSPLITS; k++) {
+  if (size < minsize)
+    size = minsize;
+
+  if (size < initial_param_size)
+    size = initial_param_size;
+
+  for (k = 0; k < MAXSPLITS; k++)
+  {
     newsize = current_param_size + size;
-    if (newsize > param_size) newsize = param_size;
+
+    if (newsize > param_size)
+      newsize = param_size;
+
     n = (newsize + 1) * sizeof (halfword); /* param_stack[param_size + 1] */
-    if (trace_flag) trace_memory("param stack", n);
+
+    if (trace_flag)
+      trace_memory("param stack", n);
+
     newparam = (halfword *) REALLOC (param_stack, n); 
-    if (newparam != NULL) break;    /* did we get it ? */
-    if (current_param_size == 0) break; /* initial allocation must work */
+
+    if (newparam != NULL)
+      break;    /* did we get it ? */
+
+    if (current_param_size == 0)
+      break; /* initial allocation must work */
+
     size = size / 2;          /* else can retry smaller */
   }
 
-  if (newparam == NULL) {
+  if (newparam == NULL)
+  {
     memory_error("param stack", n);
     return param_stack;            /* try and continue !!! */
   }
+
   param_stack = newparam;
   update_statistics ((int) param_stack, n, current_param_size);
   current_param_size = newsize;
-  if (trace_flag) {
-    sprintf(log_line, "Current%s %d\n", "param_size", current_param_size);
+
+  if (trace_flag)
+  {
+    sprintf(log_line, "Current %s %d\n", "param_size", current_param_size);
     show_line(log_line, 0);
     sprintf(log_line, "New Address %s == %d\n", "param stack", param_stack);
     show_line(log_line, 0);
   }
-  if (trace_flag)  probe_show();     /* 94/Mar/25 */
+
+  if (trace_flag)
+    probe_show();     /* 94/Mar/25 */
+
   return param_stack;
 }
 #endif
@@ -1537,52 +1630,81 @@ int current_buf_size = 0;
 ASCII_code *realloc_buffer (int size)
 {
   int k, minsize;
-  int n=0, newsize=0;
-  ASCII_code *newbuffer=NULL;
+  int n = 0, newsize = 0;
+  ASCII_code *newbuffer = NULL;
 
-  if (trace_flag) {
+  if (trace_flag)
+  {
     sprintf(log_line, "Old Address %s == %d\n", "buffer", buffer);
     show_line(log_line, 0);
   }
-  if (current_buf_size == buf_size) {  /* arbitrary limit */
+
+  if (current_buf_size == buf_size)
+  {
 /*    memory_error ("buffer", buf_size); */
 /*    exit (1); */
     return buffer;    /* pass it back to TeX 99/Fabe/4 */
   }
+
   minsize =  current_buf_size / 100 * percent_grow;
-  if (size < minsize) size = minsize;
-  if (size < initial_buf_size) size = initial_buf_size;
 
-  for (k = 0; k < MAXSPLITS; k++) {
+  if (size < minsize)
+    size = minsize;
+
+  if (size < initial_buf_size)
+    size = initial_buf_size;
+
+  for (k = 0; k < MAXSPLITS; k++)
+  {
     newsize = current_buf_size + size;
-    if (newsize > buf_size) newsize = buf_size;
-    n = (newsize + 1) * sizeof(ASCII_code);  /* buffer[buf_size + 1] */
-    if (trace_flag) trace_memory("buffer", n);
+
+    if (newsize > buf_size)
+      newsize = buf_size;
+
+    n = (newsize + 1) * sizeof(ASCII_code);
+
+    if (trace_flag)
+      trace_memory("buffer", n);
+
     newbuffer = (ASCII_code *) REALLOC (buffer, n);
-    if (newbuffer != NULL) break;   /* did we get it ? */
-    if (current_buf_size == 0) break;   /* initial allocation must work */
-    size = size / 2;          /* else can retry smaller */
+
+    if (newbuffer != NULL)
+      break;   /* did we get it ? */
+
+    if (current_buf_size == 0)
+      break;   /* initial allocation must work */
+
+    size = size / 2;
   }
 
-  if (newbuffer == NULL) {
+  if (newbuffer == NULL)
+  {
     memory_error("buffer", n);
     return buffer;            /* try and continue !!! */
   }
+
   buffer = newbuffer;
   update_statistics ((int) buffer, n, current_buf_size);
+
 #ifdef USEMEMSET
   memset(buffer + current_buf_size, 0, newsize - current_buf_size);
 #else
   for (k = current_buf_size; k < newsize; k++) buffer[k]= 0;
 #endif
+
   current_buf_size = newsize;
-  if (trace_flag) {
-    sprintf(log_line, "Current%s %d\n", "buffer", current_buf_size);
+
+  if (trace_flag)
+  {
+    sprintf(log_line, "Current %s %d\n", "buffer", current_buf_size);
     show_line(log_line, 0);
     sprintf(log_line, "New Address %s == %d\n", "buffer", buffer);
     show_line(log_line, 0);
   }
-  if (trace_flag)  probe_show();     /* 94/Mar/25 */
+
+  if (trace_flag)
+    probe_show();
+
   return buffer;
 }
 #endif
@@ -1605,18 +1727,18 @@ int allocate_memory (void)
 /* they are all rather small, and typically don't need expansion */
 /* WE ASSUME THIS DOESN'T HAPPEN, SO WON'T BOTHER WITH UPDATESTATISTICS */
 #ifdef ALLOCATEHASH
-/*  n = 9767 * sizeof (twohalves);  *//* 60 kilo bytes */   
-/*  n = (hash_size + 267) * sizeof (twohalves); */  /* 60 kilo bytes */
-/*  n = (9767 + eqtb_extra) * sizeof (twohalves); */
+/*  n = 9767 * sizeof (two_halves);  *//* 60 kilo bytes */   
+/*  n = (hash_size + 267) * sizeof (two_halves); */  /* 60 kilo bytes */
+/*  n = (9767 + eqtb_extra) * sizeof (two_halves); */
 #ifdef SHORTHASH
-  n = (hash_size + 267 + eqtb_extra) * sizeof (htwohalves);   /* 95/Feb/19 */
-  zzzae = (htwohalves *) malloc (roundup(n));
+  n = (hash_size + 267 + eqtb_extra) * sizeof (htwo_halves);   /* 95/Feb/19 */
+  zzzae = (htwo_halves *) malloc (roundup(n));
 #else
-  n = (hash_size + 267 + eqtb_extra) * sizeof (twohalves);  /* 95/Feb/19 */
-  zzzae = (twohalves *) malloc (roundup(n));
+  n = (hash_size + 267 + eqtb_extra) * sizeof (two_halves);  /* 95/Feb/19 */
+  zzzae = (two_halves *) malloc (roundup(n));
 #endif
   if (trace_flag)  trace_memory("hash table", n);
-/*  zzzae = (twohalves *) malloc ((hash_size + 267) * sizeof (twohalves)); */
+/*  zzzae = (two_halves *) malloc ((hash_size + 267) * sizeof (two_halves)); */
   if (zzzae == NULL)
   {
     memory_error("hash table", n);
@@ -1640,44 +1762,26 @@ int allocate_memory (void)
   }
 #endif
 
-/* no real reason to allocate dvi_buf - no need to ever grow it */
-#ifdef ALLOCATEDVIBUF
-/*  zdvibuf = NULL; */
-  zdvibuf = allocatedvibuf (dvi_buf_size);
-  if (zdvibuf == NULL) return -1;
-#endif
-
-#ifdef ALLOCATEZEQTB
-/*  zeqtb = NULL; */
-#ifdef INCREASEFONTS
-/*  zeqtb = allocatezeqtb (13507 + eqtb_extra); */  /* 94/Mar/29 */
-  zeqtb = allocatezeqtb (hash_size + 4007 + eqtb_extra);  /* 94/Mar/29 */
-#else
-/*  zeqtb = allocatezeqtb (13507); */
-  zeqtb = allocatezeqtb (hash_size + 4007); 
-#endif
-#endif
-
 #ifdef ALLOCATEINPUTSTACK
-  input_stack = NULL;        /* new 1999/Jan/21 */
+  input_stack = NULL;
   current_stack_size = 0;
   input_stack = realloc_input_stack (initial_stack_size);  /* + 1 */
 #endif
 
 #ifdef ALLOCATENESTSTACK
-  nest = NULL;          /* new 1999/Jan/21 */
+  nest = NULL;
   current_nest_size = 0;
   nest = realloc_nest_stack (initial_nest_size);  /* + 1 */
 #endif
 
 #ifdef ALLOCATEPARAMSTACK
-  param_stack = NULL;          /* new 1999/Jan/21 */
+  param_stack = NULL;
   current_param_size = 0;
   param_stack = realloc_param_stack (initial_param_size); /* + 1 */
 #endif
 
 #ifdef ALLOCATESAVESTACK
-  save_stack = NULL;       /* new 1999/Jan/7 */
+  save_stack = NULL;
   current_save_size = 0;
   save_stack = realloc_save_stack (initial_save_size);
 #endif
@@ -1696,8 +1800,11 @@ int allocate_memory (void)
 /*  need to create space because iniTeX writes in before reading pool file */
 /*  for a start, puts in strings for 256 characters */
 /*  maybe taylor allocations to actual pool file 1300 strings 27000 bytes ? */
-  if (is_initex) {
-    if (trace_flag) show_line("ini TeX pool and string allocation\n", 0);
+  if (is_initex)
+  {
+    if (trace_flag)
+      show_line("ini TeX pool and string allocation\n", 0);
+
     str_pool = realloc_str_pool (initial_pool_size); 
     str_start = realloc_str_start (initial_max_strings);
   }
@@ -1709,18 +1816,20 @@ int allocate_memory (void)
   current_font_mem_size = 0;
 /*  if not iniTeX, then do initial allocation on fmt file read in itex.c */
 /*  if ini-TeX we need to do it here - no format file read later */
-  if (is_initex) font_info = realloc_font_info (initial_font_mem_size);
+  if (is_initex)
+    font_info = realloc_font_info (initial_font_mem_size);
 #endif
-    
+
 #ifdef ALLOCATEMAIN
-  mainmemory = NULL;
-  zzzaa = NULL;
+  main_memory = NULL;
+  mem = NULL;
   mem_min = mem_bot;        /* just to avoid complaints in texbody */
   mem_top = mem_initex;
   mem_max = mem_top;
 /*  allocate main memory here if this is iniTeX */
 /*  otherwise wait for format undumping in itex.c ... */  
-  if (is_initex) {
+  if (is_initex)
+  {
 /*    avoid this if format specified on command line ??? */
 /*    allocate_main_memory(mem_initex); */   /* made variable ! */
     mem = allocate_main_memory(mem_initex);  /* made variable ! */
@@ -1741,6 +1850,7 @@ int allocate_memory (void)
   {
     if (new_hyphen_prime)
       hyphen_prime = new_hyphen_prime;
+
     if (realloc_hyphen(hyphen_prime)) /* allocate just in case no format */
       return -1;
   }
@@ -1768,7 +1878,7 @@ int allocate_memory (void)
   {
     trie_l = trie_r = trie_o = trie_hash = NULL; /* (trie_size + 1) * integer */
     trie_c = NULL;       /* (trie_size + 1) * char */
-    trie_taken = NULL;     /* (trie_size + 1) * bool */
+    trie_taken = NULL;     /* (trie_size + 1) * boolean */
   }
 #endif
 #ifdef PREALLOCHOLE
@@ -1781,11 +1891,10 @@ int allocate_memory (void)
 /* free in reverse order 93/Nov/26 */
 int free_memory (void)
 {
-  int n;
-  unsigned heaptotal = 0;
-/*  unsigned total; */
+  unsigned int heap_total = 0;
 
-  if (trace_flag) show_line("free_memory ", 0);
+  if (trace_flag)
+    show_line("free_memory ", 0);
 
   if (verbose_flag || trace_flag)
     show_maximums(stdout); 
@@ -1793,219 +1902,270 @@ int free_memory (void)
   if (trace_flag)
   {
     sprintf(log_line, "Heap total: %u bytes --- max address %u\n", 
-        heaptotal, max_address);
+        heap_total, max_address);
     show_line(log_line, 0);
   }
 
-  if (trace_flag) {
+  if (trace_flag)
+  {
     sprintf(log_line, "Main Memory: variable node %d (%d - %d) one word %d (%d - %d)\n",
       lo_mem_max - mem_min, mem_min, lo_mem_max, mem_end  - hi_mem_min, hi_mem_min, mem_end);
     show_line(log_line, 0);
   }
-/*  following only needed to check consistency of heap ... useful debugging */
-  if (trace_flag) show_line("Freeing memory again\n", 0);
 
-/*  if (trace_flag)
-    show_line(log_line, "Zero Glue Reference Count %d\n", mem[0].hh.v.RH); */
-
-/*  the following checks the heap integrity */
+  /*  following only needed to check consistency of heap ... useful debugging */
+  if (trace_flag)
+    show_line("Freeing memory again\n", 0);
 
-/*  if ((n = _heapchk ()) != _HEAPOK) { */      /* 94/Feb/18 */
-  n = _HEAPOK;
-#ifdef SHOWHEAPERROR
-  n = _heapchk();
-  if (n != _HEAPOK) {     /* 94/Feb/18 */
-    sprintf(log_line, "WARNING: Heap corrupted (%d)\n", n);
-    show_line(log_line, 1);
-    sprintf(log_line, "HEAP %s (%s)\n", heapstrings[-n], "free_memory");
-    show_line(log_line, 0);
-    return n;   /* non-zero and negative */ /* unreachable ??? */
-  }
-#endif
 /*  only free memory if safe ... additional check */
 #ifdef ALLOCATEINI
   if (is_initex)
   {
-    if (trie_taken != NULL) free(trie_taken);
-    if (trie_hash  != NULL) free(trie_hash);
-    if (trie_r     != NULL) free(trie_r);
-    if (trie_c     != NULL) free(trie_c);
-    if (trie_o     != NULL) free(trie_o);
-    if (trie_l     != NULL) free(trie_l);
+    if (trie_taken != NULL)
+      free(trie_taken);
+
+    if (trie_hash != NULL)
+      free(trie_hash);
+
+    if (trie_r != NULL)
+      free(trie_r);
+
+    if (trie_c != NULL)
+      free(trie_c);
+
+    if (trie_o != NULL)
+      free(trie_o);
+
+    if (trie_l != NULL)
+      free(trie_l);
+
     trie_taken = NULL;
     trie_hash = trie_l = trie_r = NULL;
     trie_c = NULL;
     trie_o = NULL;
   }
-#endif  
+#endif
+
 #ifdef ALLOCATETRIES
-  if (trie_trc != NULL) free (trie_trc);
-  if (trie_tro != NULL) free (trie_tro);
-  if (trie_trl != NULL) free (trie_trl);
+  if (trie_trc != NULL)
+    free (trie_trc);
+
+  if (trie_tro != NULL)
+    free (trie_tro);
+
+  if (trie_trl != NULL)
+    free (trie_trl);
+
   trie_trc = NULL;
   trie_tro = trie_trl = NULL;
 #endif
+
 #ifdef ALLOCATEHYPHEN
-  if (hyph_list != NULL) free(hyph_list);
-  if (hyph_word != NULL) free(hyph_word);
+  if (hyph_list != NULL)
+    free(hyph_list);
+
+  if (hyph_word != NULL)
+    free(hyph_word);
+
   hyph_list = NULL;
   hyph_word = NULL;
 #endif
+
 #ifdef ALLOCATEMAIN
 /*  if (zzzaa != NULL) free(zzzaa); */  /* NO: zzzaa may be offset ! */
-  if (mainmemory != NULL) free(mainmemory);
-  mainmemory = NULL;
+  if (main_memory != NULL)
+    free(main_memory);
+
+  main_memory = NULL;
 #endif
+
 #ifdef ALLOCATEFONT
-  if (font_info != NULL) free(font_info);
+  if (font_info != NULL)
+    free(font_info);
+
   font_info = NULL;
 #endif
+
 #ifdef ALLOCATESTRING
-  if (str_start != NULL) free(str_start);
-  if (str_pool != NULL) free(str_pool);
-  str_start = NULL;
-  str_pool = NULL;
-#endif
+  if (str_start != NULL)
+    free(str_start);
 
-#ifdef ALLOCATEHASH
-  if (zzzae != NULL) free(zzzae);
-  zzzae = NULL;
-#endif
+  if (str_pool != NULL)
+    free(str_pool);
 
-#ifdef ALLOCATEDVIBUF
-  if (zdvibuf != NULL) free(zdvibuf);
-  zdvibuf = NULL;
-#endif
-#ifdef ALLOCATEZEQTB
-  if (zeqtb != NULL) free(zeqtb);
-  zeqtb = NULL;
+  str_start = NULL;
+  str_pool = NULL;
 #endif
 
 #ifdef ALLOCATEPARAMSTACK
-  if (param_stack != NULL) free(param_stack);
+  if (param_stack != NULL)
+    free(param_stack);
+
   param_stack = NULL;
 #endif
+
 #ifdef ALLOCATENESTSTACK
-  if (nest != NULL) free(nest);
+  if (nest != NULL)
+    free(nest);
+
   nest = NULL;
 #endif
+
 #ifdef ALLOCATEINPUTSTACK
-  if (input_stack != NULL) free(input_stack);
+  if (input_stack != NULL)
+    free(input_stack);
+
   input_stack = NULL;
 #endif
+
 #ifdef ALLOCATESAVESTACK
-  if (save_stack != NULL) free(save_stack);
+  if (save_stack != NULL)
+    free(save_stack);
+
   save_stack = NULL;
 #endif
 /*  if (buffercopy != NULL) free (buffercopy); */ /* 94/Jun/27 */
-  if (format_file != NULL) free(format_file);   /* 96/Jan/16 */
-  if (string_file != NULL) free(string_file);   /* 96/Jan/16 */
-  if (source_direct != NULL) free(source_direct); /* 98/Sep/29 */
-  format_file = string_file = source_direct = NULL;
-  if (dvi_file_name != NULL) free(dvi_file_name);
-  if (log_file_name != NULL) free(log_file_name);
-  if (pdf_file_name != NULL) free(pdf_file_name);
-  pdf_file_name = log_file_name = dvi_file_name = NULL;       /* 00/Jun/18 */
+  if (format_file != NULL)
+    free(format_file);
+
+  if (source_direct != NULL)
+    free(source_direct);
+
+  format_file = source_direct = NULL;
+
+  if (dvi_file_name != NULL)
+    free(dvi_file_name);
+
+  if (log_file_name != NULL)
+    free(log_file_name);
+
+  if (pdf_file_name != NULL)
+    free(pdf_file_name);
+
+  pdf_file_name = log_file_name = dvi_file_name = NULL;
+
   return 0;
 }
 
-bool prime (int x)
+boolean prime (int x)
 {
   int k;
   int sum = 1;    /* 1 + 3 + 5 + k = (k + 1) * (k + 1) / 4 */
-  if (x % 2 == 0) return false;
-  for (k = 3; k < x; k = k + 2) {
-    if (x % k == 0) return false;
-/*    if (k * k > x) return true; */
-    if (sum * 4 > x) return true;
+
+  if (x % 2 == 0)
+    return false;
+
+  for (k = 3; k < x; k = k + 2)
+  {
+    if (x % k == 0)
+      return false;
+
+    if (sum * 4 > x)
+      return true;
+
     sum += k;
   }
+
   return true;
 }
 
 int quitflag  = 0;
-bool show_use = false;
-bool floating = false;
+boolean show_use = false;
+boolean floating = false;
 
 void complainarg (int c, char *s)
 {
   sprintf(log_line, "ERROR: Do not understand `%c' argument value `%s'\n", c, s);
   show_line(log_line, 1);
-  show_use = 1;           // 2000 June 21
+  show_use = 1;
 }
 
 /* following is list of allowed command line flags and args */
 
-/* char *allowedargs="+vitrdcyzpsqnwbfXABCDFGKLMNOQRSTYWZ?g=m=u=e=o=a=x=k=h=l=u=E=H="; */
-
-/* only  01234567.9 still left to take ... maybe recycle u */
-
 char *allowedargs = "+bcdfijnpqrstvwyzABCDFGIJKLMNOPQRSTVWXYZ023456789?a=e=g=h=k=l=m=o=u=x=E=H=P=U=";
 
-/* char takeargs="gmueoazhluEH"; */ /* subset that takes args! needed here */
-
 void reorderargs (int ac, char **av)
-{      /* put in 1993/Dec/28 */
+{
   int n, m;
   char *s, *t;
-//  char takeargs[128];   /* large enough for all command line arg chars */
   char takeargs[256];   /* large enough for all command line arg chars */
 
-/*  assumes arg pointers av[] are writeable */
-/*  for (n = 1; n < ac; n++) sprintf(log_line, "%s ", av[n]); */
-
-  if (ac < 3) { /* need more than one arg to reorder anything 94/Feb/25 */
-/*    show_line("No arguments?\n", 0); */  /* debugging */
-    return;             /* no args ! */
+  if (ac < 3)
+  {
+    return; /* no args ! */
   }
 
   s = allowedargs;
   t = takeargs;   /* list of those that take args */
-  while (*s != '\0' && *(s+1) != '\0') {
-    if (*(s+1) == '=') *t++ = *s++;   /* copy over --- without the = */
+
+  while (*s != '\0' && *(s+1) != '\0')
+  {
+    if (*(s+1) == '=')
+      *t++ = *s++;   /* copy over --- without the = */
+
     s++;
   }
+
   *t = '\0';
-  if (trace_flag) {
+
+  if (trace_flag)
+  {
     show_line(takeargs, 0);
     show_char('\n');
   }
   
   n = 1;
-  for (;;) {              /* scan to end of command line args */
-    if (*av[n] != '-') break;
-/*    does it take an argument ? and is this argument next ? */
-    if (n+1 < ac &&
-      *(av[n]+2) == '\0' &&
-/*        strchr("gmuhleoxE", *(av[n]+1)) != NULL) */
-        strchr(takeargs, *(av[n]+1)) != NULL)
-          n += 2; /* step over it */
-    else n++;
-    if (n == ac) break;
-  }
-
-  for (;;) {              /* look for more command line args */
-    if (n == ac) break;
+
+  for (;;)
+  {
+    if (*av[n] != '-')
+      break;
+
+    if (n + 1 < ac && *(av[n] + 2) == '\0' &&
+      strchr(takeargs, *(av[n]+1)) != NULL)
+      n += 2; /* step over it */
+    else
+      n++;
+
+    if (n == ac)
+      break;
+  }
+
+  for (;;)
+  {
+    if (n == ac)
+      break;
+
     m = n;
-/*    while (*av[m] != '-' && m < ac) m++; */ /* first command */
-    while (m < ac && *av[m] != '-') m++;  /* first command */
-    if (m == ac) break;
+
+    while (m < ac && *av[m] != '-')
+      m++;  /* first command */
+
+    if (m == ac)
+      break;
 /* does it take an argument ? and is this argument next ? */
 /* check first whether the `-x' is isolated, or arg follows directly */
 /* then check whether this is one of those that takes an argument */
-    if (m+1 < ac &&
-      *(av[m]+2) == '\0' &&
-        strchr(takeargs, *(av[m]+1)) != NULL) {
+    if (m+1 < ac && *(av[m]+2) == '\0' &&
+      strchr(takeargs, *(av[m]+1)) != NULL)
+    {
       s = av[m];      /*  move command down before non-command */
-      t = av[m+1];
-      for (; m > n; m--)  av[m+1] = av[m-1];
+      t = av[m + 1];
+
+      for (; m > n; m--)
+        av[m + 1] = av[m - 1];
+
       av[n] = s;
-      av[n+1] = t;
+      av[n + 1] = t;
       n += 2;       /* step over moved args */
     }
-    else {
+    else
+    {
       s = av[m];      /*  move command down before non-command */
-      for (; m > n; m--)  av[m] = av[m-1];
+
+      for (; m > n; m--)
+        av[m] = av[m - 1];
+
       av[n] = s;
       n++;        /* step over moved args */
     }
@@ -2015,12 +2175,18 @@ void reorderargs (int ac, char **av)
 int test_align (int address, int size, char *name)
 {
   int n;
-  if (size > 4) n = address % 4;
-  else n = address % size;
-  if (n != 0) {
+
+  if (size > 4)
+    n = address % 4;
+  else
+    n = address % size;
+
+  if (n != 0)
+  {
     sprintf(log_line, "OFFSET %d (ELEMENT %d) in %s\n", n, size, name);
     show_line(log_line, 0);
   }
+
   return n;
 }
 
@@ -2032,6 +2198,7 @@ void check_fixed_align (int flag)
   {
     show_line("PLEASE RECOMPILE ME!\n", 1);
   }
+
 #ifdef CHECKALIGNMENT
   if (!flag)
     return;
@@ -2078,10 +2245,6 @@ void check_fixed_align (int flag)
   test_align ((int) &depth_threshold, 4, "depth_threshold");
   test_align ((int) &breadth_max, 4, "breadth_max");
   test_align ((int) &nest, sizeof(nest[0]), "nest");
-
-#ifdef ALLOCZEQTB
-  test_align ((int) &zeqtb, sizeof(zeqtb[0]), "zeqtb");  /* not any more ? */
-#endif
 /*  test_align ((int) &xeq_level, sizeof(xeq_level[0]), "xeq_level"); */
   test_align ((int) &zzzad, sizeof(zzzad[0]), "zzzad");
 /*  test_align ((int) &hash, sizeof(hash[0]), "hash"); */
@@ -2160,6 +2323,7 @@ void check_alloc_align (int flag)
 {
   if (test_align ((int) eqtb, sizeof(eqtb[0]), "ALLOCATED ALIGNMENT"))
     show_line("PLEASE RECOMPILE ME!\n", 1);
+
 #ifdef CHECKALIGNMENT
   if (!flag) return;
 #ifndef ALLOCZEQTB
@@ -2186,16 +2350,14 @@ void check_alloc_align (int flag)
 #endif
 }
 
-bool backwardflag       = false;              /* don't cripple all advanced features */
-bool shorten_file_name  = false;              /* don't shorten file names to 8+3 for DOS */
-bool usesourcedirectory = true;               /* use source file directory as local when WorkingDirectory is set */
-bool workingdirectory   = false;              /* if working directory set in ini */
+boolean backwardflag       = false;              /* don't cripple all advanced features */
+boolean shorten_file_name  = false;              /* don't shorten file names to 8+3 for DOS */
+boolean usesourcedirectory = true;               /* use source file directory as local when WorkingDirectory is set */             /* if working directory set in ini */
 
 /* cache to prevent allocating twice in a row */
 
 char *lastname = NULL, *lastvalue = NULL;
 
-/* get value of env var - try first in dviwindo.ini then DOS env */
 /* returns allocated string -- these strings are not freed again */
 /* is it safe to do that now ? 98/Jan/31 */
 char *grabenv (char *varname)
@@ -2208,9 +2370,7 @@ char *grabenv (char *varname)
   if (*varname == '\0')
     return NULL;
 
-/*  speedup to avoid double lookup when called from set_paths in ourpaths.c */
-/*  if (lastname != NULL && strcmp(lastname, varname) == 0) { */
-  if (lastname != NULL && _strcmpi(lastname, varname) == 0)
+  if (lastname != NULL && strcasecmp(lastname, varname) == 0)
   {
     if (trace_flag)
     {
@@ -2241,12 +2401,10 @@ char *grabenv (char *varname)
     return NULL;
 }
 
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-
 void flush_trailing_slash (char *directory)
 {
   char *s;
-/*  flush trailing \ or / in directory, if any 1993/Dec/12 */
+
   if (strcmp(directory, "") != 0)
   {
     s = directory + strlen(directory) - 1;
@@ -2258,11 +2416,6 @@ void flush_trailing_slash (char *directory)
 
 void knuthify (void)
 {
-/*  show_current = false; */ /* show ultimate limits */
-/*  reorder_arg_flag = false; */ /* don't reorder command line */
-/*  deslash = false; */ /* don't unixify file names */
-/*  return_flag = false; */ /* don't allow just ^^M termination */
-/*  trimeof = false; */ /* don't trim ^^Z Ctrl-Z at end of file */
   restrict_to_ascii = false; /* don't complain non ASCII */
   allow_patterns    = false; /* don't allow pattern redefinition */
   show_in_hex       = true;  /* show character code in hex */
@@ -2273,10 +2426,7 @@ void knuthify (void)
   c_style_flag      = false; /* don't add file name to error msg */
   show_fmt_flag     = false; /* don't show format file in log */
   show_tfm_flag     = false; /* don't show metric file in log */
-/* font_max = 255; */ /* revert to TeX 82 limit */
-/* if you want this, change in tex.h definition of font_max to `int' */
-/* and add define FONTMAX 511, and in local.c add font_max = FONTMAX; */
-  tab_step = 0;
+  tab_step          = 0;
   show_line_break_stats = false;   /* do not show line break stats */
   show_fonts_used = false;
   default_rule = 26214;      /* revert to default rule thickness */
@@ -2286,13 +2436,13 @@ void knuthify (void)
   truncate_long_lines = false;
   allow_quoted_names = false;
   show_cs_names = false;
-  font_dimen_zero = false;      /* 98/Oct/5 */
-  ignore_frozen = false;     /* 98/Oct/5 */
-  suppress_f_ligs = false;      /* 99/Jan/5 */
-  full_file_name_flag = false;   // 00 Jun 18
-  save_strings_flag = false;    // 00 Aug 15
+  font_dimen_zero = false;
+  ignore_frozen = false;
+  suppress_f_ligs = false;
+  full_file_name_flag = false;
+  save_strings_flag = false;
   knuth_flag = true;       /* so other code can know about this */
-} /* end of knuthify */
+}
 
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
 
@@ -2301,12 +2451,23 @@ void knuthify (void)
 char * xchrfile = NULL;
 char * replfile = NULL;
 
-char * short_options = "viKLZMdp2t?u";
+char * short_options = "m:e:h:0:H:g:P:o:l:a:wvpiKLZMdp2t?u";
 
 static struct option long_options[] =
 {
-  //{"interaction",   1, 0, 0},
+  {"main-memory",   1, 0, 'm'},
+  {"hyph-size",     1, 0, 'e'},
+  {"trie-size",     1, 0, 'h'},
+  {"backend",       1, 0, '0'},
+  {"tab-step",      1, 0, 'H'},
+  {"percent-grow",  1, 0, 'g'},
+  {"default-rule",  1, 0, 'P'},
+  {"dvi-dir",       1, 0, 'o'},
+  {"log-dir",       1, 0, 'l'},
+  {"aux-dir",       1, 0, 'a'},
+  {"showhex",       0, 0, 'w'},
   {"verbose",       0, 0, 'v'},
+  {"patterns",      0, 0, 'p'},
   {"initex",        0, 0, 'i'},
   {"knuthify",      0, 0, 'K'},
   {"cstyle",        0, 0, 'L'},
@@ -2345,8 +2506,8 @@ int analyze_flag (int c, char *optarg)
       interaction = error_stop_mode; /* tex mode */
       break;
     case 'K':
-      backwardflag = true; /* 94/Jun/15 */
-      knuthify();         /* revert to `standard' Knuth TeX */
+      backwardflag = true;
+      knuthify(); /* revert to `standard' Knuth TeX */
       break;
     case 'L':
       c_style_flag = true; /* C style error msg 94/Mar/21 */
@@ -2354,12 +2515,6 @@ int analyze_flag (int c, char *optarg)
     case 'Z':
       show_tfm_flag = true; /* show TFM in log file 94/Jun/21 */
       break;
-    case 'c':
-      current_tfm = false; /* not look current dir for TFM */
-      break;
-    case 'C':
-      current_flag = false; /* not look current dir for files */
-      break;
     case 'M':
       show_missing = false; /* do not show missing 94/June/10 */
       break;
@@ -2381,9 +2536,6 @@ int analyze_flag (int c, char *optarg)
     case 'n':
       restrict_to_ascii = true; /* 0 - 127 1994/Jan/21 */
       break;
-    case '6':
-      workingdirectory = true; /* use source dir 98/Sep/29 */
-      break;
     case '7':
       usesourcedirectory = false; /* use working dir 98/Sep/29 */
       break;
@@ -2451,19 +2603,6 @@ int analyze_flag (int c, char *optarg)
     case 'Y':
       reorder_arg_flag = false; /* local */
       break;
-    case 'b':
-      test_dir_access = false; /* 94/Feb/10 */
-      break;
-    case 'D':
-      dir_method = false; /* 94/Feb/10 */
-      break;
-    case 'G':
-      file_method = false; /* 94/Feb/13 */
-      break;
-//  case 'V': share_flag = _SH_DENYNO; break; /* 0x40 - deny none mode */ 
-/*  case 'X': nohandler++; break; */
-/*  case 'f': waitflush = false; break; */
-/*  case 'F': floating = true; break; */
 /* *********** following command line options take arguments **************  */
     case 'm':
       if (optarg == 0)
@@ -2494,16 +2633,6 @@ int analyze_flag (int c, char *optarg)
         complainarg(c, optarg);
       break;
 #endif
-#ifdef ALLOCATEDVIBUF
-    case 'u':
-      if (optarg == 0)
-        dvi_buf_size = default_dvi_buf_size;
-      else
-        dvi_buf_size = atoi(optarg); /* 94/Mar/24 */
-      if (dvi_buf_size == 0)
-        complainarg(c, optarg);
-      break;
-#endif
     case 'g':
       if (optarg == 0)
         percent_grow = 62;
@@ -2522,9 +2651,6 @@ int analyze_flag (int c, char *optarg)
       else if (pseudo_tilde < 128)
         pseudo_tilde = 128;
       break;
-/*  case 'H':  if (optarg == 0) heapthreshold = 1024; else heapthreshold = atoi(optarg);
- *             if (heapthreshold == 0) complainarg(c, optarg); else heap_flag = 1;
- *             break; */
     case 'H':
       if (optarg == 0)
         tab_step = 8;
@@ -2538,6 +2664,7 @@ int analyze_flag (int c, char *optarg)
         xchrfile = xstrdup("xchr.map");
       else
         xchrfile = xstrdup(optarg);
+
       if (xchrfile == NULL || *xchrfile == '\0')
         complainarg(c, optarg);
       break;
@@ -2546,15 +2673,16 @@ int analyze_flag (int c, char *optarg)
         replfile = xstrdup("repl.key");
       else
         replfile = xstrdup(optarg);
+
       if (replfile == NULL || *replfile == '\0')
         complainarg(c, optarg);
       break;
-/* more obscure stuff - ppssibly recycle */
     case 'P':
       if (optarg == 0)
-        default_rule = 26214; /* 95/Oct/9 */
+        default_rule = 26214;
       else
-        default_rule = atoi(optarg); /* 95/Oct/9 */
+        default_rule = atoi(optarg);
+
       if (default_rule == 0)
         complainarg(c, optarg);
       break;
@@ -2569,18 +2697,35 @@ int analyze_flag (int c, char *optarg)
         dvi_directory = "";
       else
         dvi_directory = xstrdup(optarg);
+
       if (strcmp(dvi_directory, "") == 0)
         complainarg(c, optarg);
+
       break;
     case '0':
-      if (optarg == 0)
-        pdf_output_flag = true;
+      {
+        char * format_spec = NULL;
+
+        if (optarg != 0)
+          format_spec = xstrdup(optarg);
+
+        if (!strcmp(format_spec, "pdf"))
+          pdf_output_flag = true;
+        else if (!strcmp(format_spec, "dvi"))
+          pdf_output_flag = false;
+        else
+        {
+          sprintf(log_line, "ERROR: Do not understand argument value `%s'\n", format_spec);
+          show_line(log_line, 1);
+        }
+      }
       break;
     case 'l':
       if (optarg == 0)
         log_directory = "";
       else
         log_directory = xstrdup(optarg);
+
       if (strcmp(log_directory, "") == 0)
         complainarg(c, optarg);
       break;
@@ -2601,28 +2746,22 @@ int analyze_flag (int c, char *optarg)
   return 0;
 }
 
-/* remove file name - keep only path - inserts '\0' to terminate */
-
 void strip_name (char *pathname)
 {
   char *s;
-  if ((s = strrchr(pathname, '\\')) != NULL);
-  else if ((s = strrchr(pathname, '/')) != NULL);
-  else if ((s = strrchr(pathname, ':')) != NULL) s++;
-  else s = pathname;
-  *s = '\0';
-}
-
-/* char commandfile[PATH_MAX]; */ /* keep around so can open later */
 
-char *programpath = ""; /* pathname of program */
-                    /* redundant with texpath ? */
-
-/* The following does not deslashify arguments ? Do we need to ? */
+  if ((s = strrchr(pathname, '\\')) != NULL)
+    ;
+  else if ((s = strrchr(pathname, '/')) != NULL)
+    ;
+  else if ((s = strrchr(pathname, ':')) != NULL)
+    s++;
+  else
+    s = pathname;
 
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+  *s = '\0';
+}
 
-/* try and read commands on command line */
 int read_command_line (int ac, char **av)
 { 
   int c;
@@ -2647,9 +2786,9 @@ int read_command_line (int ac, char **av)
     stamp_it(log_line);
     strcat(log_line, "\n");
     show_line(log_line, 0);
-    stampcopy(log_line);
-    strcat(log_line, "\n");
-    show_line(log_line, 0);
+    //stampcopy(log_line);
+    //strcat(log_line, "\n");
+    //show_line(log_line, 0);
 
     if (show_use)
       show_usage();
@@ -2659,7 +2798,7 @@ int read_command_line (int ac, char **av)
       show_line(log_line, 0);
     }
 
-    return -1;        // failure
+    return -1; // failure
   } 
 
   if (replfile != NULL && *replfile != '\0')
@@ -2689,12 +2828,9 @@ int read_command_line (int ac, char **av)
 
 int init_commands (int ac, char **av)
 {
-/*  NOTE: some defaults changed 1993/Nov/18 */
-/*  want_version = show_use = switchflag = return_flag = false;
-  is_initex = trace_flag = deslash = non_ascii = false; */
   pdf_output_flag   = false;
-  is_initex         = false; /* check for dumping format file */
-  allow_patterns    = false; /* using \pattern after format file loaded */
+  is_initex         = false; 
+  allow_patterns    = false;
   reset_exceptions  = false;
   non_ascii         = false;
   key_replace       = false;
@@ -2702,7 +2838,6 @@ int init_commands (int ac, char **av)
   open_trace_flag   = false;
   trace_flag        = false;
   verbose_flag      = false;
-  heap_flag         = false;
   restrict_to_ascii = false;
   show_in_hex       = false; /* default is not to show as hex code ^^ 00/Jun/18 */
   show_in_dos       = false; /* default is not to translate to DOS 850 */ 
@@ -2716,61 +2851,47 @@ int init_commands (int ac, char **av)
   civilize_flag     = true;
   show_numeric      = true;
   show_missing      = true;
-  current_flag      = true;
-  current_tfm       = true;  /* search for TFMs in current dir as well */
-  test_dir_access   = true;  /* test if readable item is perhaps a sub-dir */
-  dir_method        = true;  /* in dir_p: _findfirst instead of use fopen (nul) */
-  file_method       = true;  /* use file_p (_findfirst) not readable (access) */
-/*  waitflush = true; */  /* flushed 97/Dec/24 */
   c_style_flag      = false; /* use c-style error output */
   show_fmt_flag     = true;  /* show format file in log */
   show_tfm_flag     = false; /* don't show metric file in log */
   shorten_file_name     = false; /* don't shorten file names to 8+3 */
   show_texinput_flag    = true;  /* show TEXINPUTS and TEXFONTS */
-  truncate_long_lines   = true; /* truncate long lines */
-  tab_step              = 0;      /* do not replace tabs with spaces */
+  truncate_long_lines   = true;  /* truncate long lines */
+  tab_step              = 0;     /* do not replace tabs with spaces */
   format_specific       = true;  /* do format specific TEXINPUTS 95/Jan/7 */
   encoding_specific     = true;  /* do encoding specific TEXFONTS 98/Jan/31 */
   show_line_break_stats = true;  /* show line break statistics 96/Feb/8 */
-  show_fonts_used       = true; /* show fonts used in LOG file 97/Dec/24 */
+  show_fonts_used       = true;  /* show fonts used in LOG file 97/Dec/24 */
   allow_quoted_names    = true;  /* allow quoted names with spaces 98/Mar/15 */
-  show_cs_names         = false;  /* don't show csnames on start 98/Mar/31 */
-  knuth_flag            = false;    /* allow extensions to TeX */
-  cache_file_flag       = true; /* default is to cache full file names 96/Nov/16 */
+  show_cs_names         = false; /* don't show csnames on start 98/Mar/31 */
+  knuth_flag            = false; /* allow extensions to TeX */
   full_file_name_flag   = true;  /* new default 2000 June 18 */
-  save_strings_flag     = true; // 2000 Aug 15
-  errout                = stdout;    /* as opposed to stderr say --- used ??? */
+  save_strings_flag     = true;
+  errout                = stdout; /* as opposed to stderr say --- used ??? */
   abort_flag            = 0;      // not yet hooked up ???
-  err_level             = 0;     // not yet hooked up ???
+  err_level             = 0;      // not yet hooked up ???
   new_hyphen_prime      = 0;
+
 #ifdef VARIABLETRIESIZE
 /*  trie_size = default_trie_size; */
   trie_size = 0;
 #endif
+
   mem_extra_high = 0;
   mem_extra_low  = 0;
   mem_initex     = 0;
-#ifdef ALLOCATEDVIBUF
-  dvi_buf_size = 0;
-#endif
-/*  share_flag = _SH_DENYNO; */ /* 0x40 - deny none mode */
-/*  share_flag = _SH_COMPAT; */ /* 0x00 - compatability mode */
-  share_flag = 0; /* revert to fopen for now */
-
-/*  strncpy(programpath, argv[0], PATH_MAX); */ /* 94/July/12 */
-  programpath = xstrdup(av[0]); /* extract path executable */
-  strip_name(programpath); /* strip off yandytex.exe */
 
-  format_name = "plain"; /* format name if specified on command line */
+  //format_name = xstrdup(av[0]);
+  format_name = "plain";
 
   encoding_name = "";
 
-  if (read_command_line(ac, av) < 0)  /* move out to subr 94/Apr/10 */
-    return -1;            // in case of error
+  if (read_command_line(ac, av) < 0)
+    return -1;
 
   if (optind == 0)
     optind = ac;
-
+/*
   if (want_version)
   {
     stamp_it(log_line);
@@ -2780,18 +2901,11 @@ int init_commands (int ac, char **av)
     strcat(log_line, "\n");
     show_line(log_line, 0);
   }
-
-/*  if we aren't including current directory in any directory lists */
-/*  then makes no sense to avoid them separately for TFM files ... */
-/*  (that is, the ./ is already omitted from the dir list in that case */
-  if (!current_flag && !current_tfm)
-    current_tfm = true; /* 94/Jan/24 */
+*/
 
   return 0;
 }
 
-/* E sets environment variable ? */
-
 void initial_memory (void)
 {
   /* set initial memory allocations */
@@ -2830,51 +2944,56 @@ void initial_memory (void)
   }
   if (mem_initex == 0)
     mem_initex = default_mem_top;
+
   if (trie_size == 0)
     trie_size = default_trie_size;
 /* Just in case user mistakenly specified words instead of kilo words */
-  if (mem_extra_high > 10000L * 1024L) mem_extra_high = mem_extra_high / 1024;
-  if (mem_extra_low > 10000L * 1024L) mem_extra_low = mem_extra_low / 1024;
-  if (mem_initex > 10000L * 1024L) mem_initex = mem_initex / 1024;
-#ifdef ALLOCATEHIGH         /* not used anymore */
-  if (mem_extra_high > 2048L * 1024L) { /* extend SW area by 16 mega byte! */
-    show_line("WARNING: There may be no benefit to asking for so much memory\n", 0);
-    mem_extra_high = 2048 * 1024; /* limit to SW to 4 x VLR */
-  }
-#endif
-#ifdef ALLOCATELOW          /* not used anymore */
-  if (mem_extra_low > 2048L * 1024L) { /* extend VL area by 16 mega byte! */
-    show_line("WARNING: There may be no benefit to asking for so much memory\n", 0);
-    mem_extra_low = 2048 * 1024; /* limit VLR to 4 x SW */
-  }
-#endif
-  if (mem_initex > 2048L * 1024L) { /* extend main memory by 16 mega byte! */
+  if (mem_extra_high > 10000L * 1024L)
+    mem_extra_high = mem_extra_high / 1024;
+
+  if (mem_extra_low > 10000L * 1024L)
+    mem_extra_low = mem_extra_low / 1024;
+
+  if (mem_initex > 10000L * 1024L)
+    mem_initex = mem_initex / 1024;
+
+  if (mem_initex > 2048L * 1024L) /* extend main memory by 16 mega byte! */
+  {
     show_line("WARNING: There may be no benefit to asking for so much memory\n", 0);
 /* mem_initex = 2048 * 1024; */
   }
- #ifdef ALLOCATEDVIBUF
-  if (dvi_buf_size == 0) dvi_buf_size = default_dvi_buf_size;
-/* if less than 1024 assume user specified kilo-bytes, not bytes */
-  if (dvi_buf_size < 1024) dvi_buf_size = dvi_buf_size * 1024;
-  if (dvi_buf_size % 8 != 0)        /* check multiple of eight */
-    dvi_buf_size = (dvi_buf_size / 8 + 1) * 8;
- #endif
-  if (new_hyphen_prime < 0) new_hyphen_prime = 0;
-  if (new_hyphen_prime > 0) {
+
+  if (new_hyphen_prime < 0)
+    new_hyphen_prime = 0;
+
+  if (new_hyphen_prime > 0)
+  {
     if (! is_initex)
       show_line("ERROR: Can only set hyphen prime in iniTeX\n", 1);
-    else {
-      if (new_hyphen_prime % 2 == 0) new_hyphen_prime++;
-      while (!prime(new_hyphen_prime)) new_hyphen_prime = new_hyphen_prime+2;
-      if (trace_flag) {
+    else
+    {
+      if (new_hyphen_prime % 2 == 0)
+        new_hyphen_prime++;
+
+      while (!prime(new_hyphen_prime))
+        new_hyphen_prime = new_hyphen_prime + 2;
+
+      if (trace_flag)
+      {
         sprintf(log_line, "Using %d as hyphen prime\n", new_hyphen_prime);
         show_line(log_line, 0);
       }
     }
   }
-  if (percent_grow > 100) percent_grow = percent_grow - 100;
-  if (percent_grow > 100) percent_grow = 100;   /* upper limit - double */
-  if (percent_grow < 10) percent_grow = 10;   /* lower limit - 10% */
+
+  if (percent_grow > 100)
+    percent_grow = percent_grow - 100;
+
+  if (percent_grow > 100)
+    percent_grow = 100;   /* upper limit - double */
+
+  if (percent_grow < 10)
+    percent_grow = 10;   /* lower limit - 10% */
 }
 
 /**********************************************************************/
@@ -2885,38 +3004,6 @@ void perrormod (char *s)
   show_line(log_line, 1);
 }
 
-void pause (void)
-{
-#ifndef _WINDOWS
-  fflush(stdout);     /* ??? */
-  fflush(stderr);     /* ??? */
-  (void) _getch();    /* ??? */
-#endif
-}
-
-void checkpause (int flag)
-{            /* 95/Oct/28 */
-  char *s;
-  int debug_pause = 0;
-/*  don't stop if in Q (quiet) or R (run) mode */
-/*  stop only in S (scroll) and T (TeX) mode */
-  if (interaction >= 0 && interaction < 2)
-    flag = 0;    /* 98/Jun/30 */
-  s = grabenv("DEBUGPAUSE");
-  if (s != NULL) sscanf(s, "%d", &debug_pause);
-  if (flag < 0) return;
-  if (debug_pause) {
-    if (debug_pause || flag > 0) {
-      show_line("\n", 0);
-#ifndef _WINDOWS
-      show_line("Press any key to continue . . .\n", 0);
-      pause();
-#endif
-    }
-  }
-}
-
-
 /*************************************************************************/
 
 /* convert tilde to pseudo_tilde to hide it from TeX --- 95/Sep/26 */
@@ -2959,40 +3046,68 @@ void deslash_all (int ac, char **av)
   char buffer[PATH_MAX];  
   char *s;
 
-/* environment variables for output directories (as in PC TeX) */
+  if ((s = grabenv("TEXDVI")) != NULL)
+    dvi_directory = s;
+
+  if ((s = grabenv("TEXLOG")) != NULL)
+    log_directory = s;
 
-  if ((s = grabenv("TEXDVI")) != NULL) dvi_directory = s;
-  if ((s = grabenv("TEXLOG")) != NULL) log_directory = s;
-  if ((s = grabenv("TEXAUX")) != NULL) aux_directory = s;
-  if ((s = grabenv("TEXFMT")) != NULL) fmt_directory = s;
-  if ((s = grabenv("TEXPDF")) != NULL) pdf_directory = s;
+  if ((s = grabenv("TEXAUX")) != NULL)
+    aux_directory = s;
 
-  strcpy(buffer, av[0]);            /* get path to executable */
+  if ((s = grabenv("TEXFMT")) != NULL)
+    fmt_directory = s;
+
+  if ((s = grabenv("TEXPDF")) != NULL)
+    pdf_directory = s;
+
+  strcpy(buffer, av[0]); /* get path to executable */
 
   if ((s = strrchr(buffer, '\\')) != NULL) *(s+1) = '\0';
   else if ((s = strrchr(buffer, '/')) != NULL) *(s+1) = '\0';
   else if ((s = strrchr(buffer, ':')) != NULL) *(s+1) = '\0';
+
   s = buffer + strlen(buffer) - 1;
+
   if (*s == '\\' || *s == '/') *s = '\0';   /* flush trailing PATH_SEP */
+
   texpath = xstrdup(buffer);
 
 /*  Hmm, we may be operating on DOS environment variables here !!! */
 
-  if (strcmp(dvi_directory, "") != 0) flush_trailing_slash (dvi_directory);
-  if (strcmp(log_directory, "") != 0) flush_trailing_slash (log_directory);
-  if (strcmp(aux_directory, "") != 0) flush_trailing_slash (aux_directory);
-  if (strcmp(fmt_directory, "") != 0) flush_trailing_slash (fmt_directory);
-  if (strcmp(pdf_directory, "") != 0) flush_trailing_slash (pdf_directory);
+  if (strcmp(dvi_directory, "") != 0)
+    flush_trailing_slash (dvi_directory);
+
+  if (strcmp(log_directory, "") != 0)
+    flush_trailing_slash (log_directory);
+
+  if (strcmp(aux_directory, "") != 0)
+    flush_trailing_slash (aux_directory);
+
+  if (strcmp(fmt_directory, "") != 0)
+    flush_trailing_slash (fmt_directory);
+
+  if (strcmp(pdf_directory, "") != 0)
+    flush_trailing_slash (pdf_directory);
 
   if (deslash)
   {
-      unixify (texpath);          /* 94/Jan/25 */
-/* if output directories given, deslashify them also 1993/Dec/12 */
-      if (strcmp(dvi_directory, "") != 0) unixify(dvi_directory);
-      if (strcmp(log_directory, "") != 0) unixify(log_directory);
-      if (strcmp(aux_directory, "") != 0) unixify(aux_directory);
-      if (strcmp(fmt_directory, "") != 0) unixify(fmt_directory);
-      if (strcmp(pdf_directory, "") != 0) unixify(pdf_directory);
+      unixify (texpath);
+
+      if (strcmp(dvi_directory, "") != 0)
+        unixify(dvi_directory);
+
+      if (strcmp(log_directory, "") != 0)
+        unixify(log_directory);
+
+      if (strcmp(aux_directory, "") != 0)
+        unixify(aux_directory);
+
+      if (strcmp(fmt_directory, "") != 0)
+        unixify(fmt_directory);
+
+      if (strcmp(pdf_directory, "") != 0)
+        unixify(pdf_directory);
   }
 
 /*  deslash TeX source file (and format, if format specified) */
@@ -3002,33 +3117,45 @@ void deslash_all (int ac, char **av)
 /*  if (trace_flag || debug_flag)
     sprintf(log_line, "optind %d ac %d\n", optind, ac); */   /* debugging */ 
 /*  if (optind < ac) { */           /* bkph */
-  if (optind < ac && optind > 0) {      /* paranoia 94/Apr/10 */
-    if (deslash) {
-      if (trace_flag || debug_flag) {
+  if (optind < ac && optind > 0)
+  {
+    if (deslash)
+    {
+      if (trace_flag || debug_flag)
+      {
         sprintf(log_line, "deslash: k %d argv[k] %s (argc %d)\n",
           optind, av[optind], ac);
         show_line(log_line, 0);
       }
+
       unixify(av[optind]);
     }
+
     if (pseudo_tilde != 0 || pseudo_space != 0)
-      hidetwiddle (av[optind]);     /* 95/Sep/25 */
-/* For Windows NT, lets allow + instead of & for format specification */
-    if (*av[optind] == '&' || *av[optind] == '+') {
-      format_spec = 1; /* format file specified */
-      format_name = xstrdup(av[optind]+1); /* 94/Oct/25 */
-/*      uppercase (format_name); */    /* why ? 98/Jan/31 */
-      if (optind + 1 < ac) {
-        if (deslash) {
-          if (trace_flag || debug_flag) {
+      hidetwiddle (av[optind]);
+
+    /* For Windows NT, lets allow + instead of & for format specification */
+    if (*av[optind] == '&' || *av[optind] == '+')
+    {
+      format_spec = 1;
+      format_name = xstrdup(av[optind] + 1);
+
+      if (optind + 1 < ac)
+      {
+        if (deslash)
+        {
+          if (trace_flag || debug_flag)
+          {
             sprintf(log_line, "deslash: k %d argv[k] %s (argc %d)\n",
-              optind+1, av[optind+1], ac);
+              optind + 1, av[optind + 1], ac);
             show_line(log_line, 0);
           }
-          unixify(av[optind+1]);
+
+          unixify(av[optind + 1]);
         }
+
         if (pseudo_tilde != 0 || pseudo_space != 0)
-          hidetwiddle (av[optind+1]); /* 95/Sep/25 */
+          hidetwiddle (av[optind + 1]);
       }
     }         
   }
@@ -3038,65 +3165,58 @@ void deslash_all (int ac, char **av)
 /* are file names or format names - what if type in control sequences? */
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
 /* main entry point follows */
-
 /* this gets called pretty much right away in `main' in texmf.c */
-
 /* note: those optarg == 0 test don't really work ... */
 /* note: optarg starts at = in case of x=... */
 
 int main_init (int ac, char **av)
 {
-  char initbuffer[PATH_MAX];
   int k;
 
   kpse_set_program_name(av[0], NULL);
+  xputenv("engine", "yandytex");
 
-  // compile time test
-  if (sizeof(memory_word) != 8)
+  if (sizeof(memory_word) != sizeof(halfword) * 2)
   {
     sprintf(log_line, "ERROR: Bad word size %d!\n", sizeof(memory_word));
     show_line(log_line, 1);
   }
 
   start_time = clock();
-  main_time = start_time;
+  main_time  = start_time;
 
-  initbuffer[0] = '\0';         /* paranoia 94/Apr/10 */
-
-/*  reset all allocatable memory pointers to NULL - in case we drop out */
-  mainmemory = NULL;
-  font_info = NULL;
-  str_pool = NULL;
-  str_start = NULL;
+/* reset all allocatable memory pointers to NULL - in case we drop out */
+  main_memory = NULL;
+  font_info   = NULL;
+  str_pool    = NULL;
+  str_start   = NULL;
 
 #ifdef ALLOCATESAVESTACK
   save_stack = NULL; 
 #endif
 
 #ifdef ALLOCATEBUFFER
-  buffer = NULL;        /* new 1999/Jan/7 need to do early */
+  buffer           = NULL;
   current_buf_size = 0;
-  buffer = realloc_buffer (initial_buf_size);
+  buffer           = realloc_buffer (initial_buf_size);
 #endif
 
-  hyph_list = NULL;
-  hyph_word = NULL;
+  hyph_list  = NULL;
+  hyph_word  = NULL;
   trie_taken = NULL;
-  trie_hash = NULL;
-  trie_r = NULL;
-  trie_c = NULL;
-  trie_o = NULL;
-  trie_l = NULL;
-  trie_trc = NULL;
-  trie_tro = NULL;
-  trie_trl = NULL;
+  trie_hash  = NULL;
+  trie_r     = NULL;
+  trie_c     = NULL;
+  trie_o     = NULL;
+  trie_l     = NULL;
+  trie_trc   = NULL;
+  trie_tro   = NULL;
+  trie_trl   = NULL;
 
   log_opened = false;       /* so can tell whether opened */
   interaction = -1;         /* default state => 3 */
   missing_characters = 0;   /* none yet! */
-  workingdirectory = false; /* set from dviwindo.ini & command line */
   font_dimen_zero = true;   /* \fontdimen0 for checksum 98/Oct/5 */
   ignore_frozen = false;    /* default is not to ignore 98/Oct/5 */
   suppress_f_ligs = false;  /* default is not to ignore f-ligs */
@@ -3108,12 +3228,11 @@ int main_init (int ac, char **av)
     reorderargs(ac, av);  
 
   if (init_commands(ac, av))
-    return -1;          // failure
+    return -1;
 
-  check_fixed_align(trace_flag);       /* sanity check 1994/Jan/8 */
+  check_fixed_align(trace_flag);
 
   format_file   = NULL;
-  string_file   = NULL;
   source_direct = NULL;
   dvi_file_name = NULL;
   log_file_name = NULL;
@@ -3128,22 +3247,19 @@ int main_init (int ac, char **av)
   underfull_hbox    = 0;
   overfull_vbox     = 0;
   underfull_vbox    = 0;
-
-  closed_already=0;        // so can only do once
+  closed_already    = 0;
 
   if (trace_flag)
     show_line("Entering init (local)\n", 0);
 
-  probe_memory();             /* show top address */
-  ini_max_address = max_address;       /* initial max address */
+  probe_memory(); /* show top address */
+  ini_max_address = max_address; /* initial max address */
 
   if (trace_flag)
     show_maximums(stdout);
 
   initial_memory();
-
-  deslash_all(ac, av);    /* deslash and note if format specified */
-
+  deslash_all(ac, av); /* deslash and note if format specified */
   no_interrupts = 0;
 
   if (format_spec && mem_spec_flag)
@@ -3154,13 +3270,13 @@ int main_init (int ac, char **av)
   if (allocate_memory() != 0)   /* NOW, try and ALLOCATE MEMORY if needed */
     return -1;         // if failed to allocate
 
-/*   following is more or less useless since most all things not yet alloc */
-   check_alloc_align(trace_flag);    /* sanity check 1994/Jan/8 */
+  /* following is more or less useless since most all things not yet alloc */
+  check_alloc_align(trace_flag);    /* sanity check 1994/Jan/8 */
 
   if (trace_flag)
     show_line("Leaving init (local)\n", 0);
 
-  return 0;         // success
+  return 0;
 }
 
 #define CLK_TCK  CLOCKS_PER_SEC
@@ -3196,12 +3312,9 @@ void show_inter_val (clock_t interval)
         show_line(log_line, 0);
       }
       else
-        show_line("0", 0);          /* 95/Mar/1 */
+        show_line("0", 0);
 }
 
-/* final cleanup opportunity */ /* flag is non-zero if error exit */
-/* shows various times, warning about missing chars */
-
 int endit (int flag)
 {
   finish_time = clock();
@@ -3233,24 +3346,22 @@ int endit (int flag)
     if (total_pages > 0)
     {
       show_inter_val ((finish_time - main_time) / total_pages);
-      show_line(" sec per page", 0);
+      show_line(" sec per page.", 0);
     }
 
     show_line("\n", 0);
   }
 
-  checkpause(flag);
-
   return flag;
 }
-
+// printf control sequences' name
 void print_cs_name (FILE *output, int h)
 {
   int c, textof, n;
 
   memset(log_line, 0, sizeof(log_line));
 
-  textof = hash[h].v.RH;
+  textof = hash[h].rh;
 
   if (textof == 0)
     return;
@@ -3274,19 +3385,17 @@ void print_cs_name (FILE *output, int h)
   }
 
 }
-
-int compare_strn (int, int, int, int); /* in tex9.c */
-
+// prototype
+int compare_strn (int, int, int, int);
 /* compare two csnames in qsort */
-
 int compare_cs (const void *cp1, const void *cp2)
 {
   int c1, c2, l1, l2, k1, k2, textof1, textof2;
 
   c1 = *(int *)cp1;
   c2 = *(int *)cp2;
-  textof1 = hash[c1].v.RH;
-  textof2 = hash[c2].v.RH;
+  textof1 = hash[c1].rh;
+  textof2 = hash[c2].rh;
   l1 = length(textof1); 
   l2 = length(textof2); 
   k1 = str_start[textof1]; 
@@ -3295,11 +3404,11 @@ int compare_cs (const void *cp1, const void *cp2)
   return compare_strn (k1, l1, k2, l2);
 }
 
-char *csused = NULL;
+char * csused = NULL;
 
 /* Allocate table of indeces to allow sorting on csname */
 /* Allocate flags to remember which ones already listed at start */
-/* pass = 0 --> fmt */
+/* pass = 0 --> fmt   */
 /* pass = 1 --> after */
 void print_cs_names (FILE *output, int pass)
 {
@@ -3329,7 +3438,7 @@ void print_cs_names (FILE *output, int pass)
     if (pass == 1 && csused[h])
       continue;
 
-    if (hash[h].v.RH != 0)
+    if (hash[h].rh != 0)
     {
       if (pass == 0)
         csused[h] = 1;
@@ -3353,7 +3462,7 @@ void print_cs_names (FILE *output, int pass)
       fprintf(output, log_line);
   }
 
-  if (ccount > 0) /* don't bother to get into trouble */
+  if (ccount > 0)
   {
     cnumtable = (int *) malloc (ccount * sizeof(int));
 
@@ -3361,13 +3470,13 @@ void print_cs_names (FILE *output, int pass)
       return;
 
     ccount = 0;
-/*    for (h = 515; h < (hash_size + 780); h++) { */
+
     for (h = hash_base + 1; h < nfcs; h++)
     {
       if (pass == 1 && csused[h])
         continue;
 
-      if (hash[h].v.RH != 0)
+      if (hash[h].rh != 0)
         cnumtable[ccount++] = h;
     }
 
@@ -3413,7 +3522,6 @@ void print_cs_names (FILE *output, int pass)
 /* compare two strings in str_pool (not null terminated) */
 /* k1 and k2 are positions in string pool */
 /* l1 and l2 are lengths of strings */
-
 int compare_strn (int k1, int l1, int k2, int l2)
 {
   int c1, c2;
@@ -3439,9 +3547,7 @@ int compare_strn (int k1, int l1, int k2, int l2)
 
   return 0;         /* strings match */
 }
-
 /* compare two font names and their at sizes in qsort */
-
 int compare_fnt (const void *fp1, const void *fp2)
 {
   int f1, f2, l1, l2, k1, k2, s;
@@ -3465,9 +3571,7 @@ int compare_fnt (const void *fp1, const void *fp2)
 
   return 0;         /* should not ever get here */
 }
-
 /* compare two font names */
-
 int compare_fnt_name (int f1, int f2)
 {
   int l1, l2, k1, k2, s;
@@ -3481,11 +3585,8 @@ int compare_fnt_name (int f1, int f2)
 
   return s;
 }
-
 /* decode checksum information */
-
-unsigned long checkdefault = 0x59265920;  /* default signature */
-
+unsigned long checkdefault = 0x59265920; /* default signature */
 int decode_fourty (unsigned long checksum, char *codingvector)
 {
   int c;
@@ -3520,8 +3621,8 @@ int decode_fourty (unsigned long checksum, char *codingvector)
       }
       codingvector[6] = '\0';
     }
-/*  sprintf(log_line, "Reconstructed vector %s\n", codingvector); */
-  return 0;         /* encoding info returned in codingvector */
+
+  return 0;
 }
 
 double sclpnt (long x)
@@ -3535,7 +3636,6 @@ double sclpnt (long x)
 }
 
 // Shows list of fonts in log file
-
 void dvi_font_show(internal_font_number f, int suppressname)
 {
   int a, l, k, n;
@@ -3582,9 +3682,7 @@ void dvi_font_show(internal_font_number f, int suppressname)
 
   putc('\n', log_file);
 }
-
 /* Allocate table of indeces to allow sorting on font name */
-
 void show_font_info (void)
 {
   int k, m, fcount, repeatflag;
@@ -3627,26 +3725,4 @@ void show_font_info (void)
   }
 
   free((void *)fnumtable);
-}
-
-/*  NOTE: current_tfm = false (-c)
-  not checking for TFM in current directory saves 0.1 sec
-  (0.2 if file_method = false (-G) */
-
-/*  NOTE: test_dir_access = false (-b):
-  not checking whether readable file is a directory saves maybe 0.5 sec
-  BUT only if file_method = false (-G) - otherwise its irrelevant */
-
-/*  NOTE: dir_method = false (-D) --- method for checking whether directory
-  using fopen instead of _findfirst in dir_p slows job maybe 0.05 sec
-  BUT not if current_tfm = false (-c) */
-
-/*  NOTE: file_method = false (-G) --- method for checking file accessible
-  using _access (readable) instead of _findfirst (file_p) costs 0.5 sec */
-
-/*  Fast flag combinations: nothing, bG, bcG, bcDG */
-
-/* buffercopy no longer used */
-
-/* To Knuthian reset right when command line interpreted */
-
+}
\ No newline at end of file