w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

aptex-src.c
Go to the documentation of this file.
1 /*
2  Copyright 2007 TeX Users Group
3  Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Clerk Ma
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301 USA.
19 */
20 
21 #include "aptex.h"
22 
23 static int mem_initex;
24 static int new_hyphen_prime;
25 static char * format_name;
26 // line break stats
27 static int lbs_pass_fst;
28 static int lbs_pass_snd;
29 static int lbs_pass_fin;
30 static int lbs_sing_line;
31 // hpack stats
32 static int hps_underfull;
33 static int hps_overfull;
34 // vpack stats
35 static int vps_underfull;
36 static int vps_overfull;
37 
38 #if defined (__clang__)
39 static const char * compiler = "Clang";
40 #elif defined (__GNUC__) || defined(__GNUG__)
41 static const char * compiler = "GCC";
42 #elif defined (_MSC_VER)
43 static const char * compiler = "MSVC";
44 #else
45 static const char * compiler = "Unknown";
46 #endif
47 
48 #if defined (_WIN64)
49 static const char * dist = "Win64";
50 #elif defined (_WIN32)
51 static const char * dist = "Win32";
52 #elif defined (__ANDROID__)
53 static const char * dist = "Android";
54 #elif defined (__APPLE__)
55 static const char * dist = "Darwin";
56 #elif defined (__gnu_linux__)
57 static const char * dist = "Linux";
58 #else
59 static const char * dist = "Unknown";
60 #endif
61 
62 #if defined (W32TeX)
63 static const char * banner = "This is Asiatic pTeX, Version 3.141592653 (W32TeX)";
64 #else
65 static const char * banner = "This is Asiatic pTeX, Version 3.141592653";
66 #endif
67 
68 static void aptex_utils_exit (int unix_code)
69 {
71  exit(unix_code);
72 }
73 
74 static void print_aptex_usage (void)
75 {
76  printf("\n"
77  "Useage: aptex [OPTION]... [+fmt_file_name] [file]\n\n"
78  " --help\n"
79  " show this usage summary\n"
80  " --version\n"
81  " output version information and exit\n"
82  " --ini\n"
83  " start up as INITEX (create format file)\n"
84  " --shell-escape\n"
85  " enable \\write18\n"
86  " --merge-kanji-baseline\n"
87  " shift baseline of OpenType's ascender/descender to JFM's height/depth\n"
88  " --visual-debug\n"
89  " when ship out DVI, show ApTeX's internal node to PNG/PDF via Cairo\n"
90  "\n"
91  " --mrb-load-file\n"
92  " execute file of mruby\n"
93  " --mrb-load-string\n"
94  " execute string of mruby\n"
95  "\n"
96  " --jobname=str\n"
97  " set the job name to str, e.g.: '--jobname=book2016'\n"
98  " --progname=str\n"
99  " set program (and fmt) name to str\n"
100  " --synctex=num\n"
101  " generate SyncTeX data for previewers if nonzero\n"
102  " --fontmap=map\n"
103  " +mapfile (append mode), !mapfile (replace mode), e.g.: '--fontmap=!replace.map'\n"
104  " --format=fmt\n"
105  " set preloaded format, e.g.: 'aptex --format=plain name.tex'\n"
106  "\n"
107  " --patterns\n"
108  " (INITEX only) allow use of \\patterns after loading format\n"
109  " --main-mem\n"
110  " (INITEX only) initial main memory size in kilo words\n"
111  " --hyph-size\n"
112  " (INITEX only) hyphenation exception dictionary size\n"
113  " --trie-size\n"
114  " (INITEX only) hyphenation pattern trie size\n\n"
115  "Email bug reports to clerkma@gmail.com.\n"
116  );
118 }
119 
120 static void print_aptex_version (void)
121 {
122  printf("Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020 Clerk Ma.\n"
123  "banner: \"%s\"\n"
124  "base: Y&Y TeX 2.3.0, pTeX%s, upTeX%s\n"
125  "Compiled with %s\n"
126  "Compiled with %s\n"
127  "Compiled with libotf version %s\n"
128  "Compiled with zlib version %s\n"
129  "Compiled with mruby version %s\n"
130  "Compiled with synctex (build-in edition)\n"
131  "Compiled with libdpx (build-in dvipdfmx)\n",
136 }
137 
138 // Sep 27 1990 => 1990 Sep 27
139 // 0123456789 0123456789
140 static void scivilize (char * date)
141 {
142  int k;
143  char pyear[6];
144 
145  strcpy(pyear, date + 7);
146 
147  for (k = 5; k >= 0; k--)
148  date[k + 5] = date[k];
149 
150  for (k = 0; k < 4; k++)
151  date[k] = pyear[k];
152 
153  date[4] = ' ';
154 
155  if (date[9] == ' ')
156  date[9] = '0';
157 }
158 
159 static void print_aptex_info (void)
160 {
161  char date[11 + 1];
162  char * executable_path;
163 
164  strcpy(date, __DATE__);
165  scivilize(date);
166  printf("Asiatic pTeX (compiled time: %s %s with %s/%s)\n",
168 
169  executable_path = (char *) calloc(65536, 1);
170 
171 #if defined (_WIN32) || defined (_WIN64)
172  GetModuleFileNameA(NULL, executable_path, 65536);
173 #elif defined (__gnu_linux__) || defined (__ANDROID__)
174  ssize_t executable_size;
175  executable_size = readlink("/proc/self/exe", executable_path, 65536);
176 #elif defined (__NetBSD__)
177  ssize_t executable_size;
178  executable_size = readlink("/proc/curproc/exe", executable_path, 65536);
179 #elif defined (__DragonFly__)
180  ssize_t executable_size;
181  executable_size = readlink("/proc/curproc/file", executable_path, 65536);
182 #elif defined (__APPLE__)
183  extern int _NSGetExecutablePath(char* buf, uint32_t* bufsize);
184  uint32_t executable_path_length;
185  _NSGetExecutablePath(executable_path, &executable_path_length);
186 #endif
187 
188 #if defined (__sun)
189  printf("Executable PATH: '%s'.\n", getexecname());
190 #else
191  printf("Executable PATH: '%s'.\n", executable_path);
192 #endif
193 
194  free(executable_path);
195 }
196 
197 static void print_aptex_time (clock_t inter_val)
198 {
199  int seconds, tenths, hundredth, thousands;
200 
201  if (inter_val >= CLOCKS_PER_SEC * 10)
202  {
203  tenths = (inter_val * 10 + CLOCKS_PER_SEC / 2) / CLOCKS_PER_SEC;
204  seconds = tenths / 10;
205  tenths = tenths % 10;
206  printf("%d.%d", seconds, tenths);
207  }
208  else if (inter_val >= CLOCKS_PER_SEC)
209  {
210  hundredth = (inter_val * 100 + CLOCKS_PER_SEC / 2) / CLOCKS_PER_SEC;
211  seconds = hundredth / 100;
212  hundredth = hundredth % 100;
213  printf("%d.%02d", seconds, hundredth);
214  }
215  else if (inter_val > 0)
216  {
217  thousands = (inter_val * 1000 + CLOCKS_PER_SEC / 2) / CLOCKS_PER_SEC;
218  seconds = thousands / 1000;
219  thousands = thousands % 1000;
220  printf("%d.%03d", seconds, thousands);
221  }
222  else
223  printf("0");
224 }
225 
226 #define MAXSPLITS 3
227 
228 /* ad hoc default minimum growth in memory realloc is 62% */
229 /* golden ratio (1 + \sqrt{5}) / 2 = 1.618033989... */
230 static int percent_grow = 62; /* default minimum growth in memory realloc is 62% */
231 static intptr_t total_allocated = 0; /* total memory allocated so far */
232 static intptr_t max_address = 0; /* maximum address seen in allocated memory */
233 
234 static void aptex_trace (const char * fmt_str, ...)
235 {
236  va_list m_ptr;
237  va_start(m_ptr, fmt_str);
238 
239  if (aptex_env.trace_mem)
240  {
241  // format => "[Sun Aug 28 14:22:05 2015] (I/V): blabla"
242  time_t time_present;
243  time(&time_present);
244  fprintf(stderr, "[%.24s] (%s): ", asctime(localtime(&time_present)),
245  aptex_env.flag_initex == true ? "I" : "V");
246  vfprintf(stderr, fmt_str, m_ptr);
247  }
248  va_end(m_ptr);
249 }
250 
251 static void aptex_memory_error (const char * s, int n)
252 {
253  aptex_trace("Unable to allocate %d bytes for '%s'\n", n, s);
254  aptex_trace("Max allocated %d, max address %p\n", total_allocated, max_address);
255 }
256 
257 static void aptex_memory_trace (const char * s, int n)
258 {
259  aptex_trace("Allocating %d bytes for '%s'\n", n, s);
260 }
261 
262 static void aptex_memory_update_statistics (intptr_t address, int size, int old_size)
263 {
264  if (address + size > max_address)
266 
267  total_allocated = total_allocated + size - old_size;
268 }
269 
270 static void aptex_memory_probe (void)
271 {
272  if (aptex_env.trace_mem)
273  {
274  aptex_trace("Max allocated %d, max address %p\n", total_allocated, max_address);
275  }
276 }
277 
278 static size_t roundup (size_t n)
279 {
280  if ((n % sizeof(void *)) == 0)
281  return n;
282  else
283  return ((n / sizeof(void *)) + 1) * sizeof(void *);
284 }
285 
286 static boolean prime (int x)
287 {
288  int k;
289  int sum = 1; /* 1 + 3 + 5 + k = (k + 1) * (k + 1) / 4 */
290 
291  if (x % 2 == 0)
292  return false;
293 
294  for (k = 3; k < x; k = k + 2)
295  {
296  if (x % k == 0)
297  return false;
298 
299  if (sum * 4 > x)
300  return true;
301 
302  sum += k;
303  }
304 
305  return true;
306 }
307 
308 #ifdef APTEX_EXTENSION
309 // -1 - fails
310 // 0 - success
311 
312 static int allocate_tries (int trie_max)
313 {
314  int n, nl, no, nc;
315 
316  if (trie_max > 1000000)
317  trie_max = 1000000;
318 
319  nl = (trie_max + 1) * sizeof(halfword);
320  no = (trie_max + 1) * sizeof(halfword);
321  nc = (trie_max + 1) * sizeof(quarterword);
322  n = nl + no + nc;
323 
324  aptex_memory_trace("hyphen trie", n);
325 
328  trie_trc = (quarterword *) malloc(roundup(nc));
329 
330  if (trie_trl == NULL || trie_tro == NULL || trie_trc == NULL)
331  {
332  aptex_memory_error("hyphen trie", n);
333 
334  return -1;
335  }
336 
338 
339  aptex_trace("Addresses trie_trl %p \n", trie_trl);
340  aptex_trace("Addresses trie_tro %p \n", trie_tro);
341  aptex_trace("Addresses trie_trc %p \n", trie_trc);
346 
347  return 0;
348 }
349 
350 /* remember in case reallocated later */
351 static int current_prime = 0;
352 
353 /* we don't return an address here, since TWO memory regions allocated */
354 /* plus, we don't really reallocate, we FLUSH the old information totally */
355 /* returns -1 if it fails */
356 
357 static int realloc_hyphen (int hyphen_prime)
358 {
359  int n, nw, nl;
360 
361  if (!prime(hyphen_prime))
362  {
363  aptex_trace("ERROR: non-prime hyphen exception number (%d)\n", hyphen_prime);
364  return -1;
365  }
366 
367 /* need not/cannot preserve old contents when hyphen prime is changed */
368 /* if (hyph_list != NULL) free(hyph_list); */
369 /* if (hyph_word != NULL) free(hyph_word); */
370  nw = (hyphen_prime + 1) * sizeof(str_number);
371  nl = (hyphen_prime + 1) * sizeof(halfword);
372  n = nw + nl;
373 
374  aptex_memory_trace("hyphen exception", n);
375 
378 
379  if (hyph_word == NULL || hyph_list == NULL)
380  {
381  aptex_memory_error("hyphen exception", n);
382  return -1;
383  }
384 
385  memset(hyph_word, 0, (hyphen_prime + 1) * sizeof (hyph_word[0]));
386  memset(hyph_list, 0, (hyphen_prime + 1) * sizeof (hyph_list[0]));
387 
388  hyph_count = 0;
389 
390  aptex_trace("Addresses hyph_word @ %p hyph_list @ %p\n", hyph_word, hyph_list);
391 
392  if (current_prime != 0)
393  {
396  }
397  else
398  {
401  }
402 
404 
406 
407  return 0; // success
408 }
409 
411 {
412  int n;
413 
414  if (main_memory != NULL)
415  aptex_trace("Reallocating initial memory allocation");
416 
417  mem_top = mem_bot + size;
418  mem_max = mem_top;
419  mem_start = 0; /* bottom of memory allocated by system */
420  mem_min = 0; /* bottom of area made available to TeX */
421  n = (mem_max - mem_start + 1) * ((int) sizeof(memory_word));
422 
423  aptex_memory_trace("main memory", n);
424 
426 
427  if (main_memory == NULL)
428  {
429  aptex_memory_error("initial main memory", n);
430  return NULL;
431  }
432 
433  aptex_trace("Address main memory == %p\n", main_memory);
434 
435  mem = main_memory;
436 
437  if (mem_start != 0 && !aptex_env.flag_initex)
439 
440  aptex_trace("Offset address main memory == %p\n", mem);
442  current_mem_size = mem_max - mem_start; /* total number of words - 1 *//* current_mem_size = (mem_max - mem_start + 1); */
444 
445  return mem;
446 }
447 
448 /* increase main memory allocation at low end and high end */
449 /* called with one of lo_size or hi_size == 0 */
450 /* returns NULL if it fails */
451 
452 static memory_word * realloc_mem (int lo_size, int hi_size)
453 {
454  int k, min_size;
455  int new_size = 0;
456  int n = 0;
457  memory_word * new_memory = NULL;
458 
459  aptex_trace("WARNING: Entering realloc_main lo %d hi %d\n", lo_size, hi_size);
460 
461  if (aptex_env.flag_initex)
462  {
463  puts("ERROR: Cannot extent main memory in initex");
464  return NULL;
465  }
466 
467  aptex_trace("Old Address '%s' @ %p\n", "main_memory", main_memory);
468 
469  /* if we REALLY run up to limit ! */
470  if (current_mem_size + 1 == max_mem_size)
471  {
472  aptex_memory_error("main memory", (max_mem_size + 1) * sizeof(memory_word));
473  return NULL;
474  }
475 
476 /* first allocation should expand *both* lo and hi */
477  if (hi_size == 0 && mem_end == mem_max)
478  hi_size = lo_size;
479 
480  if (lo_size == 0 && mem_start == mem_min)
481  lo_size = hi_size;
482 
483 /* try and prevent excessive frequent reallocations */
484 /* while avoiding over allocation by too much */
485  min_size = current_mem_size / 100 * percent_grow;
486 
487  if (lo_size + hi_size < min_size)
488  {
489  if (lo_size > 0 && hi_size > 0)
490  {
491  lo_size = min_size / 2;
492  hi_size = min_size / 2;
493  }
494  else if (lo_size > 0)
495  lo_size = min_size;
496  else if (hi_size > 0)
497  hi_size = min_size;
498  }
499 
500  if (lo_size > 0 && lo_size < mem_top / 2)
501  lo_size = mem_top / 2;
502 
503  if (hi_size > 0 && hi_size < mem_top / 2)
504  hi_size = mem_top / 2;
505 
506  for (k = 0; k < MAXSPLITS; k++)
507  {
508  new_size = current_mem_size + lo_size + hi_size;
509 
510  if (new_size >= max_mem_size) /* bump against limit - ha ha ha */
511  {
512  while (new_size >= max_mem_size)
513  {
514  lo_size = lo_size / 2;
515  hi_size = hi_size / 2;
516  new_size = current_mem_size + lo_size + hi_size;
517  }
518  }
519 
520  n = (new_size + 1) * sizeof (memory_word);
521 
522  aptex_memory_trace("main memory", n);
523 
524  new_memory = (memory_word *) realloc(main_memory, n);
525 
526  if (new_memory != NULL)
527  break; /* did we get it ? */
528 
529  if (current_mem_size == 0)
530  break; /* in case we ever use for initial */
531 
532  lo_size = lo_size / 2; hi_size = hi_size / 2;
533  }
534 
535  if (new_memory == NULL)
536  {
537  aptex_memory_error("main memory", n);
538  return mem;
539  }
540 
541  aptex_trace("New Address '%s' @ %p\n", "main_memory", new_memory);
542 
543  if (lo_size > 0)
544  {
545  aptex_trace("memmove %p %p %ld \n", new_memory + lo_size,
546  new_memory, (current_mem_size + 1) * sizeof(memory_word));
547  /* shift everything upward to make space for new low area */
548  memmove (new_memory + lo_size, new_memory,
549  (current_mem_size + 1) * sizeof(memory_word));
550  /* could reduce words moved by (mem_max - mem_end) */
551  }
552 
553  main_memory = new_memory; /* remember for free later */
554 
555  if (lo_size > 0)
556  mem_start = mem_start - lo_size; /* update lower limit */
557 
558  if (hi_size > 0)
559  mem_max = mem_max + hi_size; /* update upper limit */
560 
562  (current_mem_size + 1) * sizeof (memory_word));
564 
566  puts("ERROR: Impossible Memory Error");
567 
568  if (mem_start != 0)
570  else
571  mem = main_memory;
572 
574 
575  return mem;
576 }
577 
579 {
580  memory_word * new_font_info = NULL;
581  int k, min_size;
582  int new_size = 0;
583  int n = 0;
584 
585  aptex_trace("Old Address '%s' @ %p\n", "font_info", font_info);
586 
588  {
589  /* aptex_memory_error("font", (font_mem_size + 1) * sizeof(memory_word)); */
590  return font_info;
591  }
592 
593  min_size = current_font_mem_size / 100 * percent_grow;
594 
595  if (size < min_size)
596  size = min_size;
597 
600 
601  for (k = 0; k < MAXSPLITS; k++)
602  {
604 
605  if (new_size > font_mem_size)
606  new_size = font_mem_size; /* bump against limit */
607 
608  n = (new_size + 1) * sizeof (memory_word);
609 
610  aptex_memory_trace("font_info", n);
611 
612  new_font_info = (memory_word *) realloc(font_info, n);
613 
614  if (new_font_info != NULL)
615  break; /* did we get it ? */
616 
617  if (current_font_mem_size == 0)
618  break; /* initial allocation must work */
619 
620  size = size / 2;
621  }
622 
623  if (new_font_info == NULL)
624  {
625  aptex_memory_error("font", n);
626  return font_info; /* try and continue !!! */
627  }
628 
629  font_info = new_font_info;
630 
631  aptex_trace("New Address '%s' @ %p\n", "font_info", font_info);
634 
636 
637  return font_info;
638 }
639 
641 {
642  int k, min_size;
643  int new_size = 0;
644  int n = 0;
645  packed_ASCII_code * new_str_pool = NULL;
646 
647  aptex_trace("Old Address '%s' @ %p\n", "str_pool", str_pool);
648 
650  {
651  /* aptex_memory_error ("string pool", (pool_size + 1) * sizeof(packed_ASCII_code)); */
652  return str_pool;
653  }
654 
655  min_size = current_pool_size / 100 * percent_grow;
656 
657  if (size < min_size)
658  size = min_size;
659 
660  if (size < initial_pool_size)
662 
663  for (k = 0; k < MAXSPLITS; k++)
664  {
666 
667  if (new_size > pool_size)
669 
670  n = (new_size + 1) * sizeof (packed_ASCII_code);
671 
672  aptex_memory_trace("str_pool", n);
673 
674  new_str_pool = (packed_ASCII_code *) realloc(str_pool, n);
675 
676  if (new_str_pool != NULL)
677  break; /* did we get it ? */
678 
679  if (current_pool_size == 0)
680  break; /* initial allocation must work */
681 
682  size = size / 2; /* else can retry smaller */
683  }
684 
685  if (new_str_pool == NULL)
686  {
687  aptex_memory_error("string pool", n);
688  return str_pool; /* try and continue !!! */
689  }
690 
691  str_pool = new_str_pool;
693 
694  aptex_trace("New Address '%s' @ %p\n", "str_pool", str_pool);
697 
698  return str_pool;
699 }
700 
702 {
703  int k, min_size;
704  int n = 0;
705  int new_size = 0;
706  pool_pointer * new_str_start = NULL;
707 
708  aptex_trace("Old Address '%s' @ %p\n", "str_start", str_start);
709 
711  {
712  /* aptex_memory_error ("string pointer", (max_strings + 1) * sizeof(pool_pointer)); */
713  return str_start;
714  }
715 
716  min_size = current_max_strings / 100 * percent_grow;
717 
718  if (size < min_size)
719  size = min_size;
720 
723 
724  for (k = 0; k < MAXSPLITS; k++)
725  {
727 
728  if (new_size > max_strings)
730 
731  n = (new_size + 1) * sizeof (pool_pointer);
732 
733  aptex_memory_trace("str_start", n);
734 
735  new_str_start = (pool_pointer *) realloc(str_start, n);
736 
737  if (new_str_start != NULL)
738  break; /* did we get it ? */
739 
740  if (current_max_strings == 0)
741  break; /* initial allocation must work */
742 
743  size = size / 2; /* otherwise can try smaller */
744  }
745 
746  if (new_str_start == NULL)
747  {
748  aptex_memory_error("string pointer", n);
749  return str_start; /* try and continue */
750  }
751 
752  str_start = new_str_start;
754 
755  aptex_trace("New Address '%s' @ %p\n", "str_start", str_start);
758 
759  return str_start;
760 }
761 
762 /* returns -1 if it fails */
763 /* size == trie_size */
764 static int allocate_ini (int size)
765 {
766  int n, nl, no, nc, nr, nh, nt;
767 
768  nh = (size + 1) * sizeof(trie_pointer);
769  nr = (size + 1) * sizeof(trie_pointer);
770  nl = (size + 1) * sizeof(trie_pointer);
771  no = (size + 1) * sizeof(trie_op_code);
772  nc = (size + 1) * sizeof(packed_ASCII_code);
773  nt = (size + 1) * sizeof(char);
774  n = nl + no + nc + nr + nh + nt;
775 
776  aptex_memory_trace("initex hyphen trie", n);
777 
781  trie_r = (trie_pointer *) malloc (roundup(nr));
783  trie_taken = (char *) malloc (roundup(nt));
784 
785  if (trie_c == NULL || trie_o == NULL || trie_l == NULL || trie_r == NULL ||
786  trie_hash == NULL || trie_taken == NULL)
787  {
788  aptex_memory_error("initex hyphen trie", n);
789  return -1;
790  }
791 
792  aptex_trace("Addresses: trie_l %p trie_o %p trie_c %p\n", trie_l, trie_o, trie_c);
793  aptex_trace("Addresses: trie_r %p trie_hash %p trie_taken %p\n", trie_r, trie_hash, trie_taken);
801 
802  return 0; // success
803 }
804 
806 {
807  int k, min_size;
808  int n = 0, new_size = 0;
809  memory_word * new_save_stack = NULL;
810 
811  aptex_trace("Old Address '%s' @ %p\n", "save_stack", save_stack);
812 
814  {
815  return save_stack;
816  }
817 
818  min_size = current_save_size / 100 * percent_grow;
819 
820  if (size < min_size)
821  size = min_size;
822 
823  if (size < initial_save_size)
825 
826  for (k = 0; k < MAXSPLITS; k++)
827  {
829 
830  if (new_size > save_size)
832 
833  n = (new_size + 1) * sizeof (memory_word);
834 
835  aptex_memory_trace("save_stack", n);
836 
837  new_save_stack = (memory_word *) realloc(save_stack, n);
838 
839  if (new_save_stack != NULL)
840  break; /* did we get it ? */
841 
842  if (current_save_size == 0)
843  break; /* initial allocation must work */
844 
845  size = size / 2; /* else can retry smaller */
846  }
847 
848  if (new_save_stack == NULL)
849  {
850  aptex_memory_error("save_stack", n);
851  return save_stack; /* try and continue !!! */
852  }
853 
854  save_stack = new_save_stack;
856 
857  aptex_trace("Current %s %d\n", "save_size", current_save_size);
858  aptex_trace("New Address '%s' @ %p\n", "save_stack", save_stack);
861 
862  return save_stack;
863 }
864 
866 {
867  int k, min_size;
868  int n = 0, new_size = 0;
869  in_state_record * new_input_stack = NULL;
870 
871  aptex_trace("Old Address '%s' @ %p\n", "input_stack", input_stack);
872 
874  {
875  return input_stack;
876  }
877 
878  min_size = current_stack_size / 100 * percent_grow;
879 
880  if (size < min_size)
881  size = min_size;
882 
883  if (size < initial_stack_size)
885 
886  for (k = 0; k < MAXSPLITS; k++)
887  {
889 
890  if (new_size > stack_size)
892 
893  n = (new_size + 1) * sizeof(in_state_record);
894 
895  aptex_memory_trace("input_stack", n);
896 
897  new_input_stack = (in_state_record *) realloc(input_stack, n);
898 
899  if (new_input_stack != NULL)
900  break; /* did we get it ? */
901 
902  if (current_stack_size == 0)
903  break; /* initial allocation must work */
904 
905  size = size / 2; /* else can retry smaller */
906  }
907 
908  if (new_input_stack == NULL)
909  {
910  aptex_memory_error("input stack", n);
911  return input_stack; /* try and continue !!! */
912  }
913 
914  input_stack = new_input_stack;
916 
917  aptex_trace("Current %s %d\n", "stack_size", current_stack_size);
918  aptex_trace("New Address '%s' @ %p\n", "input_stack", input_stack);
921 
922  return input_stack;
923 }
924 
926 {
927  int k, min_size;
928  int n = 0, new_size = 0;
929  list_state_record * new_nest = NULL;
930 
931  aptex_trace("Old Address '%s' @ %p\n", "nest", nest);
932 
934  {
935  return nest;
936  }
937 
938  min_size = current_nest_size / 100 * percent_grow;
939 
940  if (size < min_size)
941  size = min_size;
942 
943  if (size < initial_nest_size)
945 
946  for (k = 0; k < MAXSPLITS; k++)
947  {
949 
950  if (new_size > nest_size)
952 
953  n = (new_size + 1) * sizeof (list_state_record);
954  aptex_memory_trace("nest stack", n);
955  new_nest = (list_state_record *) realloc(nest, n);
956 
957  if (new_nest != NULL)
958  break; /* did we get it ? */
959 
960  if (current_nest_size == 0)
961  break; /* initial allocation must work */
962 
963  size = size / 2; /* else can retry smaller */
964  }
965 
966  if (new_nest == NULL)
967  {
968  aptex_memory_error("nest stack", n);
969  return nest; /* try and continue !!! */
970  }
971 
972  nest = new_nest;
974 
975  aptex_trace("Current %s %d\n", "nest_size", current_nest_size);
976  aptex_trace("New Address '%s' @ %p\n", "nest", nest);
979 
980  return nest;
981 }
982 
984 {
985  int k, min_size;
986  int n = 0, new_size = 0;
987  halfword * new_param = NULL;
988 
989  aptex_trace("Old Address '%s' @ %p\n", "param_stack", param_stack);
990 
992  {
993  return param_stack;
994  }
995 
996  min_size = current_param_size / 100 * percent_grow;
997 
998  if (size < min_size)
999  size = min_size;
1000 
1001  if (size < initial_param_size)
1003 
1004  for (k = 0; k < MAXSPLITS; k++)
1005  {
1007 
1008  if (new_size > param_size)
1009  new_size = param_size;
1010 
1011  n = (new_size + 1) * sizeof(pointer);
1012  aptex_memory_trace("param stack", n);
1013  new_param = (pointer *) realloc(param_stack, n);
1014 
1015  if (new_param != NULL)
1016  break; /* did we get it ? */
1017 
1018  if (current_param_size == 0)
1019  break; /* initial allocation must work */
1020 
1021  size = size / 2; /* else can retry smaller */
1022  }
1023 
1024  if (new_param == NULL)
1025  {
1026  aptex_memory_error("param stack", n);
1027  return param_stack; /* try and continue !!! */
1028  }
1029 
1030  param_stack = new_param;
1032 
1033  aptex_trace("Current %s %d\n", "param_size", current_param_size);
1034  aptex_trace("New Address '%s' @ %p\n", "param_stack", param_stack);
1037 
1038  return param_stack;
1039 }
1040 
1042 {
1043  int k, min_size;
1044  int n = 0, new_size = 0;
1045  ASCII_code * new_buffer = NULL;
1046 
1047  aptex_trace("Old Address '%s' @ %p\n", "buffer", buffer);
1048 
1049  if (current_buf_size == buf_size)
1050  {
1051  return buffer;
1052  }
1053 
1054  min_size = current_buf_size / 100 * percent_grow;
1055 
1056  if (size < min_size)
1057  size = min_size;
1058 
1059  if (size < initial_buf_size)
1061 
1062  for (k = 0; k < MAXSPLITS; k++)
1063  {
1065 
1066  if (new_size > buf_size)
1067  new_size = buf_size;
1068 
1069  n = (new_size + 1) * sizeof(ASCII_code);
1070 
1071  aptex_memory_trace("buffer", n);
1072 
1073  new_buffer = (ASCII_code *) realloc(buffer, n);
1074 
1075  if (new_buffer != NULL)
1076  break; /* did we get it ? */
1077 
1078  if (current_buf_size == 0)
1079  break; /* initial allocation must work */
1080 
1081  size = size / 2;
1082  }
1083 
1084  if (new_buffer == NULL)
1085  {
1086  aptex_memory_error("buffer", n);
1087  return buffer; /* try and continue !!! */
1088  }
1089 
1090  buffer = new_buffer;
1093 
1094  aptex_trace("Current buffer %d\n", current_buf_size);
1095  aptex_trace("New Address 'buffer' @ %p\n", buffer);
1098 
1099  return buffer;
1100 }
1101 #endif
1102 
1103 /* set initial memory allocations */
1104 static void aptex_memory_init (void)
1105 {
1106  if (!aptex_env.flag_initex)
1107  {
1108  if (mem_initex != 0)
1109  {
1110  fprintf(stderr, "ERROR: Can only set initial main memory size in INITEX");
1111  mem_initex = 0;
1112  }
1113 
1114  if (trie_size != 0)
1115  fprintf(stderr, "ERROR: Need only set hyphenation trie size in INITEX");
1116  }
1117 
1118  if (mem_initex <= 0)
1120  else if (mem_initex > 10000L * 1024L)
1121  mem_initex = mem_initex / 1024;
1122 
1123  if (trie_size <= 0)
1125 
1126  if (new_hyphen_prime < 0)
1127  new_hyphen_prime = 0;
1128 
1129  if (new_hyphen_prime > 0)
1130  {
1131  if (!aptex_env.flag_initex)
1132  puts("ERROR: Can only set hyphen prime in INITEX");
1133  else
1134  {
1135  if (new_hyphen_prime % 2 == 0)
1136  new_hyphen_prime++;
1137 
1138  while (!prime(new_hyphen_prime))
1140 
1141  aptex_trace("Using %d as hyphen prime\n", new_hyphen_prime);
1142  }
1143  }
1144 
1145  if (percent_grow > 100)
1146  percent_grow = percent_grow - 100;
1147 
1148  if (percent_grow > 100)
1149  percent_grow = 100;
1150 
1151  if (percent_grow < 10)
1152  percent_grow = 10;
1153 
1154 #ifdef APTEX_EXTENSION
1155  main_memory = NULL;
1156  font_info = NULL;
1157  str_pool = NULL;
1158  str_start = NULL;
1159  save_stack = NULL;
1160  hyph_list = NULL;
1161  hyph_word = NULL;
1162  trie_taken = NULL;
1163  trie_hash = NULL;
1164  trie_r = NULL;
1165  trie_c = NULL;
1166  trie_o = NULL;
1167  trie_l = NULL;
1168  trie_trc = NULL;
1169  trie_tro = NULL;
1170  trie_trl = NULL;
1171 
1172  buffer = NULL;
1173  current_buf_size = 0;
1175 #endif
1176 
1177  interaction = -1;
1178  current_mem_size = 0;
1179 
1180 #ifdef APTEX_EXTENSION
1181  input_stack = NULL;
1182  current_stack_size = 0;
1184 
1185  nest = NULL;
1186  current_nest_size = 0;
1188 
1189  param_stack = NULL;
1190  current_param_size = 0;
1192 
1193  save_stack = NULL;
1194  current_save_size = 0;
1196 #endif
1197 
1198 #ifdef APTEX_EXTENSION
1199  str_pool = NULL;
1200  current_pool_size = 0;
1201 
1202  str_start = NULL;
1203  current_max_strings = 0;
1204 
1205  if (aptex_env.flag_initex)
1206  {
1207  aptex_trace("INITEX pool and string allocation");
1210  }
1211 
1212  font_info = NULL;
1214 
1215  if (aptex_env.flag_initex)
1217 
1218  main_memory = NULL;
1219  mem = NULL;
1220  mem_min = mem_bot;
1221  mem_top = mem_initex;
1222  mem_max = mem_top;
1223  hyph_word = NULL;
1224  hyph_list = NULL;
1226 
1227  if (aptex_env.flag_initex)
1228  {
1229  /* avoid this if format specified on command line ??? */
1230  mem = allocate_mem(mem_initex); /* made variable ! */
1231 
1232  if (mem == NULL)
1234  }
1235 
1236  if (aptex_env.flag_initex)
1237  {
1238  if (new_hyphen_prime)
1240 
1241  if (realloc_hyphen(hyphen_prime)) /* allocate just in case no format */
1243 
1246 
1247  if (allocate_ini(trie_size))
1249  }
1250  else
1251  {
1252  trie_l = NULL;
1253  trie_r = NULL;
1254  trie_o = NULL;
1255  trie_hash = NULL;
1256  trie_c = NULL;
1257  trie_taken = NULL;
1258  }
1259 #endif
1260 }
1261 
1262 static void aptex_memory_free (void)
1263 {
1264 #define safe_free(a) \
1265 do { \
1266  if (a != NULL) \
1267  free(a); \
1268  a = NULL; \
1269 } while (0)
1270 
1271  aptex_trace("Max allocated %d, max address %p\n", total_allocated, max_address);
1272  aptex_trace("Heap total : %u bytes, max address %p\n", 0, max_address);
1273  aptex_trace("Main Memory: variable node %d (%d - %d)\n", (int)(lo_mem_max - mem_min), (int)mem_min, (int)lo_mem_max);
1274  aptex_trace("Main Memory: one word node %d (%d - %d)\n", (int)(mem_end - hi_mem_min), (int)hi_mem_min, (int)mem_end);
1275 
1276 #ifdef APTEX_EXTENSION
1277  if (aptex_env.flag_initex)
1278  {
1281  safe_free(trie_l);
1282  safe_free(trie_r);
1283  safe_free(trie_c);
1284  safe_free(trie_o);
1285  }
1286 
1297  safe_free(nest);
1300 #endif
1301 
1303 }
1304 
1305 static void aptex_commands_init (int ac, char **av)
1306 {
1307  aptex_env.aptex_fmt = NULL;
1308  aptex_env.aptex_job = NULL;
1309  aptex_env.aptex_src = NULL;
1310  aptex_env.aptex_map = NULL;
1311 
1312  aptex_env.flag_initex = false;
1313  aptex_env.flag_suppress_f_ligs = false;
1314  aptex_env.flag_reset_trie = false;
1315  aptex_env.flag_reset_hyphen = false;
1316  aptex_env.flag_shell_escape = false;
1317  aptex_env.flag_tex82 = false;
1318  aptex_env.flag_compact_fmt = true;
1319  aptex_env.flag_merge_kanji_baseline = false;
1320  aptex_env.flag_visual_debug = false;
1321 
1322  aptex_env.trace_realloc = true;
1323  aptex_env.trace_mem = false;
1324  aptex_env.trace_lbrk = true;
1325 
1326  new_hyphen_prime = 0;
1327 #ifdef APTEX_EXTENSION
1328  trie_size = 0;
1329 #endif
1330  mem_initex = 0;
1331 
1332  term_in.file_data = stdin;
1333  term_in.file_type = 0;
1334 
1335  term_out.file_data = stdout;
1336  term_out.file_type = 0;
1337 
1338  lbs_pass_fst = 0;
1339  lbs_pass_snd = 0;
1340  lbs_pass_fin = 0;
1341  lbs_sing_line = 0;
1342 
1343  hps_overfull = 0;
1344  hps_underfull = 0;
1345  vps_overfull = 0;
1346  vps_underfull = 0;
1347 
1348  if (ac >= 2)
1349  {
1350  int c;
1351  int option_idx = 0;
1352 
1353 #pragma push_macro("name")
1354 #undef name
1355 #define ARGUMENT_IS(a) !strcmp(long_options[option_idx].name, a)
1356 
1357  struct option long_options[] =
1358  {
1359  { "main-memory", required_argument, NULL, 0 },
1360  { "hyph-size", required_argument, NULL, 0 },
1361  { "trie-size", required_argument, NULL, 0 },
1362  { "percent-grow", required_argument, NULL, 0 },
1363  { "progname", required_argument, NULL, 0 },
1364  { "jobname", required_argument, NULL, 0 },
1365  { "synctex", required_argument, NULL, 0 },
1366  { "fontmap", required_argument, NULL, 0 },
1367  { "format", required_argument, NULL, 0 },
1368  { "mrb-load-file", required_argument, NULL, 0 },
1369  { "mrb-load-string",required_argument, NULL, 0 },
1370  { "shell-escape", no_argument, NULL, 0 },
1371  { "merge-kanji-baseline", no_argument, NULL, 0 },
1372  { "visual-debug", no_argument, NULL, 0 },
1373  { "patterns", no_argument, NULL, 0 },
1374  { "ini", no_argument, NULL, 0 },
1375  { "showlbstats", no_argument, NULL, 0 },
1376  { "suppressfligs", no_argument, NULL, 0 },
1377  { "trace", no_argument, NULL, 0 },
1378  { "help", no_argument, NULL, 0 },
1379  { "version", no_argument, NULL, 0 },
1380  { "usage", no_argument, NULL, 0 },
1381  { NULL, 0, 0, 0 }
1382  };
1383 
1384  while ((c = getopt_long_only(ac, av, "", long_options, &option_idx)) != EOF)
1385  {
1386  if (ARGUMENT_IS("progname"))
1387  kpse_reset_program_name(xstrdup(optarg));
1388  else if (ARGUMENT_IS("jobname"))
1389  aptex_env.aptex_job = xstrdup(optarg);
1390  else if (ARGUMENT_IS("fontmap"))
1391  aptex_env.aptex_map = xstrdup(optarg);
1392  else if (ARGUMENT_IS("synctex"))
1394  else if (ARGUMENT_IS("format"))
1395  aptex_env.aptex_fmt = xstrdup(optarg);
1396  else if (ARGUMENT_IS("ini"))
1397  aptex_env.flag_initex = true;
1398  else if (ARGUMENT_IS("suppressfligs"))
1399  aptex_env.flag_suppress_f_ligs = true;
1400  else if (ARGUMENT_IS("shell-escape"))
1401  aptex_env.flag_shell_escape = true;
1402  else if (ARGUMENT_IS("merge-kanji-baseline"))
1403  aptex_env.flag_merge_kanji_baseline = true;
1404  else if (ARGUMENT_IS("visual-debug"))
1405  aptex_env.flag_visual_debug = true;
1406  else if (ARGUMENT_IS("patterns"))
1407  aptex_env.flag_reset_trie = true;
1408  else if (ARGUMENT_IS("trace"))
1409  aptex_env.trace_mem = true;
1410  else if (ARGUMENT_IS("trie-size"))
1412  else if (ARGUMENT_IS("hyph-size"))
1414  else if (ARGUMENT_IS("main-memory"))
1415  mem_initex = (optarg == NULL) ? mem_top : atoi(optarg) * 1024;
1416  else if (ARGUMENT_IS("percent-grow"))
1417  percent_grow = (optarg == NULL) ? 62 : atoi(optarg);
1418  else if (ARGUMENT_IS("help"))
1420  else if (ARGUMENT_IS("version"))
1422  else if (ARGUMENT_IS("mrb-load-file"))
1423  {
1424  mrb_state * mrb_cmd = mrb_open();
1425  print_aptex_info();
1426  mrb_mruby_aptex_gem_init(mrb_cmd);
1427 
1428  if (mrb_cmd != NULL)
1429  {
1430  FILE * mrb_cmd_file = fopen(optarg, "rb");
1431 
1432  if (mrb_cmd_file != NULL)
1433  {
1434  mrb_load_file(mrb_cmd, mrb_cmd_file);
1435  mrb_mruby_aptex_gem_final(mrb_cmd);
1436  mrb_close(mrb_cmd);
1437  fclose(mrb_cmd_file);
1438  }
1439  }
1440 
1442  }
1443  else if (ARGUMENT_IS("mrb-load-string"))
1444  {
1445  mrb_state * mrb_cmd = mrb_open();
1446  print_aptex_info();
1447  mrb_mruby_aptex_gem_init(mrb_cmd);
1448 
1449  if (mrb_cmd != NULL)
1450  {
1451  mrb_load_string(mrb_cmd, optarg);
1452  mrb_mruby_aptex_gem_final(mrb_cmd);
1453  mrb_close(mrb_cmd);
1454  }
1455 
1457  }
1458  }
1459 #pragma pop_macro("name")
1460 
1461  while (optind < ac)
1462  {
1463  if (*av[optind] == '&' || *av[optind] == '+')
1464  {
1465  if (aptex_env.aptex_fmt != NULL)
1466  free(aptex_env.aptex_fmt);
1467 
1468  aptex_env.aptex_fmt = xstrdup(av[optind] + 1);
1469  }
1470  else
1471  {
1472  if (aptex_env.aptex_src != NULL)
1473  free(aptex_env.aptex_src);
1474 
1475  aptex_env.aptex_src = (char *) calloc(strlen(av[optind]) + 2, sizeof(char));
1476  sprintf(aptex_env.aptex_src, "%s ", av[optind]);
1477  }
1478 
1479  optind++;
1480  }
1481  }
1482 
1483  if (aptex_env.aptex_src == NULL)
1484  aptex_env.aptex_src = xstrdup(" ");
1485 
1486  if (aptex_env.aptex_fmt == NULL)
1488  else
1489  format_name = xstrdup(aptex_env.aptex_fmt);
1490 
1491  TEX_format_default = (char *) malloc(strlen(format_name) + 6);
1492 
1493  if (TEX_format_default == NULL)
1494  {
1495  fprintf(stderr, "%s: something really went bad: cannot allocated mem for default format! Exiting.\n", av[0]);
1497  }
1498 
1499  sprintf(TEX_format_default, " %s.fmt", format_name);
1501 }
1502 
1503 static void catch_interrupt (int err)
1504 {
1505  (void) err;
1506  (void) signal(SIGINT, SIG_IGN);
1507 
1508  if (interrupt++ >= 3)
1510 
1511  (void) signal(SIGINT, catch_interrupt);
1512 }
1513 
1514 static void aptex_set_signal (void)
1515 {
1516 #ifdef _WIN32
1517  if (signal(SIGINT, catch_interrupt) == SIG_ERR)
1518  {
1519  puts("ApTeX: CTRL-C handler not installed");
1521  }
1522 #else
1523  void(*old_handler)(int);
1524 
1525  old_handler = signal(SIGINT, catch_interrupt);
1526 
1527  if (old_handler != SIG_DFL)
1528  (void) signal(SIGINT, old_handler);
1529 #endif
1530 }
1531 
1532 static int aptex_program (void);
1533 
1534 void aptex_run (int argc, char ** argv)
1535 {
1536 #ifdef _WIN32
1537  int i;
1538 
1539  aptex_env.argc = argc;
1540  aptex_env.argv = (char **) malloc(argc * sizeof(char *));
1541 
1542  for (i = 0; i < argc; i++)
1543  aptex_env.argv[i] = mbcs_utf8(argv[i]);
1544 
1545  _setmaxstdio(2048);
1546  setmode(fileno(stdin), _O_BINARY);
1547 #else
1548  aptex_env.argc = argc;
1549  aptex_env.argv = argv;
1550 #endif
1551 
1552  // check of memory_word's size
1553  assert(sizeof(memory_word) == sizeof(halfword) * 2);
1554  assert(sizeof(halfword) == sizeof(quarterword) * 2);
1555  assert(sizeof(integer) == sizeof(real));
1556 
1557  // for synctex
1559  stop_at_space = true;
1560  is_in_csname = false;
1561  // for kpathsea init
1562  kpse_set_program_name(aptex_env.argv[0], NULL);
1563  kpse_set_program_enabled(kpse_fontmap_format, true, kpse_src_texmf_cnf);
1564  // for ptexenc init: encoding
1565  init_default_kanji("utf8", "uptex");
1566  // for engine name
1567  xputenv("engine", "ptex-ng");
1568 
1569  aptex_set_signal();
1572 
1573  aptex_env.time_start = clock();
1574  aptex_env.time_main = aptex_env.time_start;
1575  aptex_program();
1576  aptex_env.time_finish = clock();
1577 
1579 
1580  if (!aptex_env.flag_initex)
1581  {
1582  printf("Total ");
1583  print_aptex_time(aptex_env.time_finish - aptex_env.time_start);
1584  printf("s (");
1585  print_aptex_time(aptex_env.time_main - aptex_env.time_start);
1586  printf(" format load + ");
1587  print_aptex_time(aptex_env.time_finish - aptex_env.time_main);
1588  printf(" processing)");
1589 
1590  if (total_pages > 0)
1591  {
1592  printf(" ");
1593  print_aptex_time((aptex_env.time_finish - aptex_env.time_main) / total_pages);
1594  printf("s per page");
1595  }
1596 
1597  printf(".\n");
1598  }
1599 
1600 #ifdef WIN32
1601  for (i = 0; i < aptex_env.argc; i++)
1602  {
1603  if (aptex_env.argv[i] != NULL)
1604  free(aptex_env.argv[i]);
1605 
1606  aptex_env.argv[i] = NULL;
1607  }
1608 
1609  free(aptex_env.argv);
1610 #endif
1611 
1612  safe_free(aptex_env.aptex_fmt);
1613  safe_free(aptex_env.aptex_src);
1614  safe_free(aptex_env.aptex_job);
1615  safe_free(aptex_env.aptex_map);
1616 }
1617 
1619 {
1620  integer i;
1621 
1622  if (r > 2147483647.0)
1623  i = 2147483647;
1624  else if (r < -2147483647.0)
1625  i = -2147483647;
1626  else if (r >= 0.0)
1627  i = (integer) (r + 0.5);
1628  else
1629  i = (integer) (r - 0.5);
1630 
1631  return i;
1632 }
1633 
1634 #define XXHi(x) BYTE1(x)
1635 #define Hi(x) BYTE3(x)
1636 #define Lo(x) BYTE4(x)
1637 #define nrestmultichr(x) ((x) != 0 ? ((x) / 8) + 2 - ((x) % 8) : -1)
1638 #define CJK_TOKEN_FLAG 0xFFFFFF
1639 
1640 static boolean is_char_ascii (integer c)
1641 {
1642  return (0 <= c && c < 0x100);
1643 }
1644 
1645 static boolean is_char_kanji (integer c)
1646 {
1647  if (is_internalUPTEX())
1648  return (c >= 0);
1649  else
1650  return iskanji1(Hi(c)) && iskanji2(Lo(c));
1651 }
1652 
1653 static boolean check_kanji (integer c)
1654 {
1655  if (c >= cs_token_flag)
1656  return false;
1657  else if (!(XXHi(c) >= kanji && XXHi(c) <= hangul))
1658  return false;
1659  else
1660  return is_char_kanji(c);
1661 }
1662 
1663 static boolean ismultiprn (integer c)
1664 {
1665  int i, j;
1666 
1667  for (i = 2; i <= 4; i++)
1668  for (j = 1; j <= i; j++)
1669  {
1670  if (ismultichr(i, j, c))
1671  return true;
1672  }
1673 
1674  return false;
1675 }
1676 
1678 {
1679  unsigned char c1, c2;
1680 
1681  if (c >= 0 && c <= 255)
1682  return(c);
1683 
1684  c1 = Hi(c);
1685  c2 = Lo(c);
1686 
1687  c1 = (c1 % 4) * 64; // c1 = 0, 64, 128, 192
1688  c2 = c2 % 64; // c2 = 0..63
1689  return (c1 + c2); // ret = 0..255
1690 }
1691 
1692 // Ref. http://www.unicode.org/Public/UNIDATA/Blocks.txt
1693 static long ucs_range[] =
1694 {
1695  0x0000, /* Basic Latin */ /* 0x00 */
1696  0x0080, /* Latin-1 Supplement */
1697  0x0100, /* Latin Extended-A */
1698  0x0180, /* Latin Extended-B */
1699  0x0250, /* IPA Extensions */
1700  0x02B0, /* Spacing Modifier Letters */
1701  0x0300, /* Combining Diacritical Marks */
1702  0x0370, /* Greek and Coptic */
1703  0x0400, /* Cyrillic */
1704  0x0500, /* Cyrillic Supplement */
1705  0x0530, /* Armenian */
1706  0x0590, /* Hebrew */
1707  0x0600, /* Arabic */
1708  0x0700, /* Syriac */
1709  0x0750, /* Arabic Supplement */
1710  0x0780, /* Thaana */
1711  0x07C0, /* NKo */ /* 0x10 */
1712  0x0800, /* Samaritan */
1713  0x0840, /* Mandaic */
1714  0x0860, /* Syriac Supplement */
1715  0x08A0, /* Arabic Extended-A */
1716  0x0900, /* Devanagari */
1717  0x0980, /* Bengali */
1718  0x0A00, /* Gurmukhi */
1719  0x0A80, /* Gujarati */
1720  0x0B00, /* Oriya */
1721  0x0B80, /* Tamil */
1722  0x0C00, /* Telugu */
1723  0x0C80, /* Kannada */
1724  0x0D00, /* Malayalam */
1725  0x0D80, /* Sinhala */
1726  0x0E00, /* Thai */
1727  0x0E80, /* Lao */ /* 0x20 */
1728  0x0F00, /* Tibetan */
1729  0x1000, /* Myanmar */
1730  0x10A0, /* Georgian */
1731  0x1100, /* Hangul Jamo */
1732  0x1200, /* Ethiopic */
1733  0x1380, /* Ethiopic Supplement */
1734  0x13A0, /* Cherokee */
1735  0x1400, /* Unified Canadian Aboriginal Syllabics */
1736  0x1680, /* Ogham */
1737  0x16A0, /* Runic */
1738  0x1700, /* Tagalog */
1739  0x1720, /* Hanunoo */
1740  0x1740, /* Buhid */
1741  0x1760, /* Tagbanwa */
1742  0x1780, /* Khmer */
1743  0x1800, /* Mongolian */ /* 0x30 */
1744  0x18B0, /* Unified Canadian Aboriginal Syllabics Extended */
1745  0x1900, /* Limbu */
1746  0x1950, /* Tai Le */
1747  0x1980, /* New Tai Lue */
1748  0x19E0, /* Khmer Symbols */
1749  0x1A00, /* Buginese */
1750  0x1A20, /* Tai Tham */
1751  0x1AB0, /* Combining Diacritical Marks Extended */
1752  0x1B00, /* Balinese */
1753  0x1B80, /* Sundanese */
1754  0x1BC0, /* Batak */
1755  0x1C00, /* Lepcha */
1756  0x1C50, /* Ol Chiki */
1757  0x1C80, /* Cyrillic Extended-C */
1758  0x1C90, /* Georgian Extended */
1759  0x1CC0, /* Sundanese Supplement */ /* 0x40 */
1760  0x1CD0, /* Vedic Extensions */
1761  0x1D00, /* Phonetic Extensions */
1762  0x1D80, /* Phonetic Extensions Supplement */
1763  0x1DC0, /* Combining Diacritical Marks Supplement */
1764  0x1E00, /* Latin Extended Additional */
1765  0x1F00, /* Greek Extended */
1766  0x2000, /* General Punctuation */
1767  0x2070, /* Superscripts and Subscripts */
1768  0x20A0, /* Currency Symbols */
1769  0x20D0, /* Combining Diacritical Marks for Symbols */
1770  0x2100, /* Letterlike Symbols */
1771  0x2150, /* Number Forms */
1772  0x2190, /* Arrows */
1773  0x2200, /* Mathematical Operators */
1774  0x2300, /* Miscellaneous Technical */
1775  0x2400, /* Control Pictures */ /* 0x50 */
1776  0x2440, /* Optical Character Recognition */
1777  0x2460, /* Enclosed Alphanumerics */
1778  0x2500, /* Box Drawing */
1779  0x2580, /* Block Elements */
1780  0x25A0, /* Geometric Shapes */
1781  0x2600, /* Miscellaneous Symbols */
1782  0x2700, /* Dingbats */
1783  0x27C0, /* Miscellaneous Mathematical Symbols-A */
1784  0x27F0, /* Supplemental Arrows-A */
1785  0x2800, /* Braille Patterns */
1786  0x2900, /* Supplemental Arrows-B */
1787  0x2980, /* Miscellaneous Mathematical Symbols-B */
1788  0x2A00, /* Supplemental Mathematical Operators */
1789  0x2B00, /* Miscellaneous Symbols and Arrows */
1790  0x2C00, /* Glagolitic */
1791  0x2C60, /* Latin Extended-C */ /* 0x60 */
1792  0x2C80, /* Coptic */
1793  0x2D00, /* Georgian Supplement */
1794  0x2D30, /* Tifinagh */
1795  0x2D80, /* Ethiopic Extended */
1796  0x2DE0, /* Cyrillic Extended-A */
1797  0x2E00, /* Supplemental Punctuation */
1798  0x2E80, /* CJK Radicals Supplement */
1799  0x2F00, /* Kangxi Radicals */
1800  0x2FF0, /* Ideographic Description Characters */
1801  0x3000, /* CJK Symbols and Punctuation */
1802  0x3040, /* Hiragana */
1803  0x30A0, /* Katakana */
1804  0x3100, /* Bopomofo */
1805  0x3130, /* Hangul Compatibility Jamo */
1806  0x3190, /* Kanbun */
1807  0x31A0, /* Bopomofo Extended */ /* 0x70 */
1808  0x31C0, /* CJK Strokes */
1809  0x31F0, /* Katakana Phonetic Extensions */
1810  0x3200, /* Enclosed CJK Letters and Months */
1811  0x3300, /* CJK Compatibility */
1812  0x3400, /* CJK Unified Ideographs Extension A */
1813  0x4DC0, /* Yijing Hexagram Symbols */
1814  0x4E00, /* CJK Unified Ideographs */
1815  0xA000, /* Yi Syllables */
1816  0xA490, /* Yi Radicals */
1817  0xA4D0, /* Lisu */
1818  0xA500, /* Vai */
1819  0xA640, /* Cyrillic Extended-B */
1820  0xA6A0, /* Bamum */
1821  0xA700, /* Modifier Tone Letters */
1822  0xA720, /* Latin Extended-D */
1823  0xA800, /* Syloti Nagri */ /* 0x80 */
1824  0xA830, /* Common Indic Number Forms */
1825  0xA840, /* Phags-pa */
1826  0xA880, /* Saurashtra */
1827  0xA8E0, /* Devanagari Extended */
1828  0xA900, /* Kayah Li */
1829  0xA930, /* Rejang */
1830  0xA960, /* Hangul Jamo Extended-A */
1831  0xA980, /* Javanese */
1832  0xA9E0, /* Myanmar Extended-B */
1833  0xAA00, /* Cham */
1834  0xAA60, /* Myanmar Extended-A */
1835  0xAA80, /* Tai Viet */
1836  0xAAE0, /* Meetei Mayek Extensions */
1837  0xAB00, /* Ethiopic Extended-A */
1838  0xAB30, /* Latin Extended-E */
1839  0xAB70, /* Cherokee Supplement */ /* 0x90 */
1840  0xABC0, /* Meetei Mayek */
1841  0xAC00, /* Hangul Syllables */
1842  0xD7B0, /* Hangul Jamo Extended-B */
1843  0xD800, /* High Surrogates */
1844  0xDB80, /* High Private Use Surrogates */
1845  0xDC00, /* Low Surrogates */
1846  0xE000, /* Private Use Area */
1847  0xF900, /* CJK Compatibility Ideographs */
1848  0xFB00, /* Alphabetic Presentation Forms */
1849  0xFB50, /* Arabic Presentation Forms-A */
1850  0xFE00, /* Variation Selectors */
1851  0xFE10, /* Vertical Forms */
1852  0xFE20, /* Combining Half Marks */
1853  0xFE30, /* CJK Compatibility Forms */
1854  0xFE50, /* Small Form Variants */
1855  0xFE70, /* Arabic Presentation Forms-B */ /* 0xA0 */
1856  0xFF00, /* Halfwidth and Fullwidth Forms */
1857  0xFFF0, /* Specials */
1858  0x10000, /* Linear B Syllabary */
1859  0x10080, /* Linear B Ideograms */
1860  0x10100, /* Aegean Numbers */
1861  0x10140, /* Ancient Greek Numbers */
1862  0x10190, /* Ancient Symbols */
1863  0x101D0, /* Phaistos Disc */
1864  0x10280, /* Lycian */
1865  0x102A0, /* Carian */
1866  0x102E0, /* Coptic Epact Numbers */
1867  0x10300, /* Old Italic */
1868  0x10330, /* Gothic */
1869  0x10350, /* Old Permic */
1870  0x10380, /* Ugaritic */
1871  0x103A0, /* Old Persian */ /* 0xB0 */
1872  0x10400, /* Deseret */
1873  0x10450, /* Shavian */
1874  0x10480, /* Osmanya */
1875  0x104B0, /* Osage */
1876  0x10500, /* Elbasan */
1877  0x10530, /* Caucasian Albanian */
1878  0x10600, /* Linear A */
1879  0x10800, /* Cypriot Syllabary */
1880  0x10840, /* Imperial Aramaic */
1881  0x10860, /* Palmyrene */
1882  0x10880, /* Nabataean */
1883  0x108E0, /* Hatran */
1884  0x10900, /* Phoenician */
1885  0x10920, /* Lydian */
1886  0x10980, /* Meroitic Hieroglyphs */
1887  0x109A0, /* Meroitic Cursive */ /* 0xC0 */
1888  0x10A00, /* Kharoshthi */
1889  0x10A60, /* Old South Arabian */
1890  0x10A80, /* Old North Arabian */
1891  0x10AC0, /* Manichaean */
1892  0x10B00, /* Avestan */
1893  0x10B40, /* Inscriptional Parthian */
1894  0x10B60, /* Inscriptional Pahlavi */
1895  0x10B80, /* Psalter Pahlavi */
1896  0x10C00, /* Old Turkic */
1897  0x10C80, /* Old Hungarian */
1898  0x10D00, /* Hanifi Rohingya */
1899  0x10E60, /* Rumi Numeral Symbols */
1900  0x10E80, /* Yezidi */
1901  0x10F00, /* Old Sogdian */
1902  0x10F30, /* Sogdian */
1903  0x10FB0, /* Chorasmian */ /* 0xD0 */
1904  0x10FE0, /* Elymaic */
1905  0x11000, /* Brahmi */
1906  0x11080, /* Kaithi */
1907  0x110D0, /* Sora Sompeng */
1908  0x11100, /* Chakma */
1909  0x11150, /* Mahajani */
1910  0x11180, /* Sharada */
1911  0x111E0, /* Sinhala Archaic Numbers */
1912  0x11200, /* Khojki */
1913  0x11280, /* Multani */
1914  0x112B0, /* Khudawadi */
1915  0x11300, /* Grantha */
1916  0x11400, /* Newa */
1917  0x11480, /* Tirhuta */
1918  0x11580, /* Siddham */
1919  0x11600, /* Modi */ /* 0xE0 */
1920  0x11660, /* Mongolian Supplement */
1921  0x11680, /* Takri */
1922  0x11700, /* Ahom */
1923  0x11800, /* Dogra */
1924  0x118A0, /* Warang Citi */
1925  0x11900, /* Dives Akuru */
1926  0x119A0, /* Nandinagari */
1927  0x11A00, /* Zanabazar Square */
1928  0x11A50, /* Soyombo */
1929  0x11AC0, /* Pau Cin Hau */
1930  0x11C00, /* Bhaiksuki */
1931  0x11C70, /* Marchen */
1932  0x11D00, /* Masaram Gondi */
1933  0x11D60, /* Gunjala Gondi */
1934  0x11EE0, /* Makasar */
1935  0x11FB0, /* Lisu Supplement */ /* 0xF0 */
1936  0x11FC0, /* Tamil Supplement */
1937  0x12000, /* Cuneiform */
1938  0x12400, /* Cuneiform Numbers and Punctuation */
1939  0x12480, /* Early Dynastic Cuneiform */
1940  0x13000, /* Egyptian Hieroglyphs */
1941  0x13430, /* Egyptian Hieroglyph Format Controls */
1942  0x14400, /* Anatolian Hieroglyphs */
1943  0x16800, /* Bamum Supplement */
1944  0x16A40, /* Mro */
1945  0x16AD0, /* Bassa Vah */
1946  0x16B00, /* Pahawh Hmong */
1947  0x16E40, /* Medefaidrin */
1948  0x16F00, /* Miao */
1949  0x16FE0, /* Ideographic Symbols and Punctuation */
1950  0x17000, /* Tangut */
1951  0x18800, /* Tangut Components */ /* 0x100 */
1952  0x18B00, /* Khitan Small Script */
1953  0x18D00, /* Tangut Supplement */
1954  0x1B000, /* Kana Supplement */
1955  0x1B100, /* Kana Extended-A */
1956  0x1B130, /* Small Kana Extension */
1957  0x1B170, /* Nushu */
1958  0x1BC00, /* Duployan */
1959  0x1BCA0, /* Shorthand Format Controls */
1960  0x1D000, /* Byzantine Musical Symbols */
1961  0x1D100, /* Musical Symbols */
1962  0x1D200, /* Ancient Greek Musical Notation */
1963  0x1D2E0, /* Mayan Numerals */
1964  0x1D300, /* Tai Xuan Jing Symbols */
1965  0x1D360, /* Counting Rod Numerals */
1966  0x1D400, /* Mathematical Alphanumeric Symbols */
1967  0x1D800, /* Sutton SignWriting */ /* 0x110 */
1968  0x1E000, /* Glagolitic Supplement */
1969  0x1E100, /* Nyiakeng Puachue Hmong */
1970  0x1E2C0, /* Wancho */
1971  0x1E800, /* Mende Kikakui */
1972  0x1E900, /* Adlam */
1973  0x1EC70, /* Indic Siyaq Numbers */
1974  0x1ED00, /* Ottoman Siyaq Numbers */
1975  0x1EE00, /* Arabic Mathematical Alphabetic Symbols */
1976  0x1F000, /* Mahjong Tiles */
1977  0x1F030, /* Domino Tiles */
1978  0x1F0A0, /* Playing Cards */
1979  0x1F100, /* Enclosed Alphanumeric Supplement */
1980  0x1F200, /* Enclosed Ideographic Supplement */
1981  0x1F300, /* Miscellaneous Symbols and Pictographs */
1982  0x1F600, /* Emoticons */
1983  0x1F650, /* Ornamental Dingbats */ /* 0x120 */
1984  0x1F680, /* Transport and Map Symbols */
1985  0x1F700, /* Alchemical Symbols */
1986  0x1F780, /* Geometric Shapes Extended */
1987  0x1F800, /* Supplemental Arrows-C */
1988  0x1F900, /* Supplemental Symbols and Pictographs */
1989  0x1FA00, /* Chess Symbols */
1990  0x1FA70, /* Symbols and Pictographs Extended-A */
1991  0x1FB00, /* Symbols for Legacy Computing */
1992  0x20000, /* CJK Unified Ideographs Extension B */
1993  0x2A700, /* CJK Unified Ideographs Extension C */
1994  0x2B740, /* CJK Unified Ideographs Extension D */
1995  0x2B820, /* CJK Unified Ideographs Extension E */
1996  0x2CEB0, /* CJK Unified Ideographs Extension F */
1997  0x2F800, /* CJK Compatibility Ideographs Supplement */
1998  0x30000, /* CJK Unified Ideographs Extension G */
1999  0x31350, /* Reserved */ /* 0x130 */
2000  0x40000, /* Reserved */
2001  0x50000, /* Reserved */
2002  0x60000, /* Reserved */
2003  0x70000, /* Reserved */
2004  0x80000, /* Reserved */
2005  0x90000, /* Reserved */
2006  0xA0000, /* Reserved */
2007  0xB0000, /* Reserved */
2008  0xC0000, /* Reserved */
2009  0xD0000, /* Reserved */
2010  0xE0000, /* Tags */
2011  0xE0100, /* Variation Selectors Supplement */
2012  0xF0000, /* Supplementary Private Use Area-A */
2013  0x100000, /* Supplementary Private Use Area-B */
2014 /* Value over 0x10FFFF is illegal under Unicode, They are for some special use. *** experimental *** */
2015  0x110000, /* Reserved */
2016  0x120000, /* Reserved */
2017  0x130000, /* Reserved */
2018  0x140000, /* Reserved */ /* 0x140 */
2019  0x150000, /* Reserved */
2020  0x160000, /* Reserved */
2021  0x170000, /* Reserved */
2022  0x180000, /* Reserved */
2023  0x190000, /* Reserved */
2024  0x1A0000, /* Reserved */
2025  0x1B0000, /* Reserved */
2026  0x1C0000, /* Reserved */
2027  0x1D0000, /* Reserved */
2028  0x1E0000, /* Reserved */
2029  0x1F0000, /* Reserved */
2030  0x200000, /* Reserved */
2031  0x210000, /* Reserved */
2032  0x220000, /* Reserved */ /* 0x150 */
2033  max_cjk_val
2034 };
2035 
2036 #define NUCS_RANGE (sizeof(ucs_range)/sizeof(ucs_range[0]))
2037 
2038 static int binary_search (long x, long *a, int left, int right)
2039 {
2040  right++;
2041 
2042  while (left < right)
2043  {
2044  int mid = (left + right) / 2;
2045 
2046  if (a[mid] <= x)
2047  left = mid + 1;
2048  else
2049  right = mid;
2050  }
2051 
2052  return left - 1;
2053 }
2054 
2055 
2056 #define FEMININE_ORDINAL_INDICATOR 0x00AA
2057 #define MASCULINE_ORDINAL_INDICATOR 0x00BA
2058 #define LATIN_CAPITAL_LETTER_A_WITH_GRAVE 0x00C0
2059 #define LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS 0x00D6
2060 #define LATIN_CAPITAL_LETTER_O_WITH_STROKE 0x00D8
2061 #define LATIN_SMALL_LETTER_O_WITH_DIAERESIS 0x00F6
2062 #define LATIN_SMALL_LETTER_O_WITH_STROKE 0x00F8
2063 #define LATIN_SMALL_LETTER_Y_WITH_DIAERESIS 0x00FF
2064 #define FULLWIDTH_DIGIT_0 0xFF10
2065 #define FULLWIDTH_DIGIT_9 0xFF19
2066 #define FULLWIDTH_CAPITAL_A 0xFF21
2067 #define FULLWIDTH_CAPITAL_Z 0xFF3A
2068 #define FULLWIDTH_SMALL_A 0xFF41
2069 #define FULLWIDTH_SMALL_Z 0xFF5A
2070 #define HALFWIDTH_KATAKANA_WO 0xFF66
2071 #define HALFWIDTH_KATAKANA_SMALL_TSU 0xFF6F
2072 #define HALFWIDTH_KATAKANA_A 0xFF71
2073 #define HALFWIDTH_KATAKANA_N 0xFF9D
2074 
2076 {
2077  integer block;
2078 
2079  if (is_internalUPTEX())
2080  {
2081  block = binary_search((long)c, ucs_range, 0, NUCS_RANGE-1);
2082 
2083  if (block == 0x01)
2084  {
2085  /* Latin-1 Letters */
2091  return 0x01FD;
2092  }
2093 
2094  if (block == 0xa1)
2095  {
2096  /* Fullwidth ASCII variants except for U+FF01..FF0F, U+FF1A..FF20, U+FF3B..FF40, U+FF5B..FF5E */
2097  if ((FULLWIDTH_DIGIT_0 <= c && c <= FULLWIDTH_DIGIT_9)
2099  || (FULLWIDTH_SMALL_A <= c && c <= FULLWIDTH_SMALL_Z))
2100  return 0x1FE;
2101 
2102  /* Halfwidth Katakana variants except for U+FF65, U+FF70, U+FF9E..FF9F */
2105  return 0x1FF;
2106  }
2107 
2108  return block;
2109  }
2110  else
2111  {
2112  return Hi(toDVI(c));
2113  }
2114 }
2115 
2117 {
2118  c = toBUFF(c);
2119  if (BYTE1(c)) return 4;
2120  if (BYTE2(c)) return 3;
2121  if (BYTE3(c)) return 2;
2122  if (BYTE4(c)) return 1;
2123  return 0;
2124 }
2125 
2126 static void init_default_kanji (const_string file_str, const_string internal_str)
2127 {
2128  enable_UPTEX(true);
2129 
2130  if (!set_enc_string(file_str, internal_str))
2131  {
2132  fprintf(stderr, "Bad kanji encoding \"%s\" or \"%s\".\n",
2133  file_str ? file_str : "NULL",
2134  internal_str ? internal_str : "NULL");
2136  }
2137 }
2138 
2139 static char * mbcs_utf8 (const char * mbcs_str)
2140 {
2141 #ifdef WIN32
2142  if (mbcs_str == NULL)
2143  return NULL;
2144  else
2145  {
2146  int utf8_len;
2147  int utf16_len;
2148  size_t mbcs_len;
2149  LPWSTR utf16_str;
2150  char * utf8_str;
2151  int codepage;
2152 
2153  mbcs_len = strlen(mbcs_str);
2154  codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
2155  utf16_len = MultiByteToWideChar(codepage, 0, mbcs_str, -1, NULL, 0);
2156 
2157  if (utf16_len == 0)
2158  return NULL;
2159 
2160  utf16_str = (LPWSTR) malloc((utf16_len + 1) * sizeof(utf16_str[0]));
2161 
2162  if (utf16_str == NULL)
2163  return NULL;
2164 
2165  MultiByteToWideChar(codepage, 0, mbcs_str, -1, utf16_str, utf16_len);
2166  utf8_len = WideCharToMultiByte(CP_UTF8, 0, utf16_str, utf16_len, 0, 0, 0, 0);
2167  utf8_str = utf8_len ? (char *) malloc(utf8_len + 1) : NULL;
2168 
2169  if (utf8_str)
2170  {
2171  WideCharToMultiByte(CP_UTF8, 0, utf16_str, utf16_len, utf8_str, utf8_len, 0, 0);
2172  }
2173 
2174  free(utf16_str);
2175 
2176  return utf8_str;
2177  }
2178 #else
2179  return xstrdup(mbcs_str);
2180 #endif
2181 }
2182 
2183 static char * utf8_mbcs (const char * utf8_str)
2184 {
2185 #ifdef WIN32
2186  if (utf8_str == NULL)
2187  return NULL;
2188  else
2189  {
2190  size_t utf8_len;
2191  int utf16_len;
2192  int mbcs_len;
2193  LPWSTR utf16_str;
2194  char * mbcs_str;
2195  int codepage;
2196 
2197  utf8_len = strlen(utf8_str);
2198  utf16_len = MultiByteToWideChar(CP_UTF8, 0, utf8_str, -1, NULL, 0);
2199 
2200  if (utf16_len == 0)
2201  return NULL;
2202 
2203  utf16_str = (LPWSTR) malloc((utf16_len + 1) * sizeof(utf16_str[0]));
2204 
2205  if (utf16_str == NULL)
2206  return NULL;
2207 
2208  MultiByteToWideChar(CP_UTF8, 0, utf8_str, -1, utf16_str, utf16_len);
2209  codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
2210  mbcs_len = WideCharToMultiByte(codepage, 0, utf16_str, utf16_len, 0, 0, 0, 0);
2211  mbcs_str = mbcs_len ? (char *) malloc(mbcs_len + 1) : NULL;
2212 
2213  if (mbcs_str)
2214  {
2215  WideCharToMultiByte(codepage, 0, utf16_str, utf16_len, mbcs_str, mbcs_len, 0, 0);
2216  }
2217 
2218  free(utf16_str);
2219 
2220  return mbcs_str;
2221  }
2222 #else
2223  return xstrdup(utf8_str);
2224 #endif
2225 }
2226 
2227 static void t_open_in (void)
2228 {
2229  buffer[first] = 0;
2230  sprintf((char *) &buffer[first], "%s", aptex_env.aptex_src);
2231 
2232  for (last = first; buffer[last]; ++last)
2233  do_nothing();
2234 
2235  for (--last; last >= first && isblank(buffer[last]) && buffer[last] != '\r'; --last)
2236  do_nothing();
2237 
2238  last++;
2239 }
2240 
2241 /* sec 0031 */
2242 // inputs the next line or returns |false|
2243 static boolean input_ln (alpha_file f, boolean bypass_eoln)
2244 {
2245  int i = '\0';
2246 
2247  (void) bypass_eoln;
2248  last = first;
2249 
2250 #ifdef APTEX_EXTENSION
2251  while (true)
2252 #else
2253  while (last < buf_size)
2254 #endif
2255  {
2256  i = fgetc(f.file_data);
2257 
2258  if ((i == EOF) || (i == '\n') || (i == '\r'))
2259  break;
2260  else
2261  {
2262  buffer[last++] = i;
2263 
2264 #ifdef APTEX_EXTENSION
2265  if (last >= current_buf_size)
2267 #endif
2268  }
2269  }
2270 
2271  /*
2272  LF Unix
2273  CRLF Windows
2274  */
2275 
2276  if (i == '\r')
2277  {
2278  i = fgetc(f.file_data);
2279 
2280  if (i != '\n')
2281  {
2282  ungetc(i, f.file_data);
2283  i = '\r';
2284  }
2285  }
2286 
2287  if (i == EOF && last == first)
2288  return false;
2289 
2290  buffer[last] = ' ';
2291 
2292  if (last >= max_buf_stack)
2293  max_buf_stack = last;
2294 
2295  while (last > first)
2296  {
2297  i = buffer[last - 1];
2298 
2299  if (i == ' ' || i == '\t')
2300  --last;
2301  else
2302  break;
2303  }
2304 
2305  return true;
2306 }
2307 
2308 static boolean a_open_input (alpha_file * f)
2309 {
2310  boolean openable = false;
2311  char * file_name_kpse = NULL;
2312  char * file_name_mbcs = NULL;
2313 
2314  char * file_name_utf8 = (char *) calloc(1, name_length + 1);
2315  strncpy(file_name_utf8, (const char *) name_of_file + 1, name_length);
2316 
2317  file_name_mbcs = utf8_mbcs(file_name_utf8);
2318 
2319  if (file_name_mbcs[0] == '|' && aptex_env.flag_shell_escape == true)
2320  {
2321  f->file_data = popen(file_name_mbcs + 1, "r");
2322  f->file_type = 1;
2323  if (f->file_data) openable = true;
2324  }
2325  else
2326  {
2327  file_name_kpse = kpse_find_file((const_string) file_name_mbcs, kpse_tex_format, false);
2328 
2329  if (file_name_kpse != NULL)
2330  {
2331  f->file_data = fopen(file_name_kpse, "rb");
2332  f->file_type = 0;
2333  if (f->file_data) openable = true;
2334  }
2335  }
2336 
2337  if (file_name_mbcs != NULL)
2338  free(file_name_mbcs);
2339 
2340  if (file_name_utf8 != NULL)
2341  free(file_name_utf8);
2342 
2343  if (file_name_kpse != NULL)
2344  free(file_name_kpse);
2345 
2346  return openable;
2347 }
2348 
2349 static boolean b_open_input (byte_file * f)
2350 {
2351  boolean openable = false;
2352  char * file_name_kpse = NULL;
2353  char * file_name_mbcs = NULL;
2354 
2355  char * file_name_utf8 = (char *) calloc(1, name_length + 1);
2356  strncpy(file_name_utf8, (const char *) name_of_file + 1, name_length);
2357 
2358  if (name_length > 3 && (strncasecmp(file_name_utf8, "ot:", 3) == 0))
2359  file_name_mbcs = utf8_mbcs(strrchr(file_name_utf8, ':') + 1);
2360  else
2361  file_name_mbcs = utf8_mbcs(file_name_utf8);
2362 
2363  file_name_kpse = kpse_find_file((const_string) file_name_mbcs, kpse_tfm_format, true);
2364 
2365  if (file_name_kpse != NULL)
2366  {
2367  *f = fopen(file_name_kpse, "rb");
2368 
2369  if (*f)
2370  {
2371  fbyte = fgetc((FILE *) *f);
2372  openable = true;
2373  }
2374  }
2375 
2376  if (file_name_mbcs != NULL)
2377  free(file_name_mbcs);
2378 
2379  if (file_name_utf8 != NULL)
2380  free(file_name_utf8);
2381 
2382  if (file_name_kpse != NULL)
2383  free(file_name_kpse);
2384 
2385  return openable;
2386 }
2387 
2388 static boolean w_open_input (word_file * f)
2389 {
2390  boolean openable = false;
2391  char * file_name_kpse = NULL;
2392  char * file_name_mbcs = NULL;
2393  char * file_name_utf8 = (char *) calloc(1, name_length + 1);
2394 
2395  strncpy(file_name_utf8, (const char *) name_of_file + 1, name_length);
2396  file_name_mbcs = utf8_mbcs(file_name_utf8);
2397  file_name_kpse = kpse_find_file((const_string) file_name_mbcs, kpse_fmt_format, false);
2398 
2399  if (file_name_kpse != NULL)
2400  {
2401  *f = gzopen(file_name_kpse, "rb");
2402  if (*f) openable = true;
2403  }
2404 
2405  if (file_name_mbcs != NULL)
2406  free(file_name_mbcs);
2407 
2408  if (file_name_utf8 != NULL)
2409  free(file_name_utf8);
2410 
2411  if (file_name_kpse != NULL)
2412  free(file_name_kpse);
2413 
2414  return openable;
2415 }
2416 
2417 static void a_close (alpha_file f)
2418 {
2419  switch (f.file_type)
2420  {
2421  case 0:
2422  fclose(f.file_data);
2423  break;
2424  case 1:
2425  pclose(f.file_data);
2426  break;
2427  }
2428 }
2429 
2430 static void b_close (byte_file f)
2431 {
2432  if (f == NULL)
2433  return;
2434  else if (ferror(f) || fclose(f))
2435  {
2436  perror("\n! I/O Error");
2438  }
2439 }
2440 
2441 static void w_close (word_file f)
2442 {
2443  gzclose(f);
2444 }
2445 
2446 static boolean a_open_output (alpha_file * f)
2447 {
2448  char * file_name_mbcs = NULL;
2449  char * file_name_utf8 = (char *) calloc(1, name_length + 1);
2450 
2451  strncpy(file_name_utf8, (const char *) name_of_file + 1, name_length);
2452  file_name_mbcs = utf8_mbcs(file_name_utf8);
2453 
2454  f->file_data = fopen(file_name_mbcs, "wb");
2455  f->file_type = 0;
2456 
2457  if (file_name_mbcs != NULL)
2458  free(file_name_mbcs);
2459 
2460  if (file_name_utf8 != NULL)
2461  free(file_name_utf8);
2462 
2463  return (f->file_data != NULL);
2464 }
2465 
2466 static boolean b_open_output (byte_file * f)
2467 {
2468  char * file_name_mbcs = NULL;
2469  char * file_name_utf8 = (char *) calloc(1, name_length + 1);
2470 
2471  strncpy(file_name_utf8, (const char *) name_of_file + 1, name_length);
2472  file_name_mbcs = utf8_mbcs(file_name_utf8);
2473 
2474  *f = fopen(file_name_mbcs, "wb");
2475 
2476  if (file_name_mbcs != NULL)
2477  free(file_name_mbcs);
2478 
2479  if (file_name_utf8 != NULL)
2480  free(file_name_utf8);
2481 
2482  return (*f != NULL);
2483 }
2484 
2485 static boolean w_open_output (word_file * f)
2486 {
2487  char * file_name_mbcs = NULL;
2488  char * file_name_utf8 = (char *) calloc(1, name_length + 1);
2489 
2490  strncpy(file_name_utf8, (const char *) name_of_file + 1, name_length);
2491  file_name_mbcs = utf8_mbcs(file_name_utf8);
2492 
2493  *f = gzopen(file_name_mbcs, "wb");
2494 
2495  if (file_name_mbcs != NULL)
2496  free(file_name_mbcs);
2497 
2498  if (file_name_utf8 != NULL)
2499  free(file_name_utf8);
2500 
2501  return (*f != NULL);
2502 }
2503 
2504 static const char * pool_file_arr[] =
2505 {
2506 /* 0256 */ "", //"buffer size",
2507 /* 0257 */ "", //"pool size",
2508 /* 0258 */ "", //"number of strings",
2509 /* 0259 */ "" "?" "?" "?",
2510 /* 0260 */ "m2d5c2l5x2v5i",
2511 /* 0261 */ "", //"End of file on the terminal!",
2512 /* 0262 */ "", //"! ",
2513 /* 0263 */ "", //"(That makes 100 errors; please try again.)",
2514 /* 0264 */ "", // "? ",
2515 /* 0265 */ "", //"Type <return> to proceed, S to scroll future error messages,",
2516 /* 0266 */ "", //"R to run without stopping, Q to run quietly,",
2517 /* 0267 */ "", //"I to insert something, ",
2518 /* 0268 */ "", //"E to edit your file,",
2519 /* 0269 */ "", //"1 or ... or 9 to ignore the next 1 to 9 tokens of input,",
2520 /* 0270 */ "", //"H for help, X to quit.",
2521 /* 0271 */ "", //"OK, entering ",
2522 /* 0272 */ "", //"batchmode",
2523 /* 0273 */ "", //"nonstopmode",
2524 /* 0274 */ "", //"scrollmode",
2525 /* 0275 */ "", //"...",
2526 /* 0276 */ "", //"insert>",
2527 /* 0277 */ "", //"I have just deleted some text, as you asked.",
2528 /* 0278 */ "", //"You can now delete more, or insert, or whatever.",
2529 /* 0279 */ "", //"Sorry, I don't know how to help in this situation.",
2530 /* 0280 */ "", //"Maybe you should try asking a human" "?",
2531 /* 0281 */ "", //"Sorry, I already gave what help I could...",
2532 /* 0282 */ "", //"An error might have occurred before I noticed any problems.",
2533 /* 0283 */ "", //"``If all else fails, read the instructions.''",
2534 /* 0284 */ "", //" (",
2535 /* 0285 */ "", //"Emergency stop",
2536 /* 0286 */ "", //"TeX capacity exceeded, sorry [",
2537 /* 0287 */ "", //"If you really absolutely need more capacity,",
2538 /* 0288 */ "", //"you can ask a wizard to enlarge me.",
2539 /* 0289 */ "", //"This can't happen (",
2540 /* 0290 */ "", //"I'm broken. Please show this to someone who can fix can fix",
2541 /* 0291 */ "", //"I can't go on meeting you like this",
2542 /* 0292 */ "", //"One of your faux pas seems to have wounded me deeply...",
2543 /* 0293 */ "", //"in fact, I'm barely conscious. Please fix it and try again.",
2544 /* 0294 */ "", //"Interruption",
2545 /* 0295 */ "", //"You rang" "?",
2546 /* 0296 */ "", //"Try to insert some instructions for me (e.g.,`I\\showlists'),",
2547 /* 0297 */ "", //"unless you just want to quit by typing `X'.",
2548 /* 0298 */ "", //"main memory size",
2549 /* 0299 */ "", //"AVAIL list clobbered at ",
2550 /* 0300 */ "", //"Double-AVAIL list clobbered at ",
2551 /* 0301 */ "", //"Doubly free location at ",
2552 /* 0302 */ "", //"Bad flag at ",
2553 /* 0303 */ "", //"New busy locs:",
2554 /* 0304 */ "", //"LINK(",
2555 /* 0305 */ "", //"INFO(",
2556 /* 0306 */ "", //"[]",
2557 /* 0307 */ "", //"CLOBBERED.",
2558 /* 0308 */ "", //"foul",
2559 /* 0309 */ "", //"fil",
2560 /* 0310 */ "", //" plus ",
2561 /* 0311 */ "", //" minus ",
2562 /* 0312 */ "", //" []",
2563 /* 0313 */ "", //"Bad link, display aborted.",
2564 /* 0314 */ "", //"etc.",
2565 /* 0315 */ "", //"Unknown node type!",
2566 /* 0316 */ "", //"unset",
2567 /* 0317 */ "", //"box(",
2568 /* 0318 */ "", //")x",
2569 /* 0319 */ "", //", shifted ",
2570 /* 0320 */ "", //" columns)",
2571 /* 0321 */ "", //", stretch ",
2572 /* 0322 */ "", //", shrink ",
2573 /* 0323 */ "", //", glue set ",
2574 /* 0324 */ "", //"- ",
2575 /* 0325 */ "", //"< -",
2576 /* 0326 */ "", //"rule(",
2577 /* 0327 */ "", //"insert",
2578 /* 0328 */ "", //", natural size ",
2579 /* 0329 */ "", //"; split(",
2580 /* 0330 */ "", //"); float cost ",
2581 /* 0331 */ "", //"glue",
2582 /* 0332 */ "", //"nonscript",
2583 /* 0333 */ "", //"mskip",
2584 /* 0334 */ "", //"mu",
2585 /* 0335 */ "",
2586 /* 0336 */ "", //"leaders ",
2587 /* 0337 */ "", //"kern",
2588 /* 0338 */ "", //" (for accent)",
2589 /* 0339 */ "", //"mkern",
2590 /* 0340 */ "", //"math",
2591 /* 0341 */ "", //"on",
2592 /* 0342 */ "", //"off",
2593 /* 0343 */ "", //", surrounded ",
2594 /* 0344 */ "", //" (ligature ",
2595 /* 0345 */ "", //"penalty ",
2596 /* 0346 */ "", //"discretionary",
2597 /* 0347 */ "", //" replacing ",
2598 /* 0348 */ "", //"mark",
2599 /* 0349 */ "", //"vadjust",
2600 /* 0350 */ "", //"flushing",
2601 /* 0351 */ "", //"copying",
2602 /* 0352 */ "", //"vertical",
2603 /* 0353 */ "", //"horizontal",
2604 /* 0354 */ "", //"display math",
2605 /* 0355 */ "", //"no",
2606 /* 0356 */ "", //"internal vertical",
2607 /* 0357 */ "", //"restricted horizontal",
2608 /* 0358 */ "", //" mode",
2609 /* 0359 */ "", //"semantic nest size",
2610 /* 0360 */ "", //"### ",
2611 /* 0361 */ "", //" entered at line ",
2612 /* 0362 */ "", //" (language",
2613 /* 0363 */ "", //":hyphenmin",
2614 /* 0364 */ "", //" (\\output routine)",
2615 /* 0365 */ "", //"### recent contributions:",
2616 /* 0366 */ "", //"prevdepth ",
2617 /* 0367 */ "", //"ignored",
2618 /* 0368 */ "", //", prevgraf ",
2619 /* 0369 */ "", //" line",
2620 /* 0370 */ "", //"spacefactor ",
2621 /* 0371 */ "", //", current language ",
2622 /* 0372 */ "", //"this will be denominator of:",
2623 /* 0373 */ "", //"lineskip",
2624 /* 0374 */ "", //"baselineskip",
2625 /* 0375 */ "", //"parskip",
2626 /* 0376 */ "", //"abovedisplayskip",
2627 /* 0377 */ "", //"belowdisplayskip",
2628 /* 0378 */ "", //"abovedisplayshortskip",
2629 /* 0379 */ "", //"belowdisplayshortskip",
2630 /* 0380 */ "", //"leftskip",
2631 /* 0381 */ "", //"rightskip",
2632 /* 0382 */ "", //"topskip",
2633 /* 0383 */ "", //"splittopskip",
2634 /* 0384 */ "", //"tabskip",
2635 /* 0385 */ "", //"spaceskip",
2636 /* 0386 */ "", //"xspaceskip",
2637 /* 0387 */ "", //"parfillskip",
2638 /* 0388 */ "", //"thinmuskip",
2639 /* 0389 */ "", //"medmuskip",
2640 /* 0390 */ "", //"thickmuskip",
2641 /* 0391 */ "", //"[unknown glue parameter!]",
2642 /* 0392 */ "", //"skip",
2643 /* 0393 */ "", //"muskip",
2644 /* 0394 */ "", //"pt",
2645 /* 0395 */ "", //"output",
2646 /* 0396 */ "", //"everypar",
2647 /* 0397 */ "", //"everymath",
2648 /* 0398 */ "", //"everydisplay",
2649 /* 0399 */ "", //"everyhbox",
2650 /* 0400 */ "", //"everyvbox",
2651 /* 0401 */ "", //"everyjob",
2652 /* 0402 */ "", //"everycr",
2653 /* 0403 */ "", //"errhelp",
2654 /* 0404 */ "", //"toks",
2655 /* 0405 */ "", //"parshape",
2656 /* 0406 */ "", //"box",
2657 /* 0407 */ "", //"void",
2658 /* 0408 */ "", //"current font",
2659 /* 0409 */ "", //"textfont",
2660 /* 0410 */ "", //"scriptfont",
2661 /* 0411 */ "", //"scriptscriptfont",
2662 /* 0412 */ "", //"catcode",
2663 /* 0413 */ "", //"lccode",
2664 /* 0414 */ "", //"uccode",
2665 /* 0415 */ "", //"sfcode",
2666 /* 0416 */ "", //"mathcode",
2667 /* 0417 */ "", //"pretolerance",
2668 /* 0418 */ "", //"tolerance",
2669 /* 0419 */ "", //"linepenalty",
2670 /* 0420 */ "", //"hyphenpenalty",
2671 /* 0421 */ "", //"exhyphenpenalty",
2672 /* 0422 */ "", //"clubpenalty",
2673 /* 0423 */ "", //"widowpenalty",
2674 /* 0424 */ "", //"displaywidowpenalty",
2675 /* 0425 */ "", //"brokenpenalty",
2676 /* 0426 */ "", //"binoppenalty",
2677 /* 0427 */ "", //"relpenalty",
2678 /* 0428 */ "", //"predisplaypenalty",
2679 /* 0429 */ "", //"postdisplaypenalty",
2680 /* 0430 */ "", //"interlinepenalty",
2681 /* 0431 */ "", //"doublehyphendemerits",
2682 /* 0432 */ "", //"finalhyphendemerits",
2683 /* 0433 */ "", //"adjdemerits",
2684 /* 0434 */ "", //"mag",
2685 /* 0435 */ "", //"delimiterfactor",
2686 /* 0436 */ "", //"looseness",
2687 /* 0437 */ "", //"time",
2688 /* 0438 */ "", //"day",
2689 /* 0439 */ "", //"month",
2690 /* 0440 */ "", //"year",
2691 /* 0441 */ "", //"showboxbreadth",
2692 /* 0442 */ "", //"showboxdepth",
2693 /* 0443 */ "", //"hbadness",
2694 /* 0444 */ "", //"vbadness",
2695 /* 0445 */ "", //"pausing",
2696 /* 0446 */ "", //"tracingonline",
2697 /* 0447 */ "", //"tracingmacros",
2698 /* 0448 */ "", //"tracingstats",
2699 /* 0449 */ "", //"tracingparagraphs",
2700 /* 0450 */ "", //"tracingpages",
2701 /* 0451 */ "", //"tracingoutput",
2702 /* 0452 */ "", //"tracinglostchars",
2703 /* 0453 */ "", //"tracingcommands",
2704 /* 0454 */ "", //"tracingrestores",
2705 /* 0455 */ "", //"uchyph",
2706 /* 0456 */ "", //"outputpenalty",
2707 /* 0457 */ "", //"maxdeadcycles",
2708 /* 0458 */ "", //"hangafter",
2709 /* 0459 */ "", //"floatingpenalty",
2710 /* 0460 */ "", //"globaldefs",
2711 /* 0461 */ "", //"fam",
2712 /* 0462 */ "", //"escapechar",
2713 /* 0463 */ "", //defaulthyphenchar",
2714 /* 0464 */ "", //"defaultskewchar",
2715 /* 0465 */ "", //"endlinechar",
2716 /* 0466 */ "", //"newlinechar",
2717 /* 0467 */ "", //"language",
2718 /* 0468 */ "", //"lefthyphenmin",
2719 /* 0469 */ "", //"righthyphenmin",
2720 /* 0470 */ "", //"holdinginserts",
2721 /* 0471 */ "", //"errorcontextlines",
2722 /* 0472 */ "", //"[unknown integer parameter!]",
2723 /* 0473 */ "", //"count",
2724 /* 0474 */ "", //"delcode",
2725 /* 0475 */ "", //"parindent",
2726 /* 0476 */ "", //"mathsurround",
2727 /* 0477 */ "", //"lineskiplimit",
2728 /* 0478 */ "", //"hsize",
2729 /* 0479 */ "", //"vsize",
2730 /* 0480 */ "", //"maxdepth",
2731 /* 0481 */ "", //"splitmaxdepth",
2732 /* 0482 */ "", //"boxmaxdepth",
2733 /* 0483 */ "", //"hfuzz",
2734 /* 0484 */ "", //"vfuzz",
2735 /* 0485 */ "", //"delimitershortfall",
2736 /* 0486 */ "", //"nulldelimiterspace",
2737 /* 0487 */ "", //"scriptspace",
2738 /* 0488 */ "", //"predisplaysize",
2739 /* 0489 */ "", //"displaywidth",
2740 /* 0490 */ "", //"displayindent",
2741 /* 0491 */ "", //"overfullrule",
2742 /* 0492 */ "", //"hangindent",
2743 /* 0493 */ "", //"hoffset",
2744 /* 0494 */ "", //"voffset",
2745 /* 0495 */ "", //"emergencystretch",
2746 /* 0496 */ "", //"[unknown dimen parameter!]",
2747 /* 0497 */ "", //"dimen",
2748 /* 0498 */ "", //"EQUIV(",
2749 /* 0499 */ "notexpanded:",
2750 /* 0500 */ "", //"hash size",
2751 /* 0501 */ "", //"csname",
2752 /* 0502 */ "", //"endcsname",
2753 /* 0503 */ "", //"IMPOSSIBLE.",
2754 /* 0504 */ "", //"NONEXISTENT.",
2755 /* 0505 */ "", //"accent",
2756 /* 0506 */ "", //"advance",
2757 /* 0507 */ "", //"afterassignment",
2758 /* 0508 */ "", //"aftergroup",
2759 /* 0509 */ "", //"begingroup",
2760 /* 0510 */ "", //"char",
2761 /* 0511 */ "", //"delimiter",
2762 /* 0512 */ "", //"divide",
2763 /* 0513 */ "", //"endgroup",
2764 /* 0514 */ "", //"expandafter",
2765 /* 0515 */ "", //"font",
2766 /* 0516 */ "", //"fontdimen",
2767 /* 0517 */ "", //"halign",
2768 /* 0518 */ "", //"hrule",
2769 /* 0519 */ "", //"ignorespaces",
2770 /* 0520 */ "", //"mathaccent",
2771 /* 0521 */ "", //"mathchar",
2772 /* 0522 */ "", //"mathchoice",
2773 /* 0523 */ "", //"multiply",
2774 /* 0524 */ "", //"noalign",
2775 /* 0525 */ "", //"noboundary",
2776 /* 0526 */ "", //"noexpand",
2777 /* 0527 */ "", //"omit",
2778 /* 0528 */ "", //"penalty",
2779 /* 0529 */ "", //"prevgraf",
2780 /* 0530 */ "", //"radical",
2781 /* 0531 */ "", //"read",
2782 /* 0532 */ "", //"relax",
2783 /* 0533 */ "", //"setbox",
2784 /* 0534 */ "", //"the",
2785 /* 0535 */ "", //"valign",
2786 /* 0536 */ "", //"vcenter",
2787 /* 0537 */ "", //"vrule",
2788 /* 0538 */ "", //"save size",
2789 /* 0539 */ "", //"grouping levels",
2790 /* 0540 */ "", //"curlevel",
2791 /* 0541 */ "", //"retaining",
2792 /* 0542 */ "", //"restoring",
2793 /* 0543 */ "", //"SAVE(",
2794 /* 0544 */ "", //"Incompatible magnification (",
2795 /* 0545 */ "", //");",
2796 /* 0546 */ "", //" the previous value will be retained",
2797 /* 0547 */ "", //"I can handle only one magnification ratio per job. So I've",
2798 /* 0548 */ "", //"reverted to the magnification you used earlier on this run.",
2799 /* 0549 */ "", //"Illegal magnification has been changed to 1000",
2800 /* 0550 */ "", //"The magnification ratio must be between 1 and 32768.",
2801 /* 0551 */ "", //"ETC.",
2802 /* 0552 */ "", //"BAD.",
2803 /* 0553 */ "", //"->",
2804 /* 0554 */ "", //"begin-group character ",
2805 /* 0555 */ "", //"end-group character ",
2806 /* 0556 */ "", //"math shift character ",
2807 /* 0557 */ "", //"macro parameter character ",
2808 /* 0558 */ "", //"superscript character ",
2809 /* 0559 */ "", //"subscript character ",
2810 /* 0560 */ "", //"end of alignment template",
2811 /* 0561 */ "", //"blank space ",
2812 /* 0562 */ "", //"the letter ",
2813 /* 0563 */ "", //"the character ",
2814 /* 0564 */ "", //"[unknown command code!]",
2815 /* 0565 */ "", //": ",
2816 /* 0566 */ "", //"Runaway ",
2817 /* 0567 */ "", //"definition",
2818 /* 0568 */ "", //"argument",
2819 /* 0569 */ "", //"preamble",
2820 /* 0570 */ "", //"text",
2821 /* 0571 */ "", //"<*>",
2822 /* 0572 */ "", //"<insert> ",
2823 /* 0573 */ "", //"<read ",
2824 /* 0574 */ "", //"l.",
2825 /* 0575 */ "", //"<argument> ",
2826 /* 0576 */ "", //"<template> ",
2827 /* 0577 */ "", //"<recently read> ",
2828 /* 0578 */ "", //"<to be read again> ",
2829 /* 0579 */ "", //"<inserted text> ",
2830 /* 0580 */ "", //"<output> ",
2831 /* 0581 */ "", //"<everypar> ",
2832 /* 0582 */ "", //"<everymath> ",
2833 /* 0583 */ "", //"<everydisplay> ",
2834 /* 0584 */ "", //"<everyhbox> ",
2835 /* 0585 */ "", //"<everyvbox> ",
2836 /* 0586 */ "", //"<everyjob> ",
2837 /* 0587 */ "", //"<everycr> ",
2838 /* 0588 */ "", //"<mark> ",
2839 /* 0589 */ "", //"<write> ",
2840 /* 0590 */ "", //"input stack size",
2841 /* 0591 */ "", //"write",
2842 /* 0592 */ "", //"(interwoven alignment preambles are not allowed)",
2843 /* 0593 */ "", //"text input levels",
2844 /* 0594 */ "", //"par",
2845 /* 0595 */ "", //"Incomplete ",
2846 /* 0596 */ "", //"; all text was ignored after line ",
2847 /* 0597 */ "", //"A forbidden control sequence occurred in skipped text.",
2848 /* 0598 */ "", //"This kind of error happens when you say `\\if...' and forget",
2849 /* 0599 */ "", //"the matching `\\fi'. I've inserted a `\\fi'; this might work.",
2850 /* 0600 */ "", //"The file ended while I was skipping conditional text.",
2851 /* 0601 */ "", //"File ended",
2852 /* 0602 */ "", //"Forbidden control sequence found",
2853 /* 0603 */ "", //" while scanning ",
2854 /* 0604 */ "", //" of ",
2855 /* 0605 */ "", //"I suspect you have forgotten a `}', causing me",
2856 /* 0606 */ "", //"to read past where you wanted me to stop.",
2857 /* 0607 */ "", //"I'll try to recover; but if the error is serious,",
2858 /* 0608 */ "", //"you'd better type `E' or `X' now and fix your file.",
2859 /* 0609 */ "", //"use",
2860 /* 0610 */ "", //"Text line contains an invalid character",
2861 /* 0611 */ "", //"A funny symbol that I can't read has just been input.",
2862 /* 0612 */ "", //"Continue, and I'll forget that it ever happened.",
2863 /* 0613 */ "", //"(Please type a command or say `\\end')",
2864 /* 0614 */ "", //"*** (job aborted, no legal \\end found)",
2865 /* 0615 */ "", //"=>",
2866 /* 0616 */ "", //"Undefined control sequence",
2867 /* 0617 */ "", //"The control sequence at the end of the top line",
2868 /* 0618 */ "", //"of your error message was never \\def'ed. If you have",
2869 /* 0619 */ "", //"misspelled it (e.g., `\\hobx'), type `I' and the correct",
2870 /* 0620 */ "", //"spelling (e.g., `I\\hbox'). Otherwise just continue,",
2871 /* 0621 */ "", //"and I'll forget about whatever was undefined.",
2872 /* 0622 */ "", //"Missing ",
2873 /* 0623 */ "", //" inserted",
2874 /* 0624 */ "", //"The control sequence marked <to be read again> should",
2875 /* 0625 */ "", //"not appear between \\csname and \\endcsname.",
2876 /* 0626 */ "", //"input",
2877 /* 0627 */ "", //"endinput",
2878 /* 0628 */ "", //"topmark",
2879 /* 0629 */ "", //"firstmark",
2880 /* 0630 */ "", //"botmark",
2881 /* 0631 */ "", //"splitfirstmark",
2882 /* 0632 */ "", //"splitbotmark",
2883 /* 0633 */ "", //"parameter stack size",
2884 /* 0634 */ "", //"Argument of ",
2885 /* 0635 */ "", //" has an extra }",
2886 /* 0636 */ "", //"I've run across a `}' that doesn't seem to match anything.",
2887 /* 0637 */ "", //"For example, `\\def\\a#1{...}' and `\\a}' would produce",
2888 /* 0638 */ "", //"this error. If you simply proceed now, the `\\par' that",
2889 /* 0639 */ "", //"I've just inserted will cause me to report a runaway",
2890 /* 0640 */ "", //"argument that might be the root of the problem. But if",
2891 /* 0641 */ "", //"your `}' was spurious, just type `2' and it will go away.",
2892 /* 0642 */ "", //"Paragraph ended before ",
2893 /* 0643 */ "", //" was complete",
2894 /* 0644 */ "", //"I suspect you've forgotten a `}', causing me to apply this",
2895 /* 0645 */ "", //"control sequence to too much text. How can we recover" "?",
2896 /* 0646 */ "", //"My plan is to forget the whole thing and hope for the best.",
2897 /* 0647 */ "", //"Use of ",
2898 /* 0648 */ "", //" doesn't match its definition",
2899 /* 0649 */ "", //"If you say, e.g., `\\def\\a1{...}', then you must always",
2900 /* 0650 */ "", //"put `1' after `\\a', since control sequence names are",
2901 /* 0651 */ "", //"made up of letters only. The macro here has not been",
2902 /* 0652 */ "", //"followed by the required stuff, so I'm ignoring it.",
2903 /* 0653 */ "", //"<-",
2904 /* 0654 */ "", //"Missing { inserted",
2905 /* 0655 */ "", //"A left brace was mandatory here, so I've put one in.",
2906 /* 0656 */ "", //"You might want to delete and/or insert some corrections",
2907 /* 0657 */ "", //"so that I will find a matching right brace soon.",
2908 /* 0658 */ "", //"(If you're confused by all this, try typing `I}' now.)",
2909 /* 0659 */ "", //"Incompatible glue units",
2910 /* 0660 */ "", //"I'm going to assume that 1mu=1pt when they're mixed.",
2911 /* 0661 */ "", //"Missing number, treated as zero",
2912 /* 0662 */ "", //"A number should have been here; I inserted `0'.",
2913 /* 0663 */ "", //"(If you can't figure out why I needed to see a number,",
2914 /* 0664 */ "", //"look up `weird error' in the index to The TeXbook.)",
2915 /* 0665 */ "", //"spacefactor",
2916 /* 0666 */ "", //"prevdepth",
2917 /* 0667 */ "", //"deadcycles",
2918 /* 0668 */ "", //"insertpenalties",
2919 /* 0669 */ "", //"wd",
2920 /* 0670 */ "", //"ht",
2921 /* 0671 */ "", //"dp",
2922 /* 0672 */ "", //"lastpenalty",
2923 /* 0673 */ "", //"lastkern",
2924 /* 0674 */ "", //"lastskip",
2925 /* 0675 */ "", //"inputlineno",
2926 /* 0676 */ "", //"badness",
2927 /* 0677 */ "", //"Improper ",
2928 /* 0678 */ "", //"You can refer to \\spacefactor only in horizontal mode;",
2929 /* 0679 */ "", //"you can refer to \\prevdepth only in vertical mode; and",
2930 /* 0680 */ "", //"neither of these is meaningful inside \\write. So",
2931 /* 0681 */ "", //"I'm forgetting what you said and using zero instead.",
2932 /* 0682 */ "", //"You can't use `",
2933 /* 0683 */ "", //"' after ",
2934 /* 0684 */ "", //"Bad register code",
2935 /* 0685 */ "", //"A register number must be between 0 and 255.",
2936 /* 0686 */ "", //"I changed this one to zero.",
2937 /* 0687 */ "", //"Bad character code",
2938 /* 0688 */ "", //"A character number must be between 0 and 255.",
2939 /* 0689 */ "", //"Bad number",
2940 /* 0690 */ "", //"Since I expected to read a number between 0 and 15,",
2941 /* 0691 */ "", //"Bad mathchar",
2942 /* 0692 */ "", //"A mathchar number must be between 0 and 32767.",
2943 /* 0693 */ "", //"Bad delimiter code",
2944 /* 0694 */ "", //"A numeric delimiter code must be between 0 and 2^{27}-1.",
2945 /* 0695 */ "", //"Improper alphabetic constant",
2946 /* 0696 */ "", //"A one-character control sequence belongs after a ` mark.",
2947 /* 0697 */ "", //"So I'm essentially inserting \\0 here.",
2948 /* 0698 */ "", //"Number too big",
2949 /* 0699 */ "", //"I can only go up to 2147483647='17777777777=\"7FFFFFFF,",
2950 /* 0700 */ "", //"so I'm using that number instead of yours.",
2951 /* 0701 */ "", //"true",
2952 /* 0702 */ "", //"Illegal unit of measure (",
2953 /* 0703 */ "", //"replaced by filll)",
2954 /* 0704 */ "", //"I dddon't go any higher than filll.",
2955 /* 0705 */ "", //"em",
2956 /* 0706 */ "", //"ex",
2957 /* 0707 */ "", //"mu inserted)",
2958 /* 0708 */ "", //"The unit of measurement in math glue must be mu.",
2959 /* 0709 */ "", //"To recover gracefully from this error, it's best to",
2960 /* 0710 */ "", //"delete the erroneous units; e.g., type `2' to delete",
2961 /* 0711 */ "", //"two letters. (See Chapter 27 of The TeXbook.)",
2962 /* 0712 */ "", //"in",
2963 /* 0713 */ "", //"pc",
2964 /* 0714 */ "", //"cm",
2965 /* 0715 */ "", //"mm",
2966 /* 0716 */ "", //"bp",
2967 /* 0717 */ "", //"dd",
2968 /* 0718 */ "", //"cc",
2969 /* 0719 */ "", //"sp",
2970 /* 0720 */ "", //"pt inserted)",
2971 /* 0721 */ "", //"Dimensions can be in units of em, ex, in, pt, pc,",
2972 /* 0722 */ "", //"cm, mm, dd, cc, bp, or sp; but yours is a new one!",
2973 /* 0723 */ "", //"I'll assume that you meant to say pt, for printer's points.",
2974 /* 0724 */ "", //"Dimension too large",
2975 /* 0725 */ "", //"I can't work with sizes bigger than about 19 feet.",
2976 /* 0726 */ "", //"Continue and I'll use the largest value I can.",
2977 /* 0727 */ "", //"plus",
2978 /* 0728 */ "", //"minus",
2979 /* 0729 */ "", //"width",
2980 /* 0730 */ "", //"height",
2981 /* 0731 */ "", //"depth",
2982 /* 0732 */ "", //"number",
2983 /* 0733 */ "", //"romannumeral",
2984 /* 0734 */ "", //"string",
2985 /* 0735 */ "", //"meaning",
2986 /* 0736 */ "", //"fontname",
2987 /* 0737 */ "", //"jobname",
2988 /* 0738 */ "", //" at ",
2989 /* 0739 */ "", //"Where was the left brace" "? You said something like `\\def\\a}',",
2990 /* 0740 */ "", //"which I'm going to interpret as `\\def\\a{}'.",
2991 /* 0741 */ "", //"You already have nine parameters",
2992 /* 0742 */ "", //"I'm going to ignore the # sign you just used.",
2993 /* 0743 */ "", //"Parameters must be numbered consecutively",
2994 /* 0744 */ "", //"I've inserted the digit you should have used after the #.",
2995 /* 0745 */ "", //"Type `1' to delete what you did use.",
2996 /* 0746 */ "", //"Illegal parameter number in definition of ",
2997 /* 0747 */ "", //"You meant to type ## instead of #, right" "?",
2998 /* 0748 */ "", //"Or maybe a } was forgotten somewhere earlier, and things",
2999 /* 0749 */ "", //"are all screwed up" "? I'm going to assume that you meant ##.",
3000 /* 0750 */ "", //"*** (cannot \\read from terminal in nonstop modes)",
3001 /* 0751 */ "", //"File ended within ",
3002 /* 0752 */ "", //"This \\read has unbalanced braces.",
3003 /* 0753 */ "", //"if",
3004 /* 0754 */ "", //"ifcat",
3005 /* 0755 */ "", //"ifnum",
3006 /* 0756 */ "", //"ifdim",
3007 /* 0757 */ "", //"ifodd",
3008 /* 0758 */ "", //"ifvmode",
3009 /* 0759 */ "", //"ifhmode",
3010 /* 0760 */ "", //"ifmmode",
3011 /* 0761 */ "", //"ifinner",
3012 /* 0762 */ "", //"ifvoid",
3013 /* 0763 */ "", //"ifhbox",
3014 /* 0764 */ "", //"ifvbox",
3015 /* 0765 */ "", //"ifx",
3016 /* 0766 */ "", //"ifeof",
3017 /* 0767 */ "", //"iftrue",
3018 /* 0768 */ "", //"iffalse",
3019 /* 0769 */ "", //"ifcase",
3020 /* 0770 */ "", //"fi",
3021 /* 0771 */ "", //"or",
3022 /* 0772 */ "", //"else",
3023 /* 0773 */ "", //"Extra ",
3024 /* 0774 */ "", //"I'm ignoring this; it doesn't match any \\if.",
3025 /* 0775 */ "", //"{true}",
3026 /* 0776 */ "", //"{false}",
3027 /* 0777 */ "", //"Missing = inserted for ",
3028 /* 0778 */ "", //"I was expecting to see `<', `=', or `>'. Didn't.",
3029 /* 0779 */ "", //"{case ",
3030 /* 0780 */ "", //".fmt",
3031 /* 0781 */ "", //"input file name",
3032 /* 0782 */ "", //"I can't find file `",
3033 /* 0783 */ "", //"I can't write on file `",
3034 /* 0784 */ "", //"'.",
3035 /* 0785 */ ".tex",
3036 /* 0786 */ "", //"Please type another ",
3037 /* 0787 */ "", //"*** (job aborted, file error in nonstop mode)",
3038 /* 0788 */ "", //".dvi",
3039 /* 0789 */ "", //"file name for output",
3040 /* 0790 */ "texput",
3041 /* 0791 */ "", //".log",
3042 /* 0792 */ "", //"**",
3043 /* 0793 */ "", //"transcript file name",
3044 /* 0794 */ " ",
3045 /* 0795 */ "nullfont",
3046 /* 0796 */ "", //"Font ",
3047 /* 0797 */ "", //" scaled ",
3048 /* 0798 */ "", //" not loadable: Bad metric (TFM) file",
3049 /* 0799 */ "", //" not loadable: Metric (TFM) file not found",
3050 /* 0800 */ "", //"I wasn't able to read the size data for this font,",
3051 /* 0801 */ "", //"so I will ignore the font specification.",
3052 /* 0802 */ "", //"[Wizards can fix TFM files using TFtoPL/PLtoTF.]",
3053 /* 0803 */ "", //"You might try inserting a different font spec;",
3054 /* 0804 */ "", //"e.g., type `I\\font<same font id>=<substitute font name>'.",
3055 /* 0805 */ ".tfm",
3056 /* 0806 */ "", //" not loaded: Not enough room left",
3057 /* 0807 */ "", //"I'm afraid I won't be able to make use of this font,",
3058 /* 0808 */ "", //"because my memory for character-size data is too small.",
3059 /* 0809 */ "", //"If you're really stuck, ask a wizard to enlarge me.",
3060 /* 0810 */ "", //"Or maybe try `I\\font<same font id>=<name of loaded font>'.",
3061 /* 0811 */ "", //"Missing font identifier",
3062 /* 0812 */ "", //"I was looking for a control sequence whose",
3063 /* 0813 */ "", //"current meaning has been defined by \\font.",
3064 /* 0814 */ "", //" has only ",
3065 /* 0815 */ "", //" fontdimen parameters",
3066 /* 0816 */ "", //"To increase the number of font parameters, you must",
3067 /* 0817 */ "", //"use \\fontdimen immediately after the \\font is loaded.",
3068 /* 0818 */ "", //"font memory",
3069 /* 0819 */ "", //"Missing character: There is no ",
3070 /* 0820 */ "", //" in font ",
3071 /* 0821 */ "", //" TeX output ",
3072 /* 0822 */ "", //"vlistout",
3073 /* 0823 */ "", //"Completed box being shipped out",
3074 /* 0824 */ "", //"Memory usage before: ",
3075 /* 0825 */ "", //" after: ",
3076 /* 0826 */ "", //"; still untouched: ",
3077 /* 0827 */ "", //"Huge page cannot be shipped out",
3078 /* 0828 */ "", //"The page just created is more than 18 feet tall or",
3079 /* 0829 */ "", //"more than 18 feet wide, so I suspect something went wrong.",
3080 /* 0830 */ "", //"The following box has been deleted:",
3081 /* 0831 */ "", //"No pages of output.",
3082 /* 0832 */ "", //"Output written on ",
3083 /* 0833 */ "", //" page",
3084 /* 0834 */ "", //", ",
3085 /* 0835 */ "", //" bytes).",
3086 /* 0836 */ "", //"to",
3087 /* 0837 */ "", //"spread",
3088 /* 0838 */ "", //"Underfull",
3089 /* 0839 */ "", //"Loose",
3090 /* 0840 */ "", //" \\hbox (badness ",
3091 /* 0841 */ "", //") has occurred while \\output is active",
3092 /* 0842 */ "", //") in paragraph at lines ",
3093 /* 0843 */ "", //") in alignment at lines ",
3094 /* 0844 */ "", //"--",
3095 /* 0845 */ "", //") detected at line ",
3096 /* 0846 */ "", //"Overfull \\hbox (",
3097 /* 0847 */ "", //"pt too wide",
3098 /* 0848 */ "", //"Tight \\hbox (badness ",
3099 /* 0849 */ "", //"vpack",
3100 /* 0850 */ "", //" \\vbox (badness ",
3101 /* 0851 */ "", //"Overfull \\vbox (",
3102 /* 0852 */ "", //"pt too high",
3103 /* 0853 */ "", //"Tight \\vbox (badness ",
3104 /* 0854 */ "", //"{}",
3105 /* 0855 */ "", //"displaystyle",
3106 /* 0856 */ "", //"textstyle",
3107 /* 0857 */ "", //"scriptstyle",
3108 /* 0858 */ "", //"scriptscriptstyle",
3109 /* 0859 */ "", //"Unknown style!",
3110 /* 0860 */ "", //"mathord",
3111 /* 0861 */ "", //"mathop",
3112 /* 0862 */ "", //"mathbin",
3113 /* 0863 */ "", //"mathrel",
3114 /* 0864 */ "", //"mathopen",
3115 /* 0865 */ "", //"mathclose",
3116 /* 0866 */ "", //"mathpunct",
3117 /* 0867 */ "", //"mathinner",
3118 /* 0868 */ "", //"overline",
3119 /* 0869 */ "", //"underline",
3120 /* 0870 */ "", //"left",
3121 /* 0871 */ "", //"right",
3122 /* 0872 */ "", //"limits",
3123 /* 0873 */ "", //"nolimits",
3124 /* 0874 */ "", //"fraction, thickness ",
3125 /* 0875 */ "", //"= default",
3126 /* 0876 */ "", //", left-delimiter ",
3127 /* 0877 */ "", //", right-delimiter ",
3128 /* 0878 */ "", //" is undefined (character ",
3129 /* 0879 */ "", //"Somewhere in the math formula just ended, you used the",
3130 /* 0880 */ "", //"stated character from an undefined font family. For example,",
3131 /* 0881 */ "", //"plain TeX doesn't allow \\it or \\sl in subscripts. Proceed,",
3132 /* 0882 */ "", //"and I'll try to forget that I needed that character.",
3133 /* 0883 */ "", //"mlist1",
3134 /* 0884 */ "", //"mlist2",
3135 /* 0885 */ "", //"mlist3",
3136 /* 0886 */ "0234000122*4000133**3**344*0400400*000000234000111*1111112341011",
3137 /* 0887 */ "", //"mlist4",
3138 /* 0888 */ "", //" inside $$'s",
3139 /* 0889 */ "", //"Displays can use special alignments (like \\eqalignno)",
3140 /* 0890 */ "", //"only if nothing but the alignment itself is between $$'s.",
3141 /* 0891 */ "", //"So I've deleted the formulas that preceded this alignment.",
3142 /* 0892 */ "", //"span",
3143 /* 0893 */ "", //"cr",
3144 /* 0894 */ "", //"crcr",
3145 /* 0895 */ "endtemplate",
3146 /* 0896 */ "", //"alignment tab character ",
3147 /* 0897 */ "", //"Missing # inserted in alignment preamble",
3148 /* 0898 */ "", //"There should be exactly one # between &'s, when an",
3149 /* 0899 */ "", //"\\halign or \\valign is being set up. In this case you had",
3150 /* 0900 */ "", //"none, so I've put one in; maybe that will work.",
3151 /* 0901 */ "", //"Only one # is allowed per tab",
3152 /* 0902 */ "", //"more than one, so I'm ignoring all but the first.",
3153 /* 0903 */ "", //"endv",
3154 /* 0904 */ "", //"Extra alignment tab has been changed to ",
3155 /* 0905 */ "", //"You have given more \\span or & marks than there were",
3156 /* 0906 */ "", //"in the preamble to the \\halign or \\valign now in progress.",
3157 /* 0907 */ "", //"So I'll assume that you meant to type \\cr instead.",
3158 /* 0908 */ "", //"256 spans",
3159 /* 0909 */ "", //"align1",
3160 /* 0910 */ "", //"align0",
3161 /* 0911 */ "", //"Infinite glue shrinkage found in a paragraph",
3162 /* 0912 */ "", //"The paragraph just ended includes some glue that has",
3163 /* 0913 */ "", //"infinite shrinkability, e.g., `\\hskip 0pt minus 1fil'.",
3164 /* 0914 */ "", //"Such glue doesn't belong there---it allows a paragraph",
3165 /* 0915 */ "", //"of any length to fit on one line. But it's safe to proceed,",
3166 /* 0916 */ "", //"since the offensive shrinkability has been made finite.",
3167 /* 0917 */ "", //"disc1",
3168 /* 0918 */ "", //"disc2",
3169 /* 0919 */ "", //"@@",
3170 /* 0920 */ "", //": line ",
3171 /* 0921 */ "", //" t=",
3172 /* 0922 */ "", //" -> @@",
3173 /* 0923 */ "", //" via @@",
3174 /* 0924 */ "", //" b=",
3175 /* 0925 */ "", //" p=",
3176 /* 0926 */ "", //" d=",
3177 /* 0927 */ "", //"@firstpass",
3178 /* 0928 */ "", //"@secondpass",
3179 /* 0929 */ "", //"@emergencypass",
3180 /* 0930 */ "", //"paragraph",
3181 /* 0931 */ "", //"disc3",
3182 /* 0932 */ "", //"disc4",
3183 /* 0933 */ "", //"line breaking",
3184 /* 0934 */ "", //"HYPH(",
3185 /* 0935 */ "", //"hyphenation",
3186 /* 0936 */ "", //" will be flushed",
3187 /* 0937 */ "", //"Hyphenation exceptions must contain only letters",
3188 /* 0938 */ "", //"and hyphens. But continue; I'll forgive and forget.",
3189 /* 0939 */ "", //"Not a letter",
3190 /* 0940 */ "", //"Letters in \\hyphenation words must have \\lccode>0.",
3191 /* 0941 */ "", //"Proceed; I'll ignore the character I just read.",
3192 /* 0942 */ "", //"exception dictionary",
3193 /* 0943 */ "", //"pattern memory ops",
3194 /* 0944 */ "", //"pattern memory ops per language",
3195 /* 0945 */ "", //"pattern memory",
3196 /* 0946 */ "", //"Too late for ",
3197 /* 0947 */ "", //"patterns",
3198 /* 0948 */ "", //"All patterns must be given before typesetting begins.",
3199 /* 0949 */ "", //"Bad ",
3200 /* 0950 */ "", //"(See Appendix H.)",
3201 /* 0951 */ "", //"Nonletter",
3202 /* 0952 */ "", //"Duplicate pattern",
3203 /* 0953 */ "", //"pruning",
3204 /* 0954 */ "", //"vertbreak",
3205 /* 0955 */ "", //"Infinite glue shrinkage found in box being split",
3206 /* 0956 */ "", //"The box you are \\vsplitting contains some infinitely",
3207 /* 0957 */ "", //"shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
3208 /* 0958 */ "", //"Such glue doesn't belong there; but you can safely proceed,",
3209 /* 0959 */ "", //"vsplit",
3210 /* 0960 */ "", //" needs a ",
3211 /* 0961 */ "", //"vbox",
3212 /* 0962 */ "", //"The box you are trying to split is an \\hbox.",
3213 /* 0963 */ "", //"I can't split such a box, so I'll leave it alone.",
3214 /* 0964 */ "", //"pagegoal",
3215 /* 0965 */ "", //"pagetotal",
3216 /* 0966 */ "", //"pagestretch",
3217 /* 0967 */ "", //"pagefilstretch",
3218 /* 0968 */ "", //"pagefillstretch",
3219 /* 0969 */ "", //"pagefilllstretch",
3220 /* 0970 */ "", //"pageshrink",
3221 /* 0971 */ "", //"pagedepth",
3222 /* 0972 */ "", //"fill",
3223 /* 0973 */ "", //"filll",
3224 /* 0974 */ "", //"### current page:",
3225 /* 0975 */ "", //" (held over for next output)",
3226 /* 0976 */ "", //"total height ",
3227 /* 0977 */ "", //" goal height ",
3228 /* 0978 */ "", //" adds ",
3229 /* 0979 */ "", //", #",
3230 /* 0980 */ "", //" might split",
3231 /* 0981 */ "", //"%% goal height=",
3232 /* 0982 */ "", //", max depth=",
3233 /* 0983 */ "", //"Insertions can only be added to a vbox",
3234 /* 0984 */ "", //"Tut tut: You're trying to \\insert into a",
3235 /* 0985 */ "", //"\\box register that now contains an \\hbox.",
3236 /* 0986 */ "", //"Proceed, and I'll discard its present contents.",
3237 /* 0987 */ "", //"page",
3238 /* 0988 */ "", //"Infinite glue shrinkage found on current page",
3239 /* 0989 */ "", //"The page about to be output contains some infinitely",
3240 /* 0990 */ "", //" g=",
3241 /* 0991 */ "", //" c=",
3242 /* 0992 */ "", //"Infinite glue shrinkage inserted from ",
3243 /* 0993 */ "", //"The correction glue for page breaking with insertions",
3244 /* 0994 */ "", //"must have finite shrinkability. But you may proceed,",
3245 /* 0995 */ "", //"% split",
3246 /* 0996 */ "", //" to ",
3247 /* 0997 */ "", //"255 is not void",
3248 /* 0998 */ "", //"You shouldn't use \\box255 except in \\output routines.",
3249 /* 0999 */ "", //"Output loop---",
3250 /* 1000 */ "", //" consecutive dead cycles",
3251 /* 1001 */ "", //"I've concluded that your \\output is awry; it never does a",
3252 /* 1002 */ "", //"\\shipout, so I'm shipping \\box255 out myself. Next time",
3253 /* 1003 */ "", //"increase \\maxdeadcycles if you want me to be more patient!",
3254 /* 1004 */ "", //"Unbalanced output routine",
3255 /* 1005 */ "", //"Your sneaky output routine has problematic {'s and/or }'s.",
3256 /* 1006 */ "", //"I can't handle that very well; good luck.",
3257 /* 1007 */ "", //"Output routine didn't use all of ",
3258 /* 1008 */ "", //"Your \\output commands should empty \\box255,",
3259 /* 1009 */ "", //"e.g., by saying `\\shipout\\box255'.",
3260 /* 1010 */ "", //"Proceed; I'll discard its present contents.",
3261 /* 1011 */ "", //"Missing $ inserted",
3262 /* 1012 */ "", //"I've inserted a begin-math/end-math symbol since I think",
3263 /* 1013 */ "", //"you left one out. Proceed, with fingers crossed.",
3264 /* 1014 */ "", //"' in ",
3265 /* 1015 */ "", //"Sorry, but I'm not programmed to handle this case;",
3266 /* 1016 */ "", //"I'll just pretend that you didn't ask for it.",
3267 /* 1017 */ "", //"If you're in the wrong mode, you might be able to",
3268 /* 1018 */ "", //"return to the right one by typing `I}' or `I$' or `I\\par'.",
3269 /* 1019 */ "", //"end",
3270 /* 1020 */ "", //"dump",
3271 /* 1021 */ "", //"hskip",
3272 /* 1022 */ "", //"hfil",
3273 /* 1023 */ "", //"hfill",
3274 /* 1024 */ "", //"hss",
3275 /* 1025 */ "", //"hfilneg",
3276 /* 1026 */ "", //"vskip",
3277 /* 1027 */ "", //"vfil",
3278 /* 1028 */ "", //"vfill",
3279 /* 1029 */ "", //"vss",
3280 /* 1030 */ "", //"vfilneg",
3281 /* 1031 */ "", //"I've inserted something that you may have forgotten.",
3282 /* 1032 */ "", //"(See the <inserted text> above.)",
3283 /* 1033 */ "", //"With luck, this will get me unwedged. But if you",
3284 /* 1034 */ "", //"really didn't forget anything, try typing `2' now; then",
3285 /* 1035 */ "", //"my insertion and my current dilemma will both disappear.",
3286 /* 1036 */ "", //"right.",
3287 /* 1037 */ "", //"Things are pretty mixed up, but I think the worst is over.",
3288 /* 1038 */ "", //"Too many }'s",
3289 /* 1039 */ "", //"You've closed more groups than you opened.",
3290 /* 1040 */ "", //"Such booboos are generally harmless, so keep going.",
3291 /* 1041 */ "", //"rightbrace",
3292 /* 1042 */ "", //"Extra }, or forgotten ",
3293 /* 1043 */ "", //"I've deleted a group-closing symbol because it seems to be",
3294 /* 1044 */ "", //"spurious, as in `$x}$'. But perhaps the } is legitimate and",
3295 /* 1045 */ "", //"you forgot something else, as in `\\hbox{$x}'. In such cases",
3296 /* 1046 */ "", //"the way to recover is to insert both the forgotten and the",
3297 /* 1047 */ "", //"deleted material, e.g., by typing `I$}'.",
3298 /* 1048 */ "", //"moveleft",
3299 /* 1049 */ "", //"moveright",
3300 /* 1050 */ "", //"raise",
3301 /* 1051 */ "", //"lower",
3302 /* 1052 */ "", //"copy",
3303 /* 1053 */ "", //"lastbox",
3304 /* 1054 */ "", //"vtop",
3305 /* 1055 */ "", //"hbox",
3306 /* 1056 */ "", //"shipout",
3307 /* 1057 */ "", //"leaders",
3308 /* 1058 */ "", //"cleaders",
3309 /* 1059 */ "", //"xleaders",
3310 /* 1060 */ "", //"Leaders not followed by proper glue",
3311 /* 1061 */ "", //"You should say `\\leaders <box or rule><hskip or vskip>'.",
3312 /* 1062 */ "", //"I found the <box or rule>, but there's no suitable",
3313 /* 1063 */ "", //"<hskip or vskip>, so I'm ignoring these leaders.",
3314 /* 1064 */ "", //"Sorry; this \\lastbox will be void.",
3315 /* 1065 */ "", //"Sorry...I usually can't take things from the current page.",
3316 /* 1066 */ "", //"This \\lastbox will therefore be void.",
3317 /* 1067 */ "", //"Missing `to' inserted",
3318 /* 1068 */ "", //"I'm working on `\\vsplit<box number> to <dimen>';",
3319 /* 1069 */ "", //"will look for the <dimen> next.",
3320 /* 1070 */ "", //"A <box> was supposed to be here",
3321 /* 1071 */ "", //"I was expecting to see \\hbox or \\vbox or \\copy or \\box or",
3322 /* 1072 */ "", //"something like that. So you might find something missing in",
3323 /* 1073 */ "", //"your output. But keep trying; you can fix this later.",
3324 /* 1074 */ "", //"indent",
3325 /* 1075 */ "", //"noindent",
3326 /* 1076 */ "", //"' here except with leaders",
3327 /* 1077 */ "", //"To put a horizontal rule in an hbox or an alignment,",
3328 /* 1078 */ "", //"you should use \\leaders or \\hrulefill (see The TeXbook).",
3329 /* 1079 */ "", //"You can't ",
3330 /* 1080 */ "", //"I'm changing to \\insert0; box 255 is special.",
3331 /* 1081 */ "", //"Try `I\\vskip-\\lastskip' instead.",
3332 /* 1082 */ "", //"Try `I\\kern-\\lastkern' instead.",
3333 /* 1083 */ "", //"Perhaps you can make the output routine do it.",
3334 /* 1084 */ "", //"unpenalty",
3335 /* 1085 */ "", //"unkern",
3336 /* 1086 */ "", //"unskip",
3337 /* 1087 */ "", //"unhbox",
3338 /* 1088 */ "", //"unhcopy",
3339 /* 1089 */ "", //"unvbox",
3340 /* 1090 */ "", //"unvcopy",
3341 /* 1091 */ "", //"Incompatible list can't be unboxed",
3342 /* 1092 */ "", //"Sorry, Pandora. (You sneaky devil.)",
3343 /* 1093 */ "", //"I refuse to unbox an \\hbox in vertical mode or vice versa.",
3344 /* 1094 */ "", //"And I can't open any boxes in math mode.",
3345 /* 1095 */ "", //"Illegal math ",
3346 /* 1096 */ "", //"Sorry: The third part of a discretionary break must be",
3347 /* 1097 */ "", //"empty, in math formulas. I had to delete your third part.",
3348 /* 1098 */ "", //"Discretionary list is too long",
3349 /* 1099 */ "", //"Wow---I never thought anybody would tweak me here.",
3350 /* 1100 */ "", //"You can't seriously need such a huge discretionary list" "?",
3351 /* 1101 */ "", //"Improper discretionary list",
3352 /* 1102 */ "", //"Discretionary lists must contain only boxes and kerns.",
3353 /* 1103 */ "", //"The following discretionary sublist has been deleted:",
3354 /* 1104 */ "", //"Missing } inserted",
3355 /* 1105 */ "", //"I've put in what seems to be necessary to fix",
3356 /* 1106 */ "", //"the current column of the current alignment.",
3357 /* 1107 */ "", //"Try to go on, since this might almost work.",
3358 /* 1108 */ "", //"Misplaced ",
3359 /* 1109 */ "", //"I can't figure out why you would want to use a tab mark",
3360 /* 1110 */ "", //"here. If you just want an ampersand, the remedy is",
3361 /* 1111 */ "", //"simple: Just type `I\\&' now. But if some right brace",
3362 /* 1112 */ "", //"up above has ended a previous alignment prematurely,",
3363 /* 1113 */ "", //"you're probably due for more error messages, and you",
3364 /* 1114 */ "", //"might try typing `S' now just to see what is salvageable.",
3365 /* 1115 */ "", //"or \\cr or \\span just now. If something like a right brace",
3366 /* 1116 */ "", //"I expect to see \\noalign only after the \\cr of",
3367 /* 1117 */ "", //"an alignment. Proceed, and I'll ignore this case.",
3368 /* 1118 */ "", //"I expect to see \\omit only after tab marks or the \\cr of",
3369 /* 1119 */ "", // "I'm guessing that you meant to end an alignment here.",
3370 /* 1120 */ "", //"I'm ignoring this, since I wasn't doing a \\csname.",
3371 /* 1121 */ "", //"eqno",
3372 /* 1122 */ "", //"leqno",
3373 /* 1123 */ "", //"displaylimits",
3374 /* 1124 */ "", //"Limit controls must follow a math operator",
3375 /* 1125 */ "", //"I'm ignoring this misplaced \\limits or \\nolimits command.",
3376 /* 1126 */ "", //"Missing delimiter (. inserted)",
3377 /* 1127 */ "", //"I was expecting to see something like `(' or `\\{' or",
3378 /* 1128 */ "", //"`\\}' here. If you typed, e.g., `{' instead of `\\{', you",
3379 /* 1129 */ "", //"should probably delete the `{' by typing `1' now, so that",
3380 /* 1130 */ "", //"braces don't get unbalanced. Otherwise just proceed.",
3381 /* 1131 */ "", //"Acceptable delimiters are characters whose \\delcode is",
3382 /* 1132 */ "", //"nonnegative, or you can use `\\delimiter <delimiter code>'.",
3383 /* 1133 */ "", //"Please use ",
3384 /* 1134 */ "", //" for accents in math mode",
3385 /* 1135 */ "", //"I'm changing \\accent to \\mathaccent here; wish me luck.",
3386 /* 1136 */ "", //"(Accents are not the same in formulas as they are in text.)",
3387 /* 1137 */ "", //"Double superscript",
3388 /* 1138 */ "", //"I treat `x^1^2' essentially like `x^1{}^2'.",
3389 /* 1139 */ "", //"Double subscript",
3390 /* 1140 */ "", //"I treat `x_1_2' essentially like `x_1{}_2'.",
3391 /* 1141 */ "", //"above",
3392 /* 1142 */ "", //"over",
3393 /* 1143 */ "", //"atop",
3394 /* 1144 */ "", //"abovewithdelims",
3395 /* 1145 */ "", //"overwithdelims",
3396 /* 1146 */ "", //"atopwithdelims",
3397 /* 1147 */ "", //"Ambiguous; you need another { and }",
3398 /* 1148 */ "", //"I'm ignoring this fraction specification, since I don't",
3399 /* 1149 */ "", //"know whether a construction like `x \\over y \\over z'",
3400 /* 1150 */ "", //"means `{x \\over y} \\over z' or `x \\over {y \\over z}'.",
3401 /* 1151 */ "", //"I'm ignoring a \\right that had no matching \\left.",
3402 /* 1152 */ "", //"Math formula deleted: Insufficient symbol fonts",
3403 /* 1153 */ "", //"Sorry, but I can't typeset math unless \\textfont 2",
3404 /* 1154 */ "", //"and \\scriptfont 2 and \\scriptscriptfont 2 have all",
3405 /* 1155 */ "", //"the \\fontdimen values needed in math symbol fonts.",
3406 /* 1156 */ "", //"Math formula deleted: Insufficient extension fonts",
3407 /* 1157 */ "", //"Sorry, but I can't typeset math unless \\textfont 3",
3408 /* 1158 */ "", //"and \\scriptfont 3 and \\scriptscriptfont 3 have all",
3409 /* 1159 */ "", //"the \\fontdimen values needed in math extension fonts.",
3410 /* 1160 */ "", //"Display math should end with $$",
3411 /* 1161 */ "", //"The `$' that I just saw supposedly matches a previous `$$'.",
3412 /* 1162 */ "", //"So I shall assume that you typed `$$' both times.",
3413 /* 1163 */ "", //"display",
3414 /* 1164 */ "", //"Missing $$ inserted",
3415 /* 1165 */ "", //"long",
3416 /* 1166 */ "", //"outer",
3417 /* 1167 */ "", //"global",
3418 /* 1168 */ "", //"def",
3419 /* 1169 */ "", //"gdef",
3420 /* 1170 */ "", //"edef",
3421 /* 1171 */ "", //"xdef",
3422 /* 1172 */ "", //"prefix",
3423 /* 1173 */ "", //"You can't use a prefix with `",
3424 /* 1174 */ "", //"I'll pretend you didn't say \\long or \\outer or \\global.",
3425 /* 1175 */ "", //"' or `",
3426 /* 1176 */ "", //"' with `",
3427 /* 1177 */ "", //"I'll pretend you didn't say \\long or \\outer here.",
3428 /* 1178 */ "", //"Missing control sequence inserted",
3429 /* 1179 */ "", //"Please don't say `\\def cs{...}', say `\\def\\cs{...}'.",
3430 /* 1180 */ "", //"I've inserted an inaccessible control sequence so that your",
3431 /* 1181 */ "", //"definition will be completed without mixing me up too badly.",
3432 /* 1182 */ "", //"You can recover graciously from this error, if you're",
3433 /* 1183 */ "", //"careful; see exercise 27.2 in The TeXbook.",
3434 /* 1184 */ "inaccessible",
3435 /* 1185 */ "", //"let",
3436 /* 1186 */ "", //"futurelet",
3437 /* 1187 */ "", //"chardef",
3438 /* 1188 */ "", //"mathchardef",
3439 /* 1189 */ "", //"countdef",
3440 /* 1190 */ "", //"dimendef",
3441 /* 1191 */ "", //"skipdef",
3442 /* 1192 */ "", //"muskipdef",
3443 /* 1193 */ "", //"toksdef",
3444 /* 1194 */ "", //"You should have said `\\read<number> to \\cs'.",
3445 /* 1195 */ "", //"I'm going to look for the \\cs now.",
3446 /* 1196 */ "", //"Invalid code (",
3447 /* 1197 */ "", //"), should be in the range 0..",
3448 /* 1198 */ "", //"), should be at most ",
3449 /* 1199 */ "", //"I'm going to use 0 instead of that illegal code value.",
3450 /* 1200 */ "", //"by",
3451 /* 1201 */ "", //"Arithmetic overflow",
3452 /* 1202 */ "", //"I can't carry out that multiplication or division,",
3453 /* 1203 */ "", //"since the result is out of range.",
3454 /* 1204 */ "", //"I'm forgetting what you said and not changing anything.",
3455 /* 1205 */ "", //"Sorry, \\setbox is not allowed after \\halign in a display,",
3456 /* 1206 */ "", //"or between \\accent and an accented character.",
3457 /* 1207 */ "", //"Bad space factor",
3458 /* 1208 */ "", //"I allow only values in the range 1..32767 here.",
3459 /* 1209 */ "", //"I allow only nonnegative values here.",
3460 /* 1210 */ "", //"Patterns can be loaded only by INITEX",
3461 /* 1211 */ "", //"hyphenchar",
3462 /* 1212 */ "", //"skewchar",
3463 /* 1213 */ "FONT",
3464 /* 1214 */ "", //"at",
3465 /* 1215 */ "", //"scaled",
3466 /* 1216 */ "", //"Improper `at' size (",
3467 /* 1217 */ "", //"pt), replaced by 10pt",
3468 /* 1218 */ "", //"I can only handle fonts at positive sizes that are",
3469 /* 1219 */ "", //"less than 2048pt, so I've changed what you said to 10pt.",
3470 /* 1220 */ "", //"select font ",
3471 /* 1221 */ "", //"errorstopmode",
3472 /* 1222 */ "", //"openin",
3473 /* 1223 */ "", //"closein",
3474 /* 1224 */ "", //"message",
3475 /* 1225 */ "", //"errmessage",
3476 /* 1226 */ "", //"(That was another \\errmessage.)",
3477 /* 1227 */ "", //"This error message was generated by an \\errmessage",
3478 /* 1228 */ "", //"command, so I can't give any explicit help.",
3479 /* 1229 */ "", //"Pretend that you're Hercule Poirot: Examine all clues,",
3480 /* 1230 */ "", //"and deduce the truth by order and method.",
3481 /* 1231 */ "", //"lowercase",
3482 /* 1232 */ "", //"uppercase",
3483 /* 1233 */ "", //"show",
3484 /* 1234 */ "", //"showbox",
3485 /* 1235 */ "", //"showthe",
3486 /* 1236 */ "", //"showlists",
3487 /* 1237 */ "", //"This isn't an error message; I'm just \\showing something.",
3488 /* 1238 */ "", //"Type `I\\show...' to show more (e.g., \\show\\cs,",
3489 /* 1239 */ "", //"\\showthe\\count10, \\showbox255, \\showlists).",
3490 /* 1240 */ "", //"And type `I\\tracingonline=1\\show...' to show boxes and",
3491 /* 1241 */ "", //"lists on your terminal as well as in the transcript file.",
3492 /* 1242 */ "", //"> ",
3493 /* 1243 */ "", //"undefined",
3494 /* 1244 */ "", //"macro",
3495 /* 1245 */ "", //"long macro",
3496 /* 1246 */ "", //"outer macro",
3497 /* 1247 */ "", //"outer endtemplate",
3498 /* 1248 */ "", //"> \\box",
3499 /* 1249 */ "", //"OK",
3500 /* 1250 */ "", //" (see the transcript file)",
3501 /* 1251 */ " (INITEX)",
3502 /* 1252 */ "", //"You can't dump inside a group",
3503 /* 1253 */ "", //"`{...\\dump}' is a no-no.",
3504 /* 1254 */ "", //" strings of total length ",
3505 /* 1255 */ "", //" memory locations dumped; current usage is ",
3506 /* 1256 */ "", //" multiletter control sequences",
3507 /* 1257 */ "", //" words of font info for ",
3508 /* 1258 */ "", //" preloaded font",
3509 /* 1259 */ "", //"\\font",
3510 /* 1260 */ "", //" hyphenation exception",
3511 /* 1261 */ "", //"Hyphenation trie of length ",
3512 /* 1262 */ "", //" has ",
3513 /* 1263 */ "", //" op",
3514 /* 1264 */ "", //" out of ",
3515 /* 1265 */ "", //" for language ",
3516 /* 1266 */ "", //" (format=",
3517 /* 1267 */ "", //"format file name",
3518 /* 1268 */ "", //"Beginning to dump on file ",
3519 /* 1269 */ "", //"Transcript written on ",
3520 /* 1270 */ "", //" )",
3521 /* 1271 */ "", //"end occurred ",
3522 /* 1272 */ "", //"inside a group at level ",
3523 /* 1273 */ "", //"when ",
3524 /* 1274 */ "", //" on line ",
3525 /* 1275 */ "", //" was incomplete)",
3526 /* 1276 */ "", //"(see the transcript file for additional information)",
3527 /* 1277 */ "", //"(\\dump is performed only by INITEX)",
3528 /* 1278 */ "", //"debug # (-1 to exit):",
3529 /* 1279 */ "", //"openout",
3530 /* 1280 */ "", //"closeout",
3531 /* 1281 */ "", //"special",
3532 /* 1282 */ "", //"immediate",
3533 /* 1283 */ "", //"setlanguage",
3534 /* 1284 */ "", //"[unknown extension!]",
3535 /* 1285 */ "", //"ext1",
3536 /* 1286 */ "", //" (hyphenmin ",
3537 /* 1287 */ "", //"whatsit" "?",
3538 /* 1288 */ "", //"ext2",
3539 /* 1289 */ "", //"ext3",
3540 /* 1290 */ "endwrite",
3541 /* 1291 */ "", //"Unbalanced write command",
3542 /* 1292 */ "", //"On this page there's a \\write with fewer real {'s than }'s.",
3543 /* 1293 */ "", //"ext4",
3544 /* 1294 */ "", //"output file name",
3545 };
3546 
3548 {
3549  str_number g;
3550  size_t k, l, i = 0;
3551 
3552  for (k = 0; k < sizeof(pool_file_arr) / sizeof(char *); k++)
3553  {
3554  l = strlen(pool_file_arr[k]);
3555  i += l;
3556 
3557  if (i >= spare_size)
3558  return 0;
3559 
3561  pool_ptr += l;
3562  g = make_string();
3563  }
3564 
3565  return g;
3566 }
3567 
3568 static str_number make_str_string (const char * s)
3569 {
3570  size_t slen = strlen(s);
3571 
3572  if (slen == 1)
3573  {
3574  return ((str_number) s[0]);
3575  }
3576  else
3577  {
3578  memcpy(str_pool + pool_ptr, s, slen);
3579  pool_ptr += slen;
3580  return (make_string());
3581  }
3582 }
3583 
3585 {
3586  if (aptex_env.aptex_job != NULL)
3587  return make_str_string(aptex_env.aptex_job);
3588  else
3589  return job;
3590 }
3591 
3593 {
3594  char * a = (char *) malloc(length(s) + 1);
3595  strncpy(a, (const char *)(str_pool + str_start[s]), length(s));
3596  a[length(s)] = '\0';
3597 
3598  return a;
3599 }
3600 
3601 static const integer BEGINFMTCHECKSUM = 367403084;
3602 static const integer ENDFMTCHECKSUM = 69069;
3603 
3604 static void reset_trie(void);
3605 static boolean get_strings_started(void);
3606 static void init_prim(void);
3607 static void store_fmt_file(void);
3608 static boolean str_eq_str(str_number s, str_number t);
3610 static void primitive_(str_number s, quarterword c, halfword o);
3611 static void fix_date_and_time(void);
3612 
3613 static int aptex_dump_put (void * out_file, void * p, int item_size)
3614 {
3615  boolean fmt_stat; int nitems = 1;
3616 
3617  if (aptex_env.flag_compact_fmt)
3618  fmt_stat = (gzwrite(out_file, p, (item_size * nitems)) != (item_size * nitems));
3619  else
3620  fmt_stat = (fwrite(p, item_size, nitems, out_file) != nitems);
3621 
3622  if (fmt_stat)
3623  {
3624  printf("\n! ApTeX: Could not write %d %d-byte item%s.\n", nitems, item_size, (nitems > 1) ? "s" : "");
3626  }
3627 
3628  return 0;
3629 }
3630 
3631 static int aptex_dump_get (void * in_file, void * p, int item_size)
3632 {
3633  boolean fmt_stat; int nitems = 1;
3634 
3635  if (aptex_env.flag_compact_fmt)
3636  fmt_stat = (gzread(in_file, p, (item_size * nitems)) <= 0);
3637  else
3638  fmt_stat = (fread(p, item_size, nitems, in_file) != nitems);
3639 
3640  if (fmt_stat)
3641  {
3642  printf("\n! ApTeX: Could not read %d %d-byte item%s.\n", nitems, item_size, (nitems > 1) ? "s" : "");
3644  }
3645 
3646  return 0;
3647 }
3648 
3649 static inline void dump_int (integer x)
3650 {
3651  generic_dump(x);
3652 }
3653 
3654 static inline void dump_hh (two_halves x)
3655 {
3656  generic_dump(x);
3657 }
3658 
3659 static inline void dump_wd (memory_word x)
3660 {
3661  generic_dump(x);
3662 }
3663 
3664 /* split out to allow optimize for space, not time */
3665 static void do_initex (void)
3666 {
3667  integer i;
3668  integer k;
3669 
3670  for (k = mem_bot + 1; k <= lo_mem_stat_max; k++)
3671  mem[k].cint = 0;
3672 
3673  k = mem_bot;
3674 
3675  while (k <= lo_mem_stat_max)
3676  {
3677  glue_ref_count(k) = 1;
3678  stretch_order(k) = normal;
3679  shrink_order(k) = normal;
3680  k = k + glue_spec_size;
3681  }
3682 
3683  stretch(fil_glue) = unity;
3685  stretch(fill_glue) = unity;
3687  stretch(ss_glue) = unity;
3689  shrink(ss_glue) = unity;
3693  rover = lo_mem_stat_max + 1;
3694  link(rover) = empty_flag;
3696  llink(rover) = rover;
3697  rlink(rover) = rover;
3699  link(lo_mem_max) = 0;
3700  info(lo_mem_max) = 0;
3701 
3702  for (k = hi_mem_stat_min; k <= mem_top; k++)
3703  mem[k] = mem[lo_mem_max];
3704 
3706  link(end_span) = max_quarterword + 1;
3707  info(end_span) = 0;
3710  subtype(last_active) = 0;
3711  subtype(page_ins_head) = 255;
3716  avail = 0;
3717  mem_end = mem_top;
3724 
3725  for (k = active_base; k <= undefined_control_sequence - 1; k++)
3727 
3731 
3732  for (k = glue_base + 1; k <= local_base - 1; k++)
3733  eqtb[k] = eqtb[glue_base];
3734 
3736 
3737  par_shape_ptr = 0;
3740 
3741  for (k = etex_pen_base; k <= etex_pens - 1; k++)
3742  eqtb[k] = eqtb[par_shape_loc];
3743 
3744  for (k = output_routine_loc; k <= toks_base + 255; k++)
3746 
3747  box(0) = 0;
3750 
3751  for (k = box_base + 1; k <= box_base + 255; k++)
3752  eqtb[k] = eqtb[box_base];
3753 
3754  cur_font = null_font;
3757  cur_jfont = null_font;
3760  cur_tfont = null_font;
3763 
3764  for (k = math_font_base; k <= math_font_base + 47; k++)
3765  eqtb[k] = eqtb[cur_font_loc];
3766 
3767  equiv(cat_code_base) = 0;
3770 
3771  for (k = cat_code_base; k <= int_base - 1; k++)
3772  eqtb[k] = eqtb[cat_code_base];
3773 
3777 
3778  for (k = 0; k <= 255; k++)
3779  {
3780  cat_code(k) = other_char;
3781  kcat_code(k) = other_kchar;
3782  math_code(k) = k;
3783  sf_code(k) = 1000;
3784  auto_xsp_code(k) = 0;
3785  inhibit_xsp_code(k) = 0;
3786  inhibit_xsp_type(k) = 0;
3787  kinsoku_code(k) = 0;
3788  kinsoku_type(k) = 0;
3789  }
3790 
3791  for (k = 0; k <= 511; k++)
3792  kcat_code(k) = other_kchar;
3793 
3795  cat_code(' ') = spacer;
3796  cat_code('\\') = escape;
3797  cat_code('%') = comment;
3800 
3801  for (k = '0'; k <= '9'; k++)
3802  {
3803  math_code(k) = k + var_code;
3804  auto_xsp_code(k) = 3;
3805  }
3806 
3807  kansuji_char(0) = toDVI(fromJIS(0x213B));
3808  kansuji_char(1) = toDVI(fromJIS(0x306C));
3809  kansuji_char(2) = toDVI(fromJIS(0x4673));
3810  kansuji_char(3) = toDVI(fromJIS(0x3B30));
3811  kansuji_char(4) = toDVI(fromJIS(0x3B4D));
3812  kansuji_char(5) = toDVI(fromJIS(0x385E));
3813  kansuji_char(6) = toDVI(fromJIS(0x4F3B));
3814  kansuji_char(7) = toDVI(fromJIS(0x3C37));
3815  kansuji_char(8) = toDVI(fromJIS(0x482C));
3816  kansuji_char(9) = toDVI(fromJIS(0x3665));
3817 
3818  for (k = 'A'; k <= 'Z'; k++)
3819  {
3820  cat_code(k) = letter;
3821  cat_code(k + 'a' - 'A') = letter;
3822  math_code(k) = k + var_code + 0x100;
3823  math_code(k + 'a' - 'A') = k + 'a' - 'A' + var_code + 0x100;
3824  lc_code(k) = k + 'a' - 'A';
3825  lc_code(k + 'a' - 'A') = k + 'a' - 'A';
3826  uc_code(k) = k;
3827  uc_code(k + 'a' - 'A') = k;
3828  auto_xsp_code(k) = 3;
3829  auto_xsp_code(k + 'a' - 'A') = 3;
3830  sf_code(k) = 999;
3831  }
3832 
3833  if (is_internalUPTEX())
3834  {
3835  kcat_code(0x0) = not_cjk; // { default: other_kchar }
3836 
3837  for (k = 0x2; k <= 0x3; k++)
3838  kcat_code(k) = not_cjk; // { Latin Extended-A, Latin Extended-B }
3839 
3840  kcat_code(0x24) = hangul; // { Hangul Jamo }
3841  kcat_code(0x45) = not_cjk; // { Latin Extended Additional }
3842 
3843  // { CJK Radicals Supplement .. Ideographic Description Characters }
3844  for (k = 0x67; k <= 0x69; k++)
3845  kcat_code(k) = kanji;
3846 
3847  // { Hiragana, Katakana }
3848  for (k = 0x6B; k <= 0x6C; k++)
3849  kcat_code(k) = kana;
3850 
3851  kcat_code(0x6D) = kanji; // { Bopomofo }
3852  kcat_code(0x6E) = hangul; // { Hangul Compatibility Jamo }
3853 
3854  // { Kanbun .. CJK Strokes }
3855  for (k = 0x6F; k <= 0x71; k++)
3856  kcat_code(k) = kanji;
3857 
3858  kcat_code(0x72) = kana; // { Katakana Phonetic Extensions }
3859  kcat_code(0x75) = kanji; // { CJK Unified Ideographs Extension A }
3860  kcat_code(0x77) = kanji; // { CJK Unified Ideographs }
3861  kcat_code(0x87) = hangul; // { Hangul Jamo Extended-A }
3862  kcat_code(0x92) = hangul; // { Hangul Syllables }
3863  kcat_code(0x93) = hangul; // { Hangul Jamo Extended-B }
3864  kcat_code(0x98) = kanji; // { CJK Compatibility Ideographs }
3865  // { kcat_code(0xA1) = other_kchar; Halfwidth and Fullwidth Forms }
3866 
3867  // { Kana Supplement .. Small Kana Extension }
3868  for (k = 0x103; k <= 0x105; k++)
3869  kcat_code(0xF1) = kana;
3870 
3871  // { CJK Unified Ideographs Extension B .. CJK Compatibility Ideographs Supplement }
3872  for (k = 0x129; k <= 0x12F; k++)
3873  kcat_code(k) = kanji;
3874 
3875  kcat_code(0x1FD) = not_cjk; // { Latin-1 Letters }
3876  kcat_code(0x1FE) = kana; // { Fullwidth digit and latin alphabet }
3877  kcat_code(0x1FF) = kana; // { Halfwidth katakana }
3878  }
3879  else
3880  {
3881  kcat_code(0x20 + 1) = other_kchar; // {1 ku}
3882  kcat_code(0x20 + 2) = other_kchar; // {2 ku}
3883 
3884  for (k = 3; k <= 6; k++)
3885  kcat_code(0x20 + k) = kana; // {3 ku ... 6 ku}
3886 
3887  for (k = 7; k <= 13; k++)
3888  kcat_code(0x20 + k) = other_kchar; // {7 ku ... 13 ku}
3889 
3890  for (k = 14; k <= 120; k++)
3891  kcat_code(0x20 + k) = kanji; // {14 ku ... 120 ku}
3892  //{ $\.{@0x20}+|k| = |kcatcodekey|(|fromKUTEN|(|HILO|(k,1))$ }
3893  for (k = 16; k <= 94; k++)
3894  kcat_code(0xA0 + k) = kanji; // {2 men 16 ku ... 94 ku}
3895  };
3896 
3897  for (k = int_base; k <= del_code_base - 1; k++)
3898  eqtb[k].cint = 0;
3899 
3900  mag = 1000;
3901  tolerance = 10000;
3902  hang_after = 1;
3903  max_dead_cycles = 25;
3904  escape_char = '\\';
3906  pdf_compress_level = 9;
3907  pdf_major_version = 1;
3908  pdf_minor_version = 5;
3909 
3910  for (k = 0; k <= 255; k++)
3911  del_code(k) = -1;
3912 
3913  del_code('.') = 0;
3914 
3915  for (k = dimen_base; k <= eqtb_size; k++)
3916  eqtb[k].cint = 0;
3917 
3919  cs_count = 0;
3920 
3921  if (aptex_env.trace_mem)
3922  puts("initex cs_count = 0 ");
3923 
3925  prim_used = prim_size; // {nothing is used}
3926  text(frozen_dont_expand) = 499; /* "notexpanded:" */
3928  equiv(frozen_primitive) = 1;
3930  text(frozen_primitive) = make_str_string("pdfprimitive");
3931 
3932  font_ptr = null_font;
3933  fmem_ptr = 7;
3935  font_num_ext[null_font] = 0;
3936  font_name[null_font] = 795; /* nullfont */
3937  font_area[null_font] = 335; /* "" */
3938  hyphen_char[null_font] = '-';
3939  skew_char[null_font] = -1;
3943  font_bc[null_font] = 1;
3944  font_ec[null_font] = 0;
3945  font_size[null_font] = 0;
3946  font_dsize[null_font] = 0;
3947  ctype_base[null_font] = 0;
3948  char_base[null_font] = 0;
3949  width_base[null_font] = 0;
3950  height_base[null_font] = 0;
3951  depth_base[null_font] = 0;
3952  italic_base[null_font] = 0;
3953  lig_kern_base[null_font] = 0;
3954  kern_base[null_font] = 0;
3955  exten_base[null_font] = 0;
3956  font_glue[null_font] = 0;
3957  font_params[null_font] = 7;
3958  param_base[null_font] = -1;
3959 
3960  for (k = 0; k <= 6; k++)
3961  font_info[k].cint = 0;
3962 
3966 
3967  reset_trie();
3968  text(frozen_protection) = 1184; /* "inaccessible" */
3969  format_ident = 1251; /* " (INITEX)" */
3970  text(end_write) = 1290; /* "endwrite" */
3973  equiv(end_write) = 0;
3974  eTeX_mode = false;
3975  max_reg_num = 255;
3976  max_reg_help_line = "A register number must be between 0 and 255.";
3977 
3978  for (i = int_val; i <= tok_val; ++i)
3979  sa_root[i] = null;
3980 
3981  hyph_root = 0;
3982  hyph_start = 0;
3983 }
3984 
3985 /* sec 0004 */
3986 static void initialize (void)
3987 {
3988  integer i;
3989  integer k;
3990 
3991 #ifndef APTEX_EXTENSION
3992  hyph_pointer z;
3993 #endif
3994 
3995  for (i = 0; i <= 255; i++)
3996  xchr[i] = (char) i;
3997 
3998 #ifdef JOKE
3999  xchr[32] = ' '; xchr[33] = '!'; xchr[34] = '"'; xchr[35] = '#';
4000  xchr[36] = '$'; xchr[37] = '%'; xchr[38] = '&'; xchr[39] = '\'';
4001  xchr[40] = '('; xchr[41] = ')'; xchr[42] = '*'; xchr[43] = '+';
4002  xchr[44] = ','; xchr[45] = '-'; xchr[46] = '.'; xchr[47] = '/';
4003  xchr[48] = '0'; xchr[49] = '1'; xchr[50] = '2'; xchr[51] = '3';
4004  xchr[52] = '4'; xchr[53] = '5'; xchr[54] = '6'; xchr[55] = '7';
4005  xchr[56] = '8'; xchr[57] = '9'; xchr[58] = ':'; xchr[59] = ';';
4006  xchr[60] = '<'; xchr[61] = '='; xchr[62] = '>'; xchr[63] = '?';
4007  xchr[64] = '@'; xchr[65] = 'A'; xchr[66] = 'B'; xchr[67] = 'C';
4008  xchr[68] = 'D'; xchr[69] = 'E'; xchr[70] = 'F'; xchr[71] = 'G';
4009  xchr[72] = 'H'; xchr[73] = 'I'; xchr[74] = 'J'; xchr[75] = 'K';
4010  xchr[76] = 'L'; xchr[77] = 'M'; xchr[78] = 'N'; xchr[79] = 'O';
4011  xchr[80] = 'P'; xchr[81] = 'Q'; xchr[82] = 'R'; xchr[83] = 'S';
4012  xchr[84] = 'T'; xchr[85] = 'U'; xchr[86] = 'V'; xchr[87] = 'W';
4013  xchr[88] = 'X'; xchr[89] = 'Y'; xchr[90] = 'Z'; xchr[91] = '[';
4014  xchr[92] = '\\'; xchr[93] = ']'; xchr[94] = '^'; xchr[95] = '_';
4015  xchr[96] = '`'; xchr[97] = 'a'; xchr[98] = 'b'; xchr[99] = 'c';
4016  xchr[100] = 'd'; xchr[101] = 'e'; xchr[102] = 'f'; xchr[103] = 'g';
4017  xchr[104] = 'h'; xchr[105] = 'i'; xchr[106] = 'j'; xchr[107] = 'k';
4018  xchr[108] = 'l'; xchr[109] = 'm'; xchr[110] = 'n'; xchr[111] = 'o';
4019  xchr[112] = 'p'; xchr[113] = 'q'; xchr[114] = 'r'; xchr[115] = 's';
4020  xchr[116] = 't'; xchr[117] = 'u'; xchr[118] = 'v'; xchr[119] = 'w';
4021  xchr[120] = 'x'; xchr[121] = 'y'; xchr[122] = 'z'; xchr[123] = '{';
4022  xchr[124] = '|'; xchr[125] = '}'; xchr[126] = '~';
4023 
4024  for (i = 0; i <= 31; i++)
4025  xchr[i] = chr(i);
4026 
4027  for (i = 127; i <= 255; i++)
4028  xchr[i]= chr(i);
4029 #endif
4030 
4031  for (i = 0; i <= 255; i++)
4032  xord[chr(i)] = invalid_code;
4033 
4034 #ifdef JOKE
4035  for (i = 128; i <= 255; i++)
4036  xord[xchr[i]] = i;
4037 
4038  for (i = 0; i <= 126; i++)
4039  xord[xchr[i]] = i;
4040 #endif
4041 
4042  for (i = 0; i <= 255; i++)
4043  xord[xchr[i]] = (char) i;
4044 
4045  xord[127] = 127;
4046 
4047  if (interaction < batch_mode)
4049 
4050  deletions_allowed = true;
4051  set_box_allowed = true;
4052  error_count = 0;
4053  help_ptr = 0;
4054  use_err_help = false;
4055  interrupt = 0;
4056  OK_to_interrupt = true;
4057 
4058  /* Random numbers. */
4059  two_to_the[0] = 1;
4060 
4061  for (k = 1; k <= 30; k++)
4062  two_to_the[k] = 2 * two_to_the[k - 1];
4063 
4064  spec_log[1] = 93032640;
4065  spec_log[2] = 38612034;
4066  spec_log[3] = 17922280;
4067  spec_log[4] = 8662214;
4068  spec_log[5] = 4261238;
4069  spec_log[6] = 2113709;
4070  spec_log[7] = 1052693;
4071  spec_log[8] = 525315;
4072  spec_log[9] = 262400;
4073  spec_log[10] = 131136;
4074  spec_log[11] = 65552;
4075  spec_log[12] = 32772;
4076  spec_log[13] = 16385;
4077 
4078  for (k = 14; k <= 27; k++)
4079  spec_log[k] = two_to_the[27 - k];
4080 
4081  spec_log[28] = 1;
4082 
4083 #ifdef APTEX_DEBUG
4084  was_mem_end = mem_min;
4085  was_lo_max = mem_bot; // mem_min
4086  was_hi_min = mem_top; // mem_max
4087  panicking = false;
4088 #endif
4089 
4090  nest_ptr = 0;
4091  max_nest_stack = 0;
4092  mode = vmode;
4093  head = contrib_head;
4094  tail = contrib_head;
4095  eTeX_aux = 0;
4096  prev_node = tail;
4097  direction = dir_yoko;
4099  prev_disp = 0;
4100  last_jchr = null;
4101  disp_called = false;
4103  mode_line = 0;
4104  prev_graf = 0;
4105  shown_mode = 0;
4106  page_contents = empty;
4107  page_tail = page_head;
4108 
4109 #ifdef APTEX_EXTENSION
4110  if (aptex_env.flag_initex)
4111 #endif
4112  link(page_head) = null;
4113 
4115  last_penalty = 0;
4116  last_kern = 0;
4117  last_node_type = -1;
4118  last_node_subtype = -1;
4119  page_depth = 0;
4120  page_max_depth = 0;
4121 
4122  for (k = int_base; k <= eqtb_size; k++)
4123  xeq_level[k] = level_one;
4124 
4125  no_new_control_sequence = true;
4126  prim_next(0) = 0;
4127  prim_text(0) = 0;
4128 
4129  for (k = 1; k <= prim_size; k++)
4130  prim[k] = prim[0];
4131 
4132  next(hash_base) = 0;
4133  text(hash_base) = 0;
4134 
4135  for (k = hash_base + 1; k <= undefined_control_sequence - 1; k++)
4136  hash[k] = hash[hash_base];
4137 
4138  save_ptr = 0;
4139  cur_level = level_one;
4141  cur_boundary = 0;
4142  max_save_stack = 0;
4143  mag_set = 0;
4144  skip_mode = true;
4145  top_mark = 0;
4146  first_mark = 0;
4147  bot_mark = 0;
4148  split_first_mark = 0;
4149  split_bot_mark = 0;
4150  cur_val = 0;
4152  radix = 0;
4153  cur_order = normal;
4154 
4155  for (k = 0; k <= 16; k++)
4156  read_open[k] = closed;
4157 
4158  cond_ptr = 0;
4159  if_limit = normal;
4160  cur_if = 0;
4161  if_line = 0;
4162 
4163  for (k = font_base; k <= font_max; k++)
4164  font_used[k] = false;
4165 
4170  total_pages = 0;
4171  max_v = 0;
4172  max_h = 0;
4173  max_push = 0;
4174  last_bop = -1;
4175  doing_leaders = false;
4176  dead_cycles = 0;
4177  cur_s = -1;
4178  dir_used = false;
4179  half_buf = dvi_buf_size / 2;
4181  dvi_ptr = 0;
4182  dvi_offset = 0;
4183  dvi_gone = 0;
4184  down_ptr = 0;
4185  right_ptr = 0;
4186  adjust_tail = 0;
4187  last_badness = 0;
4190  pack_begin_line = 0;
4191  empty_field.rh = 0;
4192  empty_field.lh = 0;
4193  null_delimiter.b0 = 0;
4194  null_delimiter.b1 = 0;
4195  null_delimiter.b2 = 0;
4196  null_delimiter.b3 = 0;
4197  align_ptr = 0;
4198  cur_align = 0;
4199  cur_span = 0;
4200  cur_loop = 0;
4201  cur_head = 0;
4202  cur_tail = 0;
4203 
4204 /* *not* OK with APTEX_EXTENSION, since may not be allocated yet */
4205 #ifndef APTEX_EXTENSION
4206  for (z = 0; z <= hyphen_prime; z++)
4207  {
4208  hyph_word[z] = 0;
4209  hyph_list[z] = 0;
4210  }
4211 #endif
4212 
4213  hyph_count = 0;
4214  output_active = false;
4215  insert_penalties = 0;
4216  ligature_present = false;
4217  cancel_boundary = false;
4218  lft_hit = false;
4219  rt_hit = false;
4220  ins_disc = false;
4221  after_token = 0;
4222  long_help_seen = false;
4223  format_ident = 0;
4224 
4225  for (k = 0; k <= 17; k++)
4226  write_open[k] = false;
4227 
4228  LR_ptr = null;
4229  LR_problems = 0;
4231  pseudo_files = null;
4232  sa_mark = null;
4233  sa_null.hh.lh = null;
4234  sa_null.hh.rh = null;
4235  sa_chain = null;
4236  sa_level = level_zero;
4237  page_disc = null;
4238  split_disc = null;
4239  page_dir = dir_yoko;
4240 
4243 
4244  if (aptex_env.flag_initex)
4245  do_initex();
4246 }
4247 
4248 /* sec 1303 */
4249 static boolean load_fmt_file (void)
4250 {
4251  integer j, k;
4252  pointer p, q;
4253  integer x;
4254 
4255  // Undump constants for consistency check
4256  undump_int(x);
4257 
4258  if (x != BEGINFMTCHECKSUM)
4259  goto bad_fmt;
4260 
4261  undump(0, 1, eTeX_mode);
4262 
4263  if (eTeX_ex)
4264  {
4265  max_reg_num = 32767;
4266  max_reg_help_line = "A register number must be between 0 and 32767.";
4267  }
4268  else
4269  {
4270  max_reg_num = 255;
4271  max_reg_help_line = "A register number must be between 0 and 255.";
4272  }
4273 
4274  undump_int(x); /* mem_bot */
4275 
4276  if (x != mem_bot)
4277  goto bad_fmt;
4278 
4279  undump_int(x); /* mem_top */
4280 
4281 #ifdef APTEX_EXTENSION
4282  mem = allocate_mem(x);
4283 
4284  if (mem == NULL)
4285  exit(EXIT_FAILURE);
4286 
4287  /* do `mem' part of initialize */
4288  {
4289 #ifdef APTEX_DEBUG
4290  was_mem_end = mem_min;
4291  was_lo_max = mem_bot; // mem_min
4292  was_hi_min = mem_top; // mem_max
4293  panicking = false;
4294 #endif
4295 
4296  /* nest_ptr = 0; */
4297  /* max_nest_stack = 0; */
4298  mode = vmode;
4299  head = contrib_head;
4300  tail = contrib_head;
4301  eTeX_aux = 0;
4302  prev_node = tail;
4303  direction = dir_yoko;
4305  prev_disp = 0;
4306  last_jchr = null;
4307  disp_called = false;
4309  mode_line = 0;
4310  prev_graf = 0;
4311  /* shown_mode = 0; */
4312  /* page_contents = 0; */
4313  page_tail = page_head;
4314  link(page_head) = 0;
4315  }
4316 #endif
4317 
4318  if (x != mem_top)
4319  goto bad_fmt;
4320 
4321  undump_int(x); /* eqtb_size */
4322 
4323  if (x != eqtb_size)
4324  goto bad_fmt;
4325 
4326  undump_int(x); /* hash_prime */
4327 
4328  if (x != hash_prime)
4329  goto bad_fmt;
4330 
4331  undump_int(x); /* hyphen_prime */
4332 
4333 #ifdef APTEX_EXTENSION
4334 /* allow format files dumped with arbitrary (prime) hyphenation exceptions */
4335  realloc_hyphen(x);
4336  hyphen_prime = x;
4337 #endif
4338 
4339  if (x != hyphen_prime)
4340  goto bad_fmt;
4341 
4342  // Undump the string pool
4343  {
4344  undump_int(x); /* pool_size */
4345 
4346  if (x < 0)
4347  goto bad_fmt;
4348 
4349 #ifdef APTEX_EXTENSION
4350  if (x > current_pool_size)
4352 
4353  if (x > current_pool_size)
4354 #else
4355  if (x > pool_size)
4356 #endif
4357  {
4358  printf("%s%s\n", "---! Must increase the ", "string pool size");
4359  goto bad_fmt;
4360  }
4361  else
4362  pool_ptr = x;
4363  }
4364 
4365  {
4366  undump_int(x); /* max_strings */
4367 
4368  if (x < 0)
4369  goto bad_fmt;
4370 
4371 #ifdef APTEX_EXTENSION
4372  if (x > current_max_strings)
4374 
4375  if (x > current_max_strings)
4376 #else
4377  if (x > max_strings)
4378 #endif
4379  {
4380  printf("%s%s\n", "---! Must increase the ", "max strings");
4381  goto bad_fmt;
4382  }
4383  else
4384  str_ptr = x;
4385  }
4386 
4387  undump_things(str_start[0], str_ptr + 1);
4391  // Undump the dynamic memory
4394 
4395  if (eTeX_ex)
4396  {
4397  for (k = int_val; k <= tok_val; ++k)
4398  undump(0, lo_mem_max, sa_root[k]);
4399  }
4400 
4401  p = mem_bot;
4402  q = rover;
4403 
4404  do {
4405  if (undump_things(mem[p], q + 2 - p))
4406  return -1;
4407 
4408  p = q + node_size(q);
4409 
4410  if ((p > lo_mem_max) || ((q >= rlink(q)) && (rlink(q) != rover)))
4411  goto bad_fmt;
4412 
4413  q = rlink(q);
4414  } while (!(q == rover));
4415 
4416  if (undump_things(mem[p], lo_mem_max + 1 - p))
4417  return -1;
4418 
4419  if (mem_min < mem_bot - 2)
4420  {
4421 /* or call add_variable_space(mem_bot - (mem_min + 1)) */
4422  p = llink(rover);
4423  q = mem_min + 1;
4424  link(mem_min) = 0; /* null */
4425  info(mem_min) = 0; /* null */
4426  rlink(p) = q;
4427  llink(rover) = q;
4428  rlink(q) = rover;
4429  llink(q) = p;
4430  link(q) = empty_flag;
4431  node_size(q) = mem_bot - q;
4432  }
4433 
4436  mem_end = mem_top;
4437 
4439  return -1;
4440 
4443 
4444  // Undump the table of equivalents
4445  // Undump regions 1 to 6 of eqtb
4446  k = active_base;
4447 
4448  do {
4449  undump_int(x);
4450 
4451  if ((x < 1) || (k + x > eqtb_size + 1))
4452  goto bad_fmt;
4453 
4454  if (undump_things(eqtb[k], x))
4455  return -1;
4456 
4457  k = k + x;
4458  undump_int(x);
4459 
4460  if ((x < 0) || (k + x > eqtb_size + 1))
4461  goto bad_fmt;
4462 
4463  for (j = k; j <= k + x - 1; j++)
4464  eqtb[j] = eqtb[k - 1];
4465 
4466  k = k + x;
4467  } while (!(k > eqtb_size));
4468 
4473 
4474  // Undump the hash table
4475  p = hash_base - 1;
4476 
4477  do {
4478  undump(p + 1, hash_used, p);
4479  undump_hh(hash[p]);
4480  } while (!(p == hash_used));
4481 
4483  return -1;
4484 
4486 
4487  for (p = 0; p <= prim_size; p++)
4488  undump_hh(prim[p]);
4489 
4490  // Undump the font information
4491  {
4492  undump_int(x); /* font_mem_size */
4493 
4494  if (x < 7)
4495  goto bad_fmt;
4496 
4497 #ifdef APTEX_EXTENSION
4498  if (x > current_font_mem_size)
4500 
4501  if (x > current_font_mem_size)
4502 #else
4503  if (x > font_mem_size)
4504 #endif
4505  {
4506  puts("---! Must increase the font mem size");
4507  goto bad_fmt;
4508  }
4509  else
4510  fmem_ptr = x;
4511  }
4512 
4514  undump_size(font_base, font_max, "font max", font_ptr);
4515 
4516  {
4543  }
4544 
4545 #ifdef APTEX_EXTENSION
4546  {
4547  integer count = 0, oldfont_mem_size = 0;
4548 
4549  for (x = 0; x <= font_ptr; x++)
4550  {
4551  if (bchar_label[x] > oldfont_mem_size)
4552  oldfont_mem_size = bchar_label[x];
4553  }
4554 
4555  if ((oldfont_mem_size != non_address) && (oldfont_mem_size > font_max))
4556  {
4557  for (x = 0; x <= font_ptr; x++)
4558  {
4559  if (bchar_label[x] == oldfont_mem_size)
4560  {
4562  count++;
4563  }
4564  }
4565 
4566  if (aptex_env.trace_mem)
4567  printf("oldfont_mem_size is %"PRId64" --- hit %"