1 /* Copyright 1992 Karl Berry
2 Copyright 2007 TeX Users Group
3 Copyright 2014 Clerk Ma
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.
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.
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
25 #pragma warning(disable:4115) // kill rpcasync.h complaint
27 #define MYLIBAPI __declspec(dllexport)
32 #pragma warning(disable:4996)
33 #pragma warning(disable:4131) // old style declarator
34 #pragma warning(disable:4135) // conversion between different integral types
35 #pragma warning(disable:4127) // conditional expression is constant
43 #pragma warning(disable:4244) /* 96/Jan/10 */
47 #define BEGINFMTCHECKSUM 367403084L
48 #define ENDFMTCHECKSUM 69069L
50 extern clock_t start_time, main_time, finish_time; /* in local.c */
52 /* imported from pascal.h */
53 /* localized here to avoid conflict with io.h in other code */
55 #define read(f, b) ((b) = getc (f))
56 #define readln(f) { register int c; while ((c = getc (f)) != '\n' && c != EOF); }
59 void do_initex (void); /* later in this file */
62 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
64 void initialize (void)
68 integer flag; /* bkph */
70 #ifndef ALLOCATEHYPHEN
74 /* We already initialized xchr if we are using non_ascii setup */
75 /* Normally, there is no translation of character code numbers */
78 for (i = 0; i <= 255; i++)
80 /* This is a kind of joke, since the characters are given as numeric codes ! */
82 xchr[32] = ' '; xchr[33] = '!'; xchr[34] = '"'; xchr[35] = '#';
83 xchr[36] = '$'; xchr[37] = '%'; xchr[38] = '&'; xchr[39] = '\'';
84 xchr[40] = '('; xchr[41] = ')'; xchr[42] = '*'; xchr[43] = '+';
85 xchr[44] = ','; xchr[45] = '-'; xchr[46] = '.'; xchr[47] = '/';
86 xchr[48] = '0'; xchr[49] = '1'; xchr[50] = '2'; xchr[51] = '3';
87 xchr[52] = '4'; xchr[53] = '5'; xchr[54] = '6'; xchr[55] = '7';
88 xchr[56] = '8'; xchr[57] = '9'; xchr[58] = ':'; xchr[59] = ';';
89 xchr[60] = '<'; xchr[61] = '='; xchr[62] = '>'; xchr[63] = '?';
90 xchr[64] = '@'; xchr[65] = 'A'; xchr[66] = 'B'; xchr[67] = 'C';
91 xchr[68] = 'D'; xchr[69] = 'E'; xchr[70] = 'F'; xchr[71] = 'G';
92 xchr[72] = 'H'; xchr[73] = 'I'; xchr[74] = 'J'; xchr[75] = 'K';
93 xchr[76] = 'L'; xchr[77] = 'M'; xchr[78] = 'N'; xchr[79] = 'O';
94 xchr[80] = 'P'; xchr[81] = 'Q'; xchr[82] = 'R'; xchr[83] = 'S';
95 xchr[84] = 'T'; xchr[85] = 'U'; xchr[86] = 'V'; xchr[87] = 'W';
96 xchr[88] = 'X'; xchr[89] = 'Y'; xchr[90] = 'Z'; xchr[91] = '[';
97 xchr[92] = '\\'; xchr[93] = ']'; xchr[94] = '^'; xchr[95] = '_';
98 xchr[96] = '`'; xchr[97] = 'a'; xchr[98] = 'b'; xchr[99] = 'c';
99 xchr[100] = 'd'; xchr[101] = 'e'; xchr[102] = 'f'; xchr[103] = 'g';
100 xchr[104] = 'h'; xchr[105] = 'i'; xchr[106] = 'j'; xchr[107] = 'k';
101 xchr[108] = 'l'; xchr[109] = 'm'; xchr[110] = 'n'; xchr[111] = 'o';
102 xchr[112] = 'p'; xchr[113] = 'q'; xchr[114] = 'r'; xchr[115] = 's';
103 xchr[116] = 't'; xchr[117] = 'u'; xchr[118] = 'v'; xchr[119] = 'w';
104 xchr[120] = 'x'; xchr[121] = 'y'; xchr[122] = 'z'; xchr[123] = '{';
105 xchr[124] = '|'; xchr[125] = '}'; xchr[126] = '~';
107 for (i = 0; i <= 31; i++)
110 for (i = 127; i <= 255; i++)
112 #endif /* end of JOKE */
114 /* end of plain ASCII case (otherwise have read in xchr vector before) */
115 /* Fill in background of `delete' for inverse mapping */
116 for (i = 0; i <= 255; i++)
120 for (i = 128; i <= 255 ; i++)
123 for (i = 0; i <= 126; i++)
127 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
128 /* Now invert the xchr mapping to get xord mapping */
129 for (i = 0; i <= 255; i++)
130 xord[xchr[i]] = (char) i;
132 xord[127] = 127; /* hmm, a fixed point ? why ? */
134 flag = 0; /* 93/Dec/28 - bkph */
138 /* entries in xord / xchr */
139 for (k = 0; k < 256; k++)
145 /* 127 here means mapping undefined */
148 show_line("Inverted mapping xord[] pairs:\n", 0);
150 for (k = 0; k < 256; k++)
152 /* entries in xord / xchr */
155 sprintf(log_line, "%d => %d\n", k, xord[k]);
156 show_line(log_line, 0);
161 /* may now set in local.c bkph */
163 interaction = error_stop_mode;
165 deletions_allowed = true;
166 set_box_allowed = true;
169 use_err_help = false;
171 OK_to_interrupt = true;
172 /* darn, need to know mem_top, mem_max etc for the following ... */
174 was_mem_end = mem_min;
175 /* was_lo_max = mem_min; */
176 was_lo_max = mem_bot;
177 /* was_hi_min = mem_max; */
178 was_hi_min = mem_top;
186 cur_list.aux_field.cint = ignore_depth;
191 page_tail = page_head;
193 if (is_initex) /* in iniTeX we did already allocate mem [] */
195 mem[page_head].hh.v.RH = 0;
196 /* last_glue = 262143L; */ /* NO! */
197 last_glue = empty_flag;
203 for (k = int_base; k <= eqtb_size; k++)
204 xeq_level[k] = level_one;
206 no_new_control_sequence = true;
210 for (k = hash_base + 1; k <= undefined_control_sequence - 1; k++)
211 hash[k] = hash[hash_base];
229 for (k = 0; k <= 16; k++)
237 for (k = 0; k <= font_max; k++)
238 font_used[k] = false;
240 null_character.b0 = 0;
241 null_character.b1 = 0;
242 null_character.b2 = 0;
243 null_character.b3 = 0;
249 doing_leaders = false;
252 half_buf = dvi_buf_size / 2;
253 dvi_limit = dvi_buf_size;
262 empty_field.v.RH = 0;
263 empty_field.v.LH = 0;
264 null_delimiter.b0 = 0;
265 null_delimiter.b1 = 0;
266 null_delimiter.b2 = 0;
267 null_delimiter.b3 = 0;
274 /* *not* OK with ALLOCATEHYPHEN, since may not be allocated yet */
275 #ifndef ALLOCATEHYPHEN
276 for (z = 0; z <= hyphen_prime; z++)
283 output_active = false;
284 insert_penalties = 0;
285 ligature_present = false;
286 cancel_boundary = false;
291 long_help_seen = false;
294 for (k = 0; k <= 17; k++)
295 write_open[k] = false;
299 /* initex stuff split off for convenience of optimization adjustments */
305 /* trap the -i on command line situation if INITEX was NOT defined */
308 show_line("Sorry, somebody forgot to make an INITEX!\n", 1);
310 #endif /* not INITEX */
313 /* do the part of initialize() that requires mem_top, mem_max or mem[] */
314 /* do this part after allocating main memory */
317 void initialize_aux (void)
320 was_mem_end = mem_min;
321 /* was_lo_max = mem_min; */
322 was_lo_max = mem_bot;
323 /* was_hi_min = mem_max; */
324 was_hi_min = mem_top;
328 /* max_nest_stack = 0; */
332 cur_list.aux_field.cint = ignore_depth;
335 /* shown_mode = 0; */
336 /* page_contents = 0; */
337 page_tail = page_head;
340 #endif // end of ifdef ALLOCATEMAIN
342 void line_break_ (integer final_widow_penalty)
346 halfword q, r, s, prevs;
347 internal_font_number f;
348 /* small_number j; */
349 int j; /* 95/Jan/7 */
350 /* unsigned char c; */
351 unsigned int c; /* 95/Jan/7 */
352 /* savedbadness = 0; */ /* 96/Feb/9 */
354 pack_begin_line = mode_line;
355 link(temp_head) = link(head);
357 if ((tail >= hi_mem_min))
359 tail_append(new_penalty(inf_penalty));
361 else if (type(tail) != glue_node)
363 tail_append(new_penalty(inf_penalty));
367 type(tail) = penalty_node;
368 delete_glue_ref(glue_ptr(tail));
369 flush_node_list(leader_ptr(tail));
370 penalty(tail) = inf_penalty;
373 link(tail) = new_param_glue(par_fill_skip_code);
374 init_cur_lang = prev_graf % 65536L;
375 init_l_hyf = prev_graf / 4194304L; /* 2^22 */
376 init_r_hyf = (prev_graf / 65536L) % 64;
378 no_shrink_error_yet = true;
380 if ((shrink_order(left_skip) != normal) && (shrink(left_skip) != 0))
382 left_skip = finite_shrink(left_skip);
385 if ((shrink_order(right_skip) != normal) && (shrink(right_skip) != 0))
387 right_skip = finite_shrink(right_skip);
392 background[1] = width(q) + width(r);
397 background[2 + stretch_order(q)] = stretch(q);
398 background[2 + stretch_order(r)] = background[2 + stretch_order(r)] + stretch(r);
399 background[6] = shrink(q) + shrink(r);
401 minimum_demerits = 1073741823L; /* 2^30 - 1 *//* 40000000 hex - 1 */
402 minimal_demerits[tight_fit] = 1073741823L;
403 minimal_demerits[decent_fit] = 1073741823L;
404 minimal_demerits[loose_fit] = 1073741823L;
405 minimal_demerits[very_loose_fit] = 1073741823L;
407 if (par_shape_ptr == 0)
408 if (hang_indent == 0)
410 last_special_line = 0;
411 second_width = hsize;
416 last_special_line = abs(hang_after);
420 first_width = hsize - abs(hang_indent);
422 if (hang_indent >= 0)
423 first_indent = hang_indent;
427 second_width = hsize;
434 second_width = hsize - abs(hang_indent);
436 if (hang_indent >= 0)
437 second_indent = hang_indent;
444 last_special_line = info(par_shape_ptr) - 1;
445 second_width = mem[par_shape_ptr + 2 * (last_special_line + 1)].cint;
446 second_indent = mem[par_shape_ptr + 2 * last_special_line + 1].cint;
450 easyline = last_special_line;
452 easyline = empty_flag;
454 threshold = pretolerance;
459 if (tracing_paragraphs > 0)
462 print_nl("@firstpass");
467 first_pass_count++; /* 96 Feb 9 */
471 threshold = tolerance;
473 final_pass = (emergency_stretch <= 0);
475 if (tracing_paragraphs > 0)
482 if (threshold > inf_bad)
495 cur_lang = init_cur_lang;
501 type(q) = unhyphenated;
502 fitness(q) = decent_fit;
505 line_number(q) = prev_graf + 1;
506 total_demerits(q) = 0;
508 active_width[1] = background[1];
509 active_width[2] = background[2];
510 active_width[3] = background[3];
511 active_width[4] = background[4];
512 active_width[5] = background[5];
513 active_width[6] = background[6];
516 printed_node = temp_head;
518 font_in_short_display = 0;
520 cur_p = link(temp_head);
521 auto_breaking = true;
524 while((cur_p != 0) && (link(active) != active))
526 if ((cur_p >= hi_mem_min))
533 active_width[1] = active_width[1] + char_width(f, char_info(f, character(cur_p)));
536 while(!(!(cur_p >= hi_mem_min)));
544 active_width[1] = active_width[1] + width(cur_p);
547 if (subtype(cur_p) == language_node)
549 cur_lang = what_lang(cur_p);
550 lhyf = what_lhm(cur_p);
551 rhyf = what_rhm(cur_p);
558 if ((prevp >= hi_mem_min))
559 try_break(0, unhyphenated);
560 else if ((mem[prevp].hh.b0 < 9))
561 try_break(0, unhyphenated);
562 else if ((type(prevp) == kern_node) && (subtype(prevp) != explicit))
563 try_break(0, unhyphenated);
566 if ((mem[glue_ptr(cur_p)].hh.b1 != 0) && (mem[glue_ptr(cur_p) + 3].cint != 0))
568 glue_ptr(cur_p) = finite_shrink(glue_ptr(cur_p));
572 active_width[1] = active_width[1]+ width(q);
573 active_width[2 + stretch_order(q)] = active_width[2 + stretch_order(q)] + stretch(q);
574 active_width[6] = active_width[6] + shrink(q);
576 if (second_pass && auto_breaking)
585 if ((s >= hi_mem_min))
590 else if (type(s) == ligature_node)
599 else if ((type(s) == kern_node) && (subtype(s) == normal))
601 else if (type(s) == whatsit_node)
603 if (subtype(s) == language_node)
605 cur_lang = what_lang(s);
615 if ((lc_code(c) == (halfword) c) || (uc_hyph > 0)) /* fixed signed tyoe */
624 hyf_char = hyphen_char[hf];
634 if (lhyf + rhyf > 63)
641 if ((s >= hi_mem_min))
646 hyfbchar = character(s);
648 c = hyfbchar; /* unsigned char c; */
662 else if (type(s) == ligature_node)
664 if (font(lig_char(s)) != hf)
670 if (q != 0) /* 94/Mar/23 BUG FIX */
671 hyfbchar = character(q);
673 while (q != 0) /* 94/Mar/23 BUG FIX */
693 hyfbchar = font_bchar[hf];
697 else if ((type(s) == kern_node) && (subtype(s) == normal))
700 hyfbchar = font_bchar[hf];
708 if (hn < lhyf + rhyf)
713 if (!((s >= hi_mem_min)))
719 if (subtype(s) != normal)
744 if (subtype(cur_p) == explicit)
746 if (!(link(cur_p) >= hi_mem_min) && auto_breaking)
747 if (type(link(cur_p)) == glue_node)
748 try_break(0, unhyphenated);
750 active_width[1] = active_width[1] + width(cur_p);
753 active_width[1] = active_width[1] + width(cur_p);
757 f = font(lig_char(cur_p));
758 active_width[1] = active_width[1] + char_width(f, char_info(f, character(lig_char(cur_p))));
763 s = pre_break(cur_p);
767 try_break(ex_hyphen_penalty, hyphenated);
772 if ((s >= hi_mem_min))
775 disc_width = disc_width + char_width(f, char_info(f, character(s)));
781 f = font(lig_char(s));
782 disc_width = disc_width + font_info[width_base[f] + font_info[char_base[f]+ mem[s + 1].hh.b1].qqqq.b0].cint;
789 disc_width = disc_width + width(s);
794 return; // abort_flag set
802 active_width[1] = active_width[1] + disc_width;
803 try_break(hyphen_penalty, hyphenated);
804 active_width[1] = active_width[1] - disc_width;
806 r = replace_count(cur_p);
811 if ((s >= hi_mem_min))
814 active_width[1] = active_width[1] + char_width(f, char_info(f, character(s)));
820 f = font(lig_char(s));
821 active_width[1] = active_width[1] + char_width(f, char_info(f, character(lig_char(s))));
828 active_width[1] = active_width[1] + width(s);
833 return; // abort_flag set
847 auto_breaking = (subtype(cur_p) == 1);
849 if (!(link(cur_p) >= hi_mem_min) && auto_breaking)
850 if (type(link(cur_p)) == glue_node)
851 try_break(0, unhyphenated);
853 active_width[1] = active_width[1] + width(cur_p);
858 try_break(penalty(cur_p), unhyphenated);
866 confusion("paragraph");
867 return; // abort_flag set
878 try_break(eject_penalty, hyphenated);
880 if (link(active) != active)
883 fewest_demerits = 1073741823L; /* 2^30 - 1 */
888 if (total_demerits(r) < fewest_demerits)
890 fewest_demerits = total_demerits(r);
895 while (!(r == active));
896 best_line = line_number(best_bet);
900 goto lab30; /* normal exit */
905 actual_looseness = 0;
910 line_diff = toint(line_number(r)) - toint(best_line);
912 if (((line_diff < actual_looseness) && (looseness <= line_diff)) ||
913 ((line_diff > actual_looseness) && (looseness >= line_diff)))
916 actual_looseness = line_diff;
917 fewest_demerits = total_demerits(r);
919 else if ((line_diff == actual_looseness) && (total_demerits(r) < fewest_demerits))
922 fewest_demerits = total_demerits(r);
927 while (!(r == active));
928 best_line = line_number(best_bet);
931 if ((actual_looseness == looseness) || final_pass)
964 if (tracing_paragraphs > 0)
965 print_nl("@secondpass");
967 threshold = tolerance;
969 second_pass_count++; /* 96 Feb 9 */
970 final_pass = (emergency_stretch <= 0);
975 if (tracing_paragraphs > 0)
976 print_nl("@emergencypass");
978 /* can only get here is \emergencystretch has been set positive */
979 background[2] = background[2] + emergency_stretch;
981 final_pass_count++; /* 96 Feb 9 */
982 } /* end of if second_pass */
983 } /* end of while(true)do */
984 /* cannot drop through from above loop */
985 lab30: /* common exit point */
989 if (tracing_paragraphs > 0)
991 end_diagnostic(true);
992 normalize_selector();
995 post_line_break(final_widow_penalty);
1012 while (q != 0) /* while q<>null do l.16979 */
1019 pack_begin_line = 0;
1022 void prefixed_command (void)
1025 internal_font_number f;
1034 while (cur_cmd == prefix)
1036 if (!odd(a / cur_chr))
1037 a = a + cur_chr; /* small_number a; */
1043 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
1045 if (cur_cmd <= max_non_prefixed_command)
1047 print_err("You can't use a prefix with `");
1048 print_cmd_chr(cur_cmd, cur_chr);
1050 help1("I'll pretend you didn't say \\long or \\outer or \\global.");
1056 if ((cur_cmd != def) && (a % 4 != 0))
1058 print_err("You can't use `");
1060 print_string("' or `");
1062 print_string("' with `");
1063 print_cmd_chr(cur_cmd, cur_chr);
1065 help1("I'll pretend you didn't say \\long or \\outer here.");
1069 if (global_defs != 0)
1070 if (global_defs < 0)
1085 geq_define(cur_font_loc, data, cur_chr);
1087 eq_define(cur_font_loc, data, cur_chr);
1092 if (odd(cur_chr) && !(a >= 4) && (global_defs >= 0))
1098 q = scan_toks(true, e);
1101 geq_define(p, call + (a % 4), def_ref);
1103 eq_define(p, call + (a % 4), def_ref);
1119 while (!(cur_cmd != spacer));
1121 if (cur_tok == other_token + '=')
1125 if (cur_cmd == spacer)
1139 if (cur_cmd >= call)
1140 incr(mem[cur_chr].hh.v.LH);
1143 geq_define(p, cur_cmd, cur_chr);
1145 eq_define(p, cur_cmd, cur_chr);
1156 geq_define(p, relax, 256);
1158 eq_define(p, relax, 256);
1160 scan_optional_equals();
1169 geq_define(p, char_given, cur_val);
1171 eq_define(p, char_given, cur_val);
1175 case math_char_def_code:
1177 scan_fifteen_bit_int();
1180 geq_define(p, math_given, cur_val);
1182 eq_define(p, math_given, cur_val);
1188 scan_eight_bit_int();
1192 case count_def_code:
1194 geq_define(p, assign_int, count_base + cur_val);
1196 eq_define(p, assign_int, count_base + cur_val);
1199 case dimen_def_code:
1201 geq_define(p, assign_dimen, scaled_base + cur_val);
1203 eq_define(p, assign_dimen, scaled_base + cur_val);
1208 geq_define(p, assign_glue, skip_base + cur_val);
1210 eq_define(p, assign_glue, skip_base + cur_val);
1213 case mu_skip_def_code:
1215 geq_define(p, assign_mu_glue, mu_skip_base + cur_val);
1217 eq_define(p, assign_mu_glue, mu_skip_base + cur_val);
1222 geq_define(p, assign_toks, toks_base + cur_val);
1224 eq_define(p, assign_toks, toks_base + cur_val);
1238 if (! scan_keyword("to"))
1240 print_err("Missing `to' inserted");
1241 help2("You should have said `\\read<number> to \\cs'.",
1242 "I'm going to look for the \\cs now.");
1251 geq_define(p, call, cur_val);
1253 eq_define(p, call, cur_val);
1262 if (cur_cmd == toks_register)
1264 scan_eight_bit_int();
1265 p = toks_base + cur_val;
1270 scan_optional_equals();
1276 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
1278 if (cur_cmd != left_brace)
1280 if (cur_cmd == toks_register)
1282 scan_eight_bit_int();
1283 cur_cmd = assign_toks;
1284 cur_chr = toks_base + cur_val;
1287 if (cur_cmd == assign_toks)
1293 geq_define(p, undefined_cs, 0);
1295 eq_define(p, undefined_cs, 0);
1298 incr(mem[q].hh.v.LH);
1301 geq_define(p, call, q);
1303 eq_define(p, call, q);
1311 q = scan_toks(false, false);
1313 if (link(def_ref) == 0)
1316 geq_define(p, undefined_cs, 0);
1318 eq_define(p, undefined_cs, 0);
1320 free_avail(def_ref);
1324 if (p == output_routine_loc)
1326 link(q) = get_avail();
1328 info(q) = right_brace_token + '}';
1330 info(q) = left_brace_token + '{';
1331 link(q) = link(def_ref);
1336 geq_define(p, call, def_ref);
1338 eq_define(p, call, def_ref);
1346 scan_optional_equals();
1350 geq_word_define(p, cur_val);
1352 eq_word_define(p, cur_val);
1359 scan_optional_equals();
1360 scan_dimen(false, false, false);
1363 geq_word_define(p, cur_val);
1365 eq_word_define(p, cur_val);
1370 case assign_mu_glue:
1374 scan_optional_equals();
1376 if (n == assign_mu_glue)
1379 scan_glue(glue_val);
1384 geq_define(p, glue_ref, cur_val);
1386 eq_define(p, glue_ref, cur_val);
1392 if (cur_chr == cat_code_base)
1394 else if (cur_chr == math_code_base)
1395 n = 32768L; /* 2^15 */
1396 else if (cur_chr == sf_code_base)
1397 n = 32767; /* 2^15 - 1*/
1398 else if (cur_chr == del_code_base)
1399 n = 16777215L; /* 2^24 - 1 */
1401 n = 255; /* 2^8 - 1 */
1406 scan_optional_equals();
1409 if (((cur_val < 0) && (p < del_code_base)) ||(cur_val > n))
1411 print_err("Invalid code(");
1414 if (p < del_code_base)
1415 print_string("), should be in the range 0..");
1417 print_string("), should be at most ");
1420 help1("I'm going to use 0 instead of that illegal code value.");
1425 if (p < math_code_base)
1427 geq_define(p, data, cur_val);
1429 eq_define(p, data, cur_val);
1430 else if (p < del_code_base)
1432 geq_define(p, data, cur_val);
1434 eq_define(p, data, cur_val);
1437 geq_word_define(p, cur_val);
1439 eq_word_define(p, cur_val);
1446 scan_four_bit_int();
1448 scan_optional_equals();
1452 geq_define(p, data, cur_val);
1454 eq_define(p, data, cur_val);
1462 do_register_command(a);
1467 scan_eight_bit_int();
1474 scan_optional_equals();
1476 if (set_box_allowed)
1478 scan_box(box_flag + n);
1482 print_err("Improper ");
1483 print_esc("setbox");
1484 help2("Sorry, \\setbox is not allowed after \\halign in a display,",
1485 "or between \\accent and an accented character.");
1499 case set_page_dimen:
1500 alter_page_so_far();
1513 scan_optional_equals();
1521 p = get_node(2 * n + 1);
1524 for (j = 1; j <= n; j++)
1526 scan_dimen(false, false, false);
1527 mem[p + 2 * j - 1].cint = cur_val;
1528 scan_dimen(false, false, false);
1529 mem[p + 2 * j].cint = cur_val;
1534 geq_define(par_shape_loc, shape_ref, p);
1536 eq_define(par_shape_loc, shape_ref, p);
1550 print_err("Patterns can be loaded only by INITEX");
1558 while(!(cur_cmd == right_brace));
1564 new_hyph_exceptions();
1569 case assign_font_dimen:
1571 find_font_dimen(true);
1573 scan_optional_equals();
1574 scan_dimen(false, false, false);
1575 font_info[k].cint = cur_val;
1579 case assign_font_int:
1584 scan_optional_equals();
1588 hyphen_char[f] = cur_val;
1590 skew_char[f] = cur_val;
1598 case set_interaction:
1604 confusion("prefix");
1605 return; // abort_flag set
1608 } /* end of cur_cmd switch */
1611 if (after_token != 0)
1613 cur_tok = after_token;
1619 void bad_formator_pool (char *name, char *defaultname, char *envvar)
1624 sprintf(log_line, "(Perhaps %s is for an older version of TeX)\n", name);
1625 show_line(log_line, 0);
1626 name_of_file[name_length + 1] = '\0';
1627 sprintf(log_line, "(Alternatively, %s may have been corrupted)\n", name_of_file + 1);
1628 show_line(log_line, 0);
1629 name_of_file[name_length + 1] = ' ';
1630 sprintf(log_line, "(Perhaps your %s environment variable is not set correctly)\n", envvar);
1631 show_line(log_line, 0);
1634 char *s; /* extra info 99/April/28 */
1636 if ((s = grabenv(envvar)) != NULL)
1638 sprintf(log_line, "(%s=%s)\n", envvar, s);
1639 show_line(log_line, 0);
1643 sprintf(log_line, "%s environment variable not set\n", envvar);
1644 show_line(log_line, 0);
1652 bool load_fmt_file (void)
1654 register bool Result;
1661 if (x != BEGINFMTCHECKSUM) /* magic FMT file start 4C 20 E6 15 hex */
1664 undump_int(x); /* mem_bot */
1669 undump_int(x); /* mem_top */
1672 /* we already read this once earlier to grab mem_top */
1675 sprintf(log_line, "Read from fmt file mem_top = %d TeX words\n", x);
1676 show_line(log_line, 0);
1679 mem = allocate_main_memory(x); /* allocate main memory at this point */
1682 exit(1); /* redundant sanity test ! */
1684 initialize_aux(); /* do `mem' part of initialize */
1685 /* mem = zmem; */ /* update pointer to main memory */
1691 undump_int(x); /* eqtbsize */
1693 if (x != (eqtb_size))
1696 undump_int(x); /* hash_prime */
1698 if (x != hash_prime)
1701 undump_int(x); /* hyphen_prime */
1703 #ifdef ALLOCATEHYPHEN
1704 /* allow format files dumped with arbitrary (prime) hyphenation exceptions */
1705 realloc_hyphen(x); /* reset_hyphen(); */
1709 if (x != hyphen_prime)
1713 undump_int(x); /* pool_size */
1718 #ifdef ALLOCATESTRING
1719 if (x > current_pool_size)
1723 sprintf(log_line, "undump string pool reallocation (%d > %d)\n", x, current_pool_size);
1724 show_line(log_line, 0);
1726 str_pool = realloc_str_pool (x - current_pool_size + increment_pool_size);
1728 if (x > current_pool_size) /* 94/Jan/24 */
1733 sprintf(log_line, "%s%s\n", "---! Must increase the ", "string pool size");
1734 show_line(log_line, 0);
1741 undump_int(x); /* max_strings */
1745 #ifdef ALLOCATESTRING
1746 if (x > current_max_strings)
1750 sprintf(log_line, "undump string pointer reallocation (%d > %d)\n", x, current_max_strings);
1751 show_line(log_line, 0);
1753 str_start = realloc_str_start(x - current_max_strings + increment_max_strings);
1755 if (x > current_max_strings) /* 94/Jan/24 */
1757 if (x > max_strings)
1760 sprintf(log_line, "%s%s\n", "---! Must increase the ", "max strings");
1761 show_line(log_line, 0);
1768 if (undumpthings(str_start[0], str_ptr + 1)) /* undump string ptrs */
1770 if (undumpthings(str_pool[0], pool_ptr)) /* undump string pool */
1773 init_str_ptr = str_ptr;
1774 init_pool_ptr = pool_ptr;
1775 /* undump the dynamic memory - paragraph 1312 in the book */
1778 if ((x < lo_mem_stat_max + 1000) || (x > hi_mem_stat_min - 1))
1785 if ((x < lo_mem_stat_max + 1) || (x > lo_mem_max))
1790 p = 0; /* mem_bot */
1795 if (undumpthings(mem[p], q + 2 - p))
1798 p = q + node_size(q);
1800 if ((p > lo_mem_max) || ((q >= rlink(q)) && (rlink(q) != rover)))
1804 } while (!(q == rover));
1806 if (undumpthings(mem[p], lo_mem_max + 1 - p))
1809 if (mem_min < mem_bot - 2) /* ? splice in block below */
1811 /* or call add_variable_space(mem_bot - (mem_min + 1)) */
1813 show_line("Splicing in mem_min space in undump!\n", 0);
1817 link(mem_min) = 0; /* null */
1818 info(mem_min) = 0; /* null */
1823 link(q) = empty_flag;
1824 node_size(q) = mem_bot - q; /* ? size of block */
1828 if ((x < lo_mem_max + 1) || (x > hi_mem_stat_min))
1836 if ((x < mem_bot) || (x > mem_top))
1843 if (undumpthings(mem[hi_mem_min], mem_end + 1 - hi_mem_min))
1846 undump_int(var_used);
1847 undump_int(dyn_used);
1852 if ((x < 1) || (k + x > (eqtb_size + 1)))
1855 if (undumpthings(eqtb[k], x))
1861 if ((x < 0) || (k + x > (eqtb_size + 1)))
1864 for (j = k; j <= k + x - 1; j++)
1866 eqtb[j] = eqtb[k - 1];
1869 } while(!(k > (eqtb_size)));
1872 if ((x < hash_base) || (x > (frozen_control_sequence))) /*96/Jan/10*/
1877 par_token = 4095 + par_loc;
1880 if ((x < hash_base) || (x > (frozen_control_sequence))) /*96/Jan/10*/
1887 if ((x < hash_base) || (x > (frozen_control_sequence))) /*96/Jan/10*/
1896 if ((x < p + 1) || (x > hash_used))
1902 } while (!(p == hash_used));
1904 if (undumpthings(hash[hash_used + 1], (undefined_control_sequence - 1) - hash_used))
1907 undump_int(cs_count); /* cs_count */
1910 sprintf(log_line, "itex undump cs_count %d ", cs_count); /* debugging */
1911 show_line(log_line, 0);
1914 undump_int(x); /* font_mem_size */
1920 sprintf(log_line, "Read from fmt fmem_ptr = %d\n", x);
1921 show_line(log_line, 0);
1923 if (x > current_font_mem_size) /* 93/Nov/28 dynamic allocate font_info */
1927 sprintf(log_line, "Undump realloc font_info (%d > %d)\n", x, current_font_mem_size);
1928 show_line(log_line, 0);
1930 font_info = realloc_font_info (x - current_font_mem_size + increment_font_mem_size);
1932 if (x > current_font_mem_size) /* in case allocation failed 94/Jan/24 */
1934 if (x > font_mem_size)
1937 sprintf(log_line, "%s%s\n", "---! Must increase the ", "font mem size");
1938 show_line(log_line, 0);
1945 if (undumpthings(font_info[0], fmem_ptr))
1948 undump_int(x); /* font_max */
1953 sprintf(log_line, "%s%s\n", "---! Must increase the ", "font max");
1954 show_line(log_line, 0);
1960 frozenfontptr = font_ptr; /* remember number of fonts frozen into format */
1961 if (undumpthings(font_check[0], font_ptr + 1))
1963 if (undumpthings(font_size[0], font_ptr + 1))
1965 if (undumpthings(font_dsize[0], font_ptr + 1))
1967 if (undumpthings(font_params[0], font_ptr + 1))
1969 if (undumpthings(hyphen_char[0], font_ptr + 1))
1971 if (undumpthings(skew_char[0], font_ptr + 1))
1973 if (undumpthings(font_name[0], font_ptr + 1))
1975 if (undumpthings(font_area[0], font_ptr + 1))
1977 if (undumpthings(font_bc[0], font_ptr + 1))
1979 if (undumpthings(font_ec[0], font_ptr + 1))
1981 if (undumpthings(char_base[0], font_ptr + 1))
1983 if (undumpthings(width_base[0], font_ptr + 1))
1985 if (undumpthings(height_base[0], font_ptr + 1))
1987 if (undumpthings(depth_base[0], font_ptr + 1))
1989 if (undumpthings(italic_base[0], font_ptr + 1))
1991 if (undumpthings(lig_kern_base[0], font_ptr + 1))
1993 if (undumpthings(kern_base[0], font_ptr + 1))
1995 if (undumpthings(exten_base[0], font_ptr + 1))
1997 if (undumpthings(param_base[0], font_ptr + 1))
1999 if (undumpthings(font_glue[0], font_ptr + 1))
2001 if (undumpthings(bchar_label[0], font_ptr + 1))
2003 if (undumpthings(font_bchar[0], font_ptr + 1))
2005 if (undumpthings(font_false_bchar[0], font_ptr + 1))
2009 /* log not opened yet, so can't show fonts frozen into format */
2010 /* May be able to avoid the following since we switched to */
2011 /* non_address from font_mem_size to 0 96/Jan/15 ??? */
2014 /* deal with fmt files dumped with *different* font_mem_size 93/Nov/29 */
2016 int count = 0, oldfont_mem_size = 0;
2018 for (x = 0; x <= font_ptr; x++)
2020 if (bchar_label[x] > oldfont_mem_size)
2021 oldfont_mem_size = bchar_label[x];
2024 /* somewhat arbitrary sanity check ... */
2025 /* if (oldfont_mem_size != font_mem_size && oldfont_mem_size > font_max) { */
2026 if (oldfont_mem_size != non_address && oldfont_mem_size > font_max) /* 96/Jan/16 */
2028 for (x = 0; x <= font_ptr; x++)
2030 if (bchar_label[x] == oldfont_mem_size)
2032 /* bchar_label[x] = font_mem_size; */
2033 bchar_label[x] = non_address; /* 96/Jan/16 */
2039 sprintf(log_line, "oldfont_mem_size is %d --- hit %d times. Using non_address %d\n",
2040 oldfont_mem_size, count, non_address);
2041 show_line(log_line, 0);
2046 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2047 /* undump(0)(hyph_size)(hyph_count); */
2051 if ((x < 0) || (x > hyphen_prime))
2056 /* undump hypenation exception tables p.1325 */
2057 for (k = 1; k <= hyph_count; k++)
2061 if ((x < 0) || (x > hyphen_prime))
2068 if ((x < 0) || (x > str_ptr))
2075 if ((x < 0) || (x > max_halfword)) /* mem_top ? no p.1325 */
2082 #ifdef ALLOCATEHYPHEN
2083 /* if user specified new hyphen prime - flush existing exception patterns ! */
2084 /* but, we can reclaim the string storage wasted ... */
2087 if (new_hyphen_prime != 0)
2089 realloc_hyphen(new_hyphen_prime); /* reset_hyphen(); */
2090 hyphen_prime = new_hyphen_prime;
2100 #ifdef ALLOCATETRIES
2103 allocate_tries(x); /* allocate only as much as is needed */
2104 /* trie_size = x; */ /* ??? */
2110 sprintf(log_line, "%s%s\n", "---! Must increase the ", "trie size");
2111 show_line(log_line, 0);
2118 if (is_initex) /* bkph */
2121 if (undumpthings(trie_trl[0], j + 1))
2123 if (undumpthings(trie_tro[0], j + 1))
2125 if (undumpthings(trie_trc[0], j + 1))
2131 if (x > trie_op_size)
2133 sprintf(log_line, "%s%s\n", "---! Must increase the ", "trie op size");
2134 show_line(log_line, 0);
2142 if (is_initex) /* bkph */
2146 if (undumpthings(hyf_distance[1], j))
2148 if (undumpthings(hyf_num[1], j))
2150 if (undumpthings(hyf_next[1], j))
2154 if (is_initex) /* bkph */
2156 for (k = 0; k <= 255; k++)
2166 if ((x < 0) || (x > k - 1))
2173 if ((x < 1) || (x > j))
2179 if (is_initex) /* bkph */
2182 /* j:=j-x; op_start[k]:=qo(j); */
2187 if (is_initex) /* bkph */
2188 trie_not_ready = false;
2192 if ((x < batch_mode) || (x > error_stop_mode))
2194 /* else interaction = x; */
2195 if (interaction < batch_mode) /* may now set in local.c bkph 94/Jan/8 */
2200 if ((x < 0) || (x > str_ptr))
2206 /* test_eof(fmt_file)? */
2208 if ((x != ENDFMTCHECKSUM) || feof(fmt_file)) /* magic checksum --- change ? */
2215 sprintf(log_line, "(Fatal format file error; I'm stymied)\n");
2216 show_line(log_line, 1);
2217 /* added following bit of explanation 96/Jan/10 */
2219 bad_formator_pool(format_file, "the format file", "TEXFORMATS");
2224 void final_cleanup (void)
2233 while (input_ptr > 0)
2235 if (cur_input.state_field == 0)
2243 while (open_parens > 0)
2249 if (cur_level > level_one)
2252 print_esc("end occurred ");
2253 print_string("inside a group at level ");
2254 print_int(cur_level - 1);
2258 while (cond_ptr != 0)
2261 print_esc("end occurred ");
2262 print_string("when ");
2263 print_cmd_chr('i', cur_if);
2267 print_string("on line ");
2271 print_string(" was incomplete)");
2272 if_line = mem[cond_ptr + 1].cint;
2273 cur_if = mem[cond_ptr].hh.b1;
2274 temp_ptr = cond_ptr;
2275 cond_ptr = mem[cond_ptr].hh.v.RH;
2276 free_node(temp_ptr, 2);
2279 if (history != spotless)
2280 if (((history == warning_issued) || (interaction < error_stop_mode)))
2281 if (selector == term_and_log)
2283 selector = term_only;
2284 print_nl("(see the transcript file for additional information)");
2285 selector = term_and_log;
2293 for (c = 0; c <= 4; c++)
2295 if (cur_mark[c] != 0)
2296 delete_token_ref(cur_mark[c]);
2299 if (last_glue != max_halfword)
2300 delete_glue_ref(last_glue);
2301 store_fmt_file(); // returns a value ?
2304 if (!is_initex) /* 2000/March/3 */
2305 print_nl("(\\dump is performed only by INITEX)");
2309 void show_frozen (void)
2313 fprintf(log_file, "\n");
2314 fprintf(log_file, "(%d fonts frozen in format file:\n", font_ptr);
2316 for (i = 1; i <= font_ptr; i++)
2319 fprintf(log_file, ", ");
2322 fprintf(log_file, "\n");
2324 n = str_start[font_name[i] + 1] - str_start[font_name[i]];
2326 for (j = 0; j < n; j++)
2328 putc(str_pool[str_start[font_name[i]] + j], log_file);
2332 fprintf(log_file, ") ");
2335 /* Main entry point called from texmf.c int main(int ac, char *av[]) */
2336 /* call from main_program in texmf.c */
2337 /* This in turn calls initialize() */
2339 #pragma warning(disable:4127) // conditional expression is constant
2345 set_paths(TEXFORMATPATHBIT + TEXINPUTPATHBIT + TFMFILEPATHBIT);
2347 if (ready_already == 314159L) /* magic number */
2349 /* These tests are almost all compile time tests and so could be eliminated */
2352 if ((half_error_line < 30) || (half_error_line > error_line - 15))
2355 if (max_print_line < 60)
2358 if (dvi_buf_size % 8 != 0)
2362 bad = 4; /* not compile time */
2364 if (hash_prime > (hash_size + hash_extra))
2367 if (max_in_open >= 128)
2371 bad = 7; /* where from ? *//* not compile time */
2376 if ((mem_min != 0) || (mem_max != mem_top))
2381 if ((mem_min > mem_bot) || (mem_max < mem_top))
2384 if ((min_quarterword > 0) || (max_quarterword < 255))
2387 if ((min_halfword > 0) || (max_halfword < 32767))
2390 if ((min_quarterword < min_halfword) || (max_quarterword > max_halfword))
2393 if ((mem_min < min_halfword) || (mem_max >= max_halfword) || (mem_bot - mem_min >= max_halfword))
2395 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2396 if (mem_max > mem_top + mem_extra_high) /* not compile time */
2397 bad = 14; /* ha ha */
2398 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2399 /* if ((0 < 0)||(font_max > 255)) */
2400 if ((0 < min_quarterword) || (font_max > max_quarterword)) /* 93/Dec/3 */
2402 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2403 #ifdef INCREASEFONTS
2404 if (font_max > 1024) /* 96/Jan/17 */
2410 if ((save_size > max_halfword) || (max_strings > max_halfword))
2413 if (buf_size > max_halfword)
2416 if (max_quarterword - min_quarterword < 255)
2419 if (cs_token_flag + undefined_control_sequence > max_halfword)
2422 if (format_default_length > PATHMAX)
2424 /* if (2 * 262143L < mem_top - mem_min) */
2425 if (max_halfword < (mem_top - mem_min) / 2)
2430 sprintf(log_line, "%s%s%ld\n", "Ouch---my internal constants have been clobbered!",
2431 "---case ", (long) bad);
2432 show_line(log_line, 1);
2435 bad_formator_pool(format_file, "the format file", "TEXFORMATS"); /* 96/Jan/17 */
2437 goto lab9999; // abort
2445 if (!get_strings_started())
2446 goto lab9999; // abort
2449 init_str_ptr = str_ptr;
2450 init_pool_ptr = pool_ptr;
2451 fix_date_and_time();
2454 ready_already = 314159L; /* magic number */
2456 lab1: /* get here directly if ready_already already set ... */
2457 selector = term_only;
2461 show_line(tex_version, 0);
2462 sprintf(log_line, " (%s %s)", application, yandyversion);
2463 show_line(log_line, 0);
2465 if (format_ident > 0)
2466 slow_print(format_ident);
2475 name_in_progress = false;
2477 output_file_name = 0;
2484 high_in_open = 0; /* max_in_open name already used 1999 Jan 17 */
2486 max_open_parens = 0; /* max_open_parens */
2489 max_param_stack = 0;
2491 #ifdef ALLOCATEBUFFER
2492 /* first = current_buf_size; */
2493 memset (buffer, 0, current_buf_size); /* redundant */
2495 /* first = buf_size; */
2496 memset (buffer, 0, buf_size); /* redundant ? */
2498 first = 0; /* 1999/Jan/22 */
2501 warning_index = 0; /* warning_index:=null; l.7068 */
2503 cur_input.state_field = 33;
2504 cur_input.start_field = 1;
2505 cur_input.index_field = 0;
2507 cur_input.name_field = 0;
2509 align_state = 1000000L;
2511 if (!init_terminal())
2512 goto lab9999; // abort
2514 cur_input.limit_field = last;
2517 /* if ((format_ident == 0)||(buffer[cur_input.loc_field]== 38)) */
2518 /* For Windows NT, lets allow + instead of & for format specification */
2519 if ((format_ident == 0) ||
2520 (buffer[cur_input.loc_field] == '&') ||
2521 (buffer[cur_input.loc_field] == '+'))
2523 if (format_ident != 0)
2526 if (!open_fmt_file ())
2527 goto lab9999; // abort
2529 if (!load_fmt_file ())
2532 goto lab9999; // abort
2537 while ((cur_input.loc_field < cur_input.limit_field) &&
2538 (buffer[cur_input.loc_field] == ' '))
2539 incr(cur_input.loc_field);
2544 check_eqtb("after format"); /* debugging 94/Apr/5 */
2546 if ((end_line_char < 0) || (end_line_char > 255))
2547 decr(cur_input.limit_field);
2549 buffer[cur_input.limit_field] = end_line_char;
2551 fix_date_and_time();
2553 magic_offset = str_start[886] - 9 * ord_noad; /* following: */
2554 /* "0234000122*4000133**3**344*0400400*000000234000111*1111112341011" */
2556 if (interaction == batch_mode)
2557 selector = no_print;
2559 selector = term_only;
2561 if ((cur_input.loc_field < cur_input.limit_field) &&
2562 (cat_code(buffer[cur_input.loc_field]) != escape))
2566 /* show font TFMs frozen into format file */
2567 /* moved here after start_input to ensure the log file is open */
2568 if (show_tfm_flag && log_opened && font_ptr > 0) /* 98/Sep/28 */
2571 main_time = clock();
2575 print_cs_names(stdout, 0); /* 98/Mar/31 */
2577 main_control(); /* read-eval-print loop :-) in tex8.c */
2580 print_cs_names(stdout, 1); /* 98/Mar/31 */
2584 close_files_and_terminate();
2596 if ((history != 0) && (history != 1))
2600 // now return instead of exit to allow cleanup in local.c
2604 } /* end of texbody */
2607 /* add a block of variable size node space below mem_bot */
2608 /* used in tex0.c, local.c, itex.c */
2609 void add_variable_space(int size)
2616 t = mem_min; /* bottom of present block */
2620 mem_min = t - (size + 1); /* first word in new block - 1 */
2621 /* mem_min = mem_start; */ /* allocate all of it at once */
2622 if (mem_min < mem_start) /* sanity test */
2625 show_line("WARNING: mem_min < mem_start!\n", 0);
2626 mem_min = mem_start;
2629 p = mem[rover + 1].hh.v.LH;
2631 mem[mem_min].hh.v.RH = 0; /* insert blank word below ??? */
2632 mem[mem_min].hh.v.LH = 0; /* insert blank word below ??? */
2633 mem[p + 1].hh.v.RH = q;
2634 mem[rover + 1].hh.v.LH = q;
2635 mem[q + 1].hh.v.RH = rover;
2636 mem[q + 1].hh.v.LH = p;
2637 mem[q].hh.v.RH = empty_flag;
2638 mem[q].hh.v.LH = t - q; /* block size */
2643 /**************************************************************************/
2646 /* split out to allow sharing of code from do_initex and newpattern */
2647 void reset_trie (void)
2651 for (k = - (integer) trie_op_size; k <= trie_op_size; k++)
2652 trie_op_hash[k] = 0;
2654 for (k = 0; k <= 255; k++)
2655 trie_used[k] = min_trie_op;
2657 max_op_used = min_trie_op;
2659 trie_not_ready = true;
2663 trie_not_ready = true;
2665 /* borrowed code from initialize() */
2666 void reset_hyphen (void)
2670 for (z = 0; z <= hyphen_prime; z++)
2673 hyph_list[z] = 0; /* hyph_list[z]:=null; l.18131 */
2678 /* split out to allow optimize for space, not time */
2679 void do_initex (void)
2683 /* hyph_pointer z; */
2685 for (k = mem_bot + 1; k <= lo_mem_stat_max; k++)
2690 while (k <= lo_mem_stat_max)
2692 glue_ref_count(k) = 1;
2693 stretch_order(k) = normal;
2694 shrink_order(k) = normal;
2695 k = k + glue_spec_size;
2698 stretch(fil_glue) = 65535L;
2699 stretch_order(fil_glue) = fil;
2700 stretch(fill_glue) = 65535L;
2701 stretch_order(fill_glue) = fill;
2702 stretch(ss_glue) = 65535L;
2703 stretch_order(ss_glue) = fil;
2704 shrink(ss_glue) = 65535L;
2705 shrink_order(ss_glue) = fil;
2706 stretch(fil_neg_glue) = -65536L;
2707 stretch_order(fil_neg_glue) = fil;
2708 rover = lo_mem_stat_max + 1;
2709 link(rover) = empty_flag;
2710 node_size(rover) = block_size;
2711 llink(rover) = rover;
2712 rlink(rover) = rover;
2713 lo_mem_max = rover + block_size;
2714 link(lo_mem_max) = 0;
2715 info(lo_mem_max) = 0;
2717 for (k = hi_mem_stat_min; k <= mem_top; k++)
2718 mem[k] = mem[lo_mem_max];
2720 info(omit_template) = end_template_token;
2721 link(end_span) = max_quarterword + 1;
2723 type(last_active) = hyphenated;
2724 line_number(last_active) = max_halfword;
2725 subtype(last_active) = 0;
2726 subtype(page_ins_head) = 255;
2727 type(page_ins_head) = split_up;
2728 link(mem_top) = page_ins_head;
2729 type(page_head) = glue_node;
2730 subtype(page_head) = normal;
2731 avail = 0; /* avail <- null p.164 */
2733 hi_mem_min = hi_mem_stat_min;
2734 var_used = lo_mem_stat_max + 1 - mem_bot;
2735 dyn_used = hi_mem_stat_usage;
2736 eq_type(undefined_control_sequence) = undefined_cs;
2737 equiv(undefined_control_sequence) = 0;
2738 eq_level(undefined_control_sequence) = level_zero;
2740 for (k = active_base; k <= undefined_control_sequence - 1; k++)
2741 eqtb[k] = eqtb[undefined_control_sequence];
2743 equiv(glue_base) = zero_glue;
2744 eq_level(glue_base) = level_one;
2745 eq_type(glue_base) = glue_ref;
2747 for (k = glue_base + 1; k <= local_base - 1; k++)
2748 eqtb[k] = eqtb[glue_base];
2750 glue_ref_count(zero_glue) = glue_ref_count(zero_glue) + local_base - glue_base;
2753 eq_type(par_shape_loc) = shape_ref;
2754 eq_level(par_shape_loc) = level_one;
2756 for (k = output_routine_loc; k <= toks_base + 255; k++)
2757 eqtb[k] = eqtb[undefined_control_sequence];
2760 eq_type(box_base) = box_ref;
2761 eq_level(box_base) = level_one;
2763 for (k = box_base + 1; k <= box_base + 255; k++)
2764 eqtb[k] = eqtb[box_base];
2766 cur_font = null_font;
2767 eq_type(cur_font_loc) = data;
2768 eq_level(cur_font_loc) = level_one;
2770 for (k = math_font_base; k <= math_font_base + 47; k++)
2771 eqtb[k] = eqtb[cur_font_loc];
2773 equiv(cat_code_base) = 0;
2774 eq_type(cat_code_base) = data;
2775 eq_level(cat_code_base) = level_one;
2777 for (k = cat_code_base; k <= int_base - 1; k++)
2778 eqtb[k] = eqtb[cat_code_base];
2780 for (k = 0; k <= 255; k++)
2782 cat_code(k) = other_char;
2787 cat_code(carriage_return) = car_ret;
2788 cat_code(' ') = spacer;
2789 cat_code('\\') = escape;
2790 cat_code('%') = comment;
2791 cat_code(invalid_code) = invalid_char;
2792 cat_code(null_code) = ignore;
2794 for (k = '0'; k <= '9'; k++)
2795 math_code(k) = k + var_code;
2797 for (k = 'A'; k <= 'Z'; k++)
2799 cat_code(k) = letter;
2800 cat_code(k + 'a' - 'A') = letter;
2801 math_code(k) = k + var_code + 0x100;
2802 math_code(k + 'a' - 'A') = k + 'a' - 'A' + var_code + 0x100;
2803 lc_code(k) = k + 'a' - 'A';
2804 lc_code(k + 'a' - 'A') = k + 'a' - 'A';
2806 uc_code(k + 'a' - 'A') = k;
2810 for (k = int_base; k <= del_code_base - 1; k++)
2816 max_dead_cycles = 25;
2818 end_line_char = carriage_return;
2820 for (k = 0; k <= 255; k++)
2825 for (k = dimen_base; k <= eqtb_size; k++)
2828 hash_used = frozen_control_sequence;
2832 show_line("initex cs_count = 0 ", 0);
2834 eq_type(frozen_dont_expand) = dont_expand;
2835 text(frozen_dont_expand) = 499; /* notexpanded */
2837 font_ptr = null_font;
2839 font_name[null_font] = 795; /* nullfont */
2840 font_area[null_font] = 335; /* "" */
2841 hyphen_char[null_font] = '-';
2842 skew_char[null_font] = -1;
2843 bchar_label[null_font] = non_address;
2844 font_bchar[null_font] = non_char;
2845 font_false_bchar[null_font] = non_char;
2846 font_bc[null_font] = 1;
2847 font_ec[null_font] = 0;
2848 font_size[null_font] = 0;
2849 font_dsize[null_font] = 0;
2850 char_base[null_font] = 0;
2851 width_base[null_font] = 0;
2852 height_base[null_font] = 0;
2853 depth_base[null_font] = 0;
2854 italic_base[null_font] = 0;
2855 lig_kern_base[null_font] = 0;
2856 kern_base[null_font] = 0;
2857 exten_base[null_font] = 0;
2858 font_glue[null_font] = 0;
2859 font_params[null_font] = 7;
2860 param_base[null_font] = -1;
2861 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2862 reset_trie(); /* shared 93/Nov/26 */
2863 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2865 text(frozen_protection) = 1184; /* "inaccessible" */
2866 format_ident = 1251;
2867 text(end_write) = 1290;
2868 eq_level(end_write) = level_one;
2869 eq_type(end_write) = outer_call;
2870 equiv(end_write) = 0;
2876 bool get_strings_started (void)
2885 for (k = 0; k <= 255; k++)
2887 if (((k < ' ') || (k > '~')))
2893 append_char(k + 64);
2896 append_char(k - 64);
2899 append_lc_hex(k / 16);
2900 append_lc_hex(k % 16);
2909 g = load_pool_strings(pool_size - stringvacancies);
2913 fprintf(stdout , "%s\n", "! You have to increase POOLSIZE." );
2923 void sort_avail (void)
2928 p = get_node(1073741824L); /* 2^30 merge adjacent free nodes */
2930 rlink(rover) = empty_flag;
2933 while (p != old_rover)
2946 while (rlink(q) < p)
2950 rlink(p) = rlink(q);
2958 while (rlink(p) != empty_flag)
2960 llink(rlink(p)) = p;
2970 str_number make_string_pool (char *s)
2972 int slen = strlen(s);
2976 return ((str_number)s[0]);
2980 memcpy(str_pool + pool_ptr, s, slen);
2982 return (make_string());
2986 void primitive_ (str_number s, quarterword c, halfword o)
2990 /* small_number l; */
2991 int l; /* 95/Jan/7 */
2994 cur_val = s + single_base;
2998 l = str_start[s + 1] - k; /* small_number l */
3000 for (j = 0; j <= l - 1; j++)
3001 buffer[j] = str_pool[k + j];
3003 cur_val = id_lookup(0, l);
3008 show_line("ERROR: hash entry too large\n", 1);
3014 eq_level(cur_val) = level_one;
3015 eq_type(cur_val) = c;
3020 /* more weird constants ? page 394 */
3024 trie_op_code new_trie_op_ (small_number d, small_number n, trie_op_code v)
3030 h = abs(n + 313 * d + 361 * v + 1009 * cur_lang) % (trie_op_size + trie_op_size) + neg_trie_op_size;
3034 l = trie_op_hash[h];
3038 if (trie_op_ptr == trie_op_size)
3040 overflow("pattern memory ops", trie_op_size);
3041 return 0; // abort_flag set
3044 u = trie_used[cur_lang];
3046 if (u == max_trie_op)
3048 overflow("pattern memory ops per language", max_trie_op - min_trie_op);
3049 return 0; // abort_flag set
3054 trie_used[cur_lang] = u;
3056 if (u > max_op_used)
3059 hyf_distance[trie_op_ptr] = d;
3060 hyf_num[trie_op_ptr] = n;
3061 hyf_next[trie_op_ptr] = v;
3062 trie_op_lang[trie_op_ptr] = cur_lang;
3063 trie_op_hash[h] = trie_op_ptr;
3064 trie_op_val[trie_op_ptr] = u;
3068 if ((hyf_distance[l]== d) && (hyf_num[l]== n) && (hyf_next[l]== v) && (trie_op_lang[l]== cur_lang))
3070 return trie_op_val[l];
3073 if (h > - (integer) trie_op_size)
3080 trie_pointer trie_node_ (trie_pointer p)
3085 /* the 1009, 2718, 3142 are hard-wired constants here (not hyphen_prime) */
3086 /* compute hash value */
3087 h = abs(trie_c[p] + 1009 * trie_o[p] + 2718 * trie_l[p] + 3142 * trie_r[p]) % trie_size;
3099 if ((trie_c[q] == trie_c[p]) && (trie_o[q] == trie_o[p]) &&
3100 (trie_l[q] == trie_l[p]) && (trie_r[q] == trie_r[p]))
3112 trie_pointer compress_trie_ (trie_pointer p)
3118 trie_l[p] = compress_trie(trie_l[p]);
3119 trie_r[p] = compress_trie(trie_r[p]);
3120 return trie_node(p);
3124 void first_fit_ (trie_pointer p)
3140 if (trie_max < h + 256)
3142 if (trie_size <= h + 256)
3144 /* pattern memory - NOT DYNAMIC */
3145 overflow("pattern memory", trie_size);
3146 /* not dynamic ---- but can be set -h=... from command line in ini-TeX */
3147 return; // abort_flag set
3153 trie_taken[trie_max] = false;
3154 trie_trl[trie_max] = trie_max + 1;
3155 trie_tro[trie_max] = trie_max - 1;
3157 while (!(trie_max == h + 256));
3167 if (trie_trl[h + trie_c[q]] == 0)
3178 trie_taken[h] = true; /* h may be used without ... */
3193 ll = z; /* short ll */
3200 } while (!(l == ll));
3203 } while (!(q == 0));
3206 void trie_pack_ (trie_pointer p)
3214 if ((q > 0) && (trie_hash[q]== 0))
3225 void trie_fix_ (trie_pointer p)
3237 trie_trl[z + c] = trie_hash[q];
3238 trie_trc[z + c] = c;
3239 trie_tro[z + c] = trie_o[p];
3249 void new_patterns (void)
3251 /* ******************************************************************* */
3252 /* was small_number k, l; in 3.141 */
3254 /* ******************************************************************* */
3260 int c; /* 95/Jan/7 */
3262 if (!trie_not_ready) /* new stuff */
3267 show_line("Resetting patterns\n", 0);
3269 reset_trie(); /* RESET PATTERNS - 93/Nov/26 */
3271 if (reset_exceptions)
3274 show_line("Resetting exceptions\n", 0);
3276 reset_hyphen(); /* RESET HYPHENEXCEPTIONS - 93/Nov/26 */
3280 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
3287 digitsensed = false;
3297 if (digitsensed || (cur_chr < '0') || (cur_chr > '9'))
3303 cur_chr = lc_code(cur_chr);
3307 print_err("Nonletter");
3308 help1("(See Appendix H.)");
3318 digitsensed = false;
3323 hyf[k] = cur_chr - '0';
3343 v = new_trie_op(k - l, hyf[l], v);
3360 while ((p > 0) && (c > trie_c[p])) {
3366 if ((p == 0) || (c < trie_c[p]))
3368 if (trie_ptr == trie_size)
3370 overflow("pattern memory", trie_size); /* pattern memory - NOT DYNAMIC */
3371 /* not dynamic ---- but can be set -h=... from command line in ini-TeX */
3372 return; // abort_flag set
3376 trie_r[trie_ptr] = p;
3386 trie_o[p] = min_trie_op;
3391 if (trie_o[q]!= min_trie_op)
3393 print_err("Duplicate pattern");
3394 help1("(See Appendix H.)");
3401 if (cur_cmd == right_brace)
3406 digitsensed = false;
3412 print_esc("patterns");
3413 help1("(See Appendix H.)");
3423 print_err("Too late for ");
3424 print_esc("patterns");
3425 help1("All patterns must be given before typesetting begins.");
3427 link(garbage) = scan_toks(false, false);
3428 flush_list(def_ref);
3432 void init_trie (void)
3435 /* integer j, k, t; */
3437 int t; /* 95/Jan/7 */
3440 op_start[0] = - (integer) min_trie_op;
3442 for (j = 1; j <= 255; j++)
3444 op_start[j] = op_start[j - 1] + trie_used[j - 1];
3447 for (j = 1; j <= trie_op_ptr; j++)
3449 trie_op_hash[j] = op_start[trie_op_lang[j]] + trie_op_val[j];
3452 for (j = 1; j <= trie_op_ptr; j++)
3454 while (trie_op_hash[j] > j)
3456 k = trie_op_hash[j];
3457 t = hyf_distance[k];
3458 hyf_distance[k] = hyf_distance[j];
3459 hyf_distance[j] = t;
3461 hyf_num[k] = hyf_num[j];
3464 hyf_next[k] = hyf_next[j];
3466 trie_op_hash[j] = trie_op_hash[k];
3467 trie_op_hash[k] = k;
3471 for (p = 0; p <= trie_size; p++)
3476 trie_l[0] = compress_trie(trie_l[0]);
3478 for (p = 0; p <= trie_ptr; p++)
3483 for (p = 0; p <= 255; p++)
3485 trie_min[p] = p + 1;
3493 first_fit(trie_l[0]);
3494 trie_pack(trie_l[0]);
3499 for (r = 0; r <= 256; r++)
3502 trie_tro[r] = min_trie_op;
3509 trie_fix(trie_l[0]);
3517 trie_tro[r] = min_trie_op;
3523 while(!(r > trie_max));
3526 trie_not_ready = false;
3532 void store_fmt_file (void)
3538 if (!is_initex) /* redundant check 94/Feb/14 */
3540 show_line("! \\dump is performed only by INITEX\n", 1);
3543 show_line(" (Use -i on the command line)\n", 0);
3551 print_err("You can't dump inside a group");
3552 help1("`{...\\dump}' is a no-no.");
3556 selector = new_string;
3557 print_string(" (format=");
3567 if (interaction == 0)
3568 selector = log_only;
3570 selector = term_and_log;
3573 format_ident = make_string();
3574 pack_job_name(".fmt");
3576 while(!w_open_out(fmt_file))
3578 prompt_file_name("format file name", ".fmt");
3581 print_nl("Beginning to dump on file ");
3582 slow_print(w_make_name_string(fmt_file));
3585 slow_print(format_ident);
3587 dump_int(BEGINFMTCHECKSUM); /* magic FMT file start 4C 20 E6 15 hex */
3591 dump_int(eqtb_size);
3592 dump_int(hash_prime);
3593 dump_int(hyphen_prime); /* bkph */
3598 if (dumpthings(str_start[0], str_ptr + 1))
3601 if (dumpthings(str_pool[0], pool_ptr))
3606 print_string(" strings of total length ");
3607 print_int(pool_ptr);
3611 dump_int(lo_mem_max);
3619 if (dumpthings(mem[p], q + 2 - p))
3623 var_used = var_used + q - p;
3624 p = q + mem[q].hh.v.LH;
3625 q = mem[q + 1].hh.v.RH;
3627 while (!(q == rover));
3629 var_used = var_used + lo_mem_max - p;
3630 dyn_used = mem_end + 1 - hi_mem_min;
3632 if (dumpthings(mem[p], lo_mem_max + 1 - p))
3635 x = x + lo_mem_max + 1 - p;
3636 dump_int(hi_mem_min);
3639 if (dumpthings(mem[hi_mem_min], mem_end + 1 - hi_mem_min))
3642 x = x + mem_end + 1 - hi_mem_min;
3655 print_string(" memory locations dumped; current usage is ");
3656 print_int(var_used);
3658 print_int(dyn_used);
3665 while (j < (int_base - 1))
3667 if ((equiv(j) == equiv(j + 1)) &&
3668 (eq_type(j) == eq_type(j + 1)) &&
3669 (eq_level(j) == eq_level(j + 1)))
3679 while (j < (int_base - 1))
3681 if ((equiv(j) != equiv(j + 1)) ||
3682 (eq_type(j) != eq_type(j + 1)) ||
3683 (eq_level(j) != eq_level(j + 1)))
3690 if (dumpthings(eqtb[k], l - k))
3696 while (!(k == (int_base)));
3700 while (j < (eqtb_size)) {
3701 if (eqtb[j].cint == eqtb[j + 1].cint)
3705 l = (eqtb_size + 1);
3710 while (j < (eqtb_size)) {
3711 if (eqtb[j].cint != eqtb[j + 1].cint)
3717 if (dumpthings(eqtb[k], l - k))
3721 } while (!(k > (eqtb_size)));
3724 dump_int(write_loc);
3726 dump_int(hash_used);
3727 cs_count = frozen_control_sequence - 1 - hash_used;
3731 sprintf(log_line, "itex cs_count %d hash_size %d hash_extra %d hash_used %d",
3732 cs_count, hash_size, hash_extra, hash_used);
3733 show_line(log_line, 0);
3736 for (p = hash_base; p <= hash_used; p++)
3738 if (hash[p].v.RH != 0)
3746 sprintf(log_line, "itex cs_count++ ");
3747 show_line(log_line, 0); /* debugging */
3753 /* for p <- hash_used+1 to undefined_control_sequence-1 do dump_hh(hash[p]) */
3754 if (dumpthings(hash[hash_used + 1], (hash_size + 780) - hash_used))
3759 print_int(cs_count);
3760 print_string(" multiletter control sequences");
3764 if (dumpthings(font_info[0], fmem_ptr))
3769 if (dumpthings(font_check[0], font_ptr + 1))
3772 if (dumpthings(font_size[0], font_ptr + 1))
3775 if (dumpthings(font_dsize[0], font_ptr + 1))
3778 if (dumpthings(font_params[0], font_ptr + 1))
3781 if (dumpthings(hyphen_char[0], font_ptr + 1))
3784 if (dumpthings(skew_char[0], font_ptr + 1))
3787 if (dumpthings(font_name[0], font_ptr + 1))
3790 if (dumpthings(font_area[0], font_ptr + 1))
3793 if (dumpthings(font_bc[0], font_ptr + 1))
3796 if (dumpthings(font_ec[0], font_ptr + 1))
3799 if (dumpthings(char_base[0], font_ptr + 1))
3802 if (dumpthings(width_base[0], font_ptr + 1))
3805 if (dumpthings(height_base[0], font_ptr + 1))
3808 if (dumpthings(depth_base[0], font_ptr + 1))
3811 if (dumpthings(italic_base[0], font_ptr + 1))
3814 if (dumpthings(lig_kern_base[0], font_ptr + 1))
3817 if (dumpthings(kern_base[0], font_ptr + 1))
3820 if (dumpthings(exten_base[0], font_ptr + 1))
3823 if (dumpthings(param_base[0], font_ptr + 1))
3826 if (dumpthings(font_glue[0], font_ptr + 1))
3829 if (dumpthings(bchar_label[0], font_ptr + 1))
3832 if (dumpthings(font_bchar[0], font_ptr + 1))
3835 if (dumpthings(font_false_bchar[0], font_ptr + 1))
3838 for (k = 0; k <= font_ptr; k++)
3841 /* print_esc(hash[(hash_size + 524) + k].v.RH); */
3842 /* print_esc(hash[(hash_size + hash_extra + 524) + k].v.RH); */
3843 print_esc("");print(hash[(hash_size + hash_extra + 524) + k].v.RH);
3845 print_file_name(font_name[k], font_area[k], 335);
3847 if (font_size[k] != font_dsize[k])
3849 print_string(" at ");
3850 print_scaled(font_size[k]);
3857 print_int(fmem_ptr - 7);
3858 print_string(" words of font info for ");
3859 print_int(font_ptr - 0);
3860 print_string(" preloaded font");
3865 dump_int(hyph_count);
3867 for (k = 0; k <= hyphen_prime; k++)
3869 if (hyph_word[k]!= 0)
3872 dump_int(hyph_word[k]);
3873 dump_int(hyph_list[k]);
3878 print_int(hyph_count);
3879 print_string(" hyphenation exception");
3881 if (hyph_count != 1)
3889 if (dumpthings(trie_trl[0], trie_max + 1))
3892 if (dumpthings(trie_tro[0], trie_max + 1))
3895 if (dumpthings(trie_trc[0], trie_max + 1))
3898 dump_int(trie_op_ptr);
3900 if (dumpthings(hyf_distance[1], trie_op_ptr))
3903 if (dumpthings(hyf_num[1], trie_op_ptr))
3906 if (dumpthings(hyf_next[1], trie_op_ptr))
3909 print_nl("Hyphenation trie of length ");
3910 print_int(trie_max);
3911 print_string(" has ");
3912 print_int(trie_op_ptr);
3913 print_string(" op");
3915 if (trie_op_ptr != 1)
3918 print_string(" out of ");
3919 print_int(trie_op_size);
3921 for (k = 255; k >= 0; k--)
3923 if (trie_used[k] > 0)
3926 print_int(trie_used[k]);
3927 print_string(" for language ");
3930 dump_int(trie_used[k]);
3933 dump_int(interaction);
3934 dump_int(format_ident);
3935 dump_int(ENDFMTCHECKSUM); /* magic checksum end of FMT file --- change ??? */
3944 void init_prim (void)
3946 no_new_control_sequence = false;
3947 primitive("lineskip", assign_glue, glue_base + line_skip_code);
3948 primitive("baselineskip", assign_glue, glue_base + baseline_skip_code);
3949 primitive("parskip", assign_glue, glue_base + par_skip_code);
3950 primitive("abovedisplayskip", assign_glue, glue_base + above_display_skip_code);
3951 primitive("belowdisplayskip", assign_glue, glue_base + below_display_skip_code);
3952 primitive("abovedisplayshortskip", assign_glue, glue_base + above_display_short_skip_code);
3953 primitive("belowdisplayshortskip", assign_glue, glue_base + below_display_short_skip_code);
3954 primitive("leftskip", assign_glue, glue_base + left_skip_code);
3955 primitive("rightskip", assign_glue, glue_base + right_skip_code);
3956 primitive("topskip", assign_glue, glue_base + top_skip_code);
3957 primitive("splittopskip", assign_glue, glue_base + split_top_skip_code);
3958 primitive("tabskip", assign_glue, glue_base + tab_skip_code);
3959 primitive("spaceskip", assign_glue, glue_base + space_skip_code);
3960 primitive("xspaceskip", assign_glue, glue_base + xspace_skip_code);
3961 primitive("parfillskip", assign_glue, glue_base + par_fill_skip_code);
3962 primitive("thinmuskip", assign_mu_glue, glue_base + thin_mu_skip_code);
3963 primitive("medmuskip", assign_mu_glue, glue_base + med_mu_skip_code);
3964 primitive("thickmuskip", assign_mu_glue, glue_base + thick_mu_skip_code);
3965 primitive("output", assign_toks, output_routine_loc);
3966 primitive("everypar", assign_toks, every_par_loc);
3967 primitive("everymath", assign_toks, every_math_loc);
3968 primitive("everydisplay", assign_toks, every_display_loc);
3969 primitive("everyhbox", assign_toks, every_hbox_loc);
3970 primitive("everyvbox", assign_toks, every_vbox_loc);
3971 primitive("everyjob", assign_toks, every_job_loc);
3972 primitive("everycr", assign_toks, every_cr_loc);
3973 primitive("errhelp", assign_toks, err_help_loc);
3974 primitive("pretolerance", assign_int, int_base + pretolerance_code);
3975 primitive("tolerance", assign_int, int_base + tolerance_code);
3976 primitive("linepenalty", assign_int, int_base + line_penalty_code);
3977 primitive("hyphenpenalty", assign_int, int_base + hyphen_penalty_code);
3978 primitive("exhyphenpenalty", assign_int, int_base + ex_hyphen_penalty_code);
3979 primitive("clubpenalty", assign_int, int_base + club_penalty_code);
3980 primitive("widowpenalty", assign_int, int_base + widow_penalty_code);
3981 primitive("displaywidowpenalty", assign_int, int_base + display_widow_penalty_code);
3982 primitive("brokenpenalty", assign_int, int_base + broken_penalty_code);
3983 primitive("binoppenalty", assign_int, int_base + bin_op_penalty_code);
3984 primitive("relpenalty", assign_int, int_base + rel_penalty_code);
3985 primitive("predisplaypenalty", assign_int, int_base + pre_display_penalty_code);
3986 primitive("postdisplaypenalty", assign_int, int_base + post_display_penalty_code);
3987 primitive("interlinepenalty", assign_int, int_base + inter_line_penalty_code);
3988 primitive("doublehyphendemerits", assign_int, int_base + double_hyphen_demerits_code);
3989 primitive("finalhyphendemerits", assign_int, int_base + final_hyphen_demerits_code);
3990 primitive("adjdemerits", assign_int, int_base + adj_demerits_code);
3991 primitive("mag", assign_int, int_base + mag_code);
3992 primitive("delimiterfactor", assign_int, int_base + delimiter_factor_code);
3993 primitive("looseness", assign_int, int_base + looseness_code);
3994 primitive("time", assign_int, int_base + time_code);
3995 primitive("day", assign_int, int_base + day_code);
3996 primitive("month", assign_int, int_base + month_code);
3997 primitive("year", assign_int, int_base + year_code);
3998 primitive("showboxbreadth", assign_int, int_base + show_box_breadth_code);
3999 primitive("showboxdepth", assign_int, int_base + show_box_depth_code);
4000 primitive("hbadness", assign_int, int_base + hbadness_code);
4001 primitive("vbadness", assign_int, int_base + vbadness_code);
4002 primitive("pausing", assign_int, int_base + pausing_code);
4003 primitive("tracingonline", assign_int, int_base + tracing_online_code);
4004 primitive("tracingmacros", assign_int, int_base + tracing_macros_code);
4005 primitive("tracingstats", assign_int, int_base + tracing_stats_code);
4006 primitive("tracingparagraphs", assign_int, int_base + tracing_paragraphs_code);
4007 primitive("tracingpages", assign_int, int_base + tracing_pages_code);
4008 primitive("tracingoutput", assign_int, int_base + tracing_output_code);
4009 primitive("tracinglostchars", assign_int, int_base + tracing_lost_chars_code);
4010 primitive("tracingcommands", assign_int, int_base + tracing_commands_code);
4011 primitive("tracingrestores", assign_int, int_base + tracing_restores_code);
4012 primitive("uchyph", assign_int, int_base + uc_hyph_code);
4013 primitive("outputpenalty", assign_int, int_base + output_penalty_code);
4014 primitive("maxdeadcycles", assign_int, int_base + max_dead_cycles_code);
4015 primitive("hangafter", assign_int, int_base + hang_after_code);
4016 primitive("floatingpenalty", assign_int, int_base + floating_penalty_code);
4017 primitive("globaldefs", assign_int, int_base + global_defs_code);
4018 primitive("fam", assign_int, int_base + cur_fam_code);
4019 primitive("escapechar", assign_int, int_base + escape_char_code);
4020 primitive("defaulthyphenchar", assign_int, int_base + default_hyphen_char_code);
4021 primitive("defaultskewchar", assign_int, int_base + default_skew_char_code);
4022 primitive("endlinechar", assign_int, int_base + end_line_char_code);
4023 primitive("newlinechar", assign_int, int_base + new_line_char_code);
4024 primitive("language", assign_int, int_base + language_code);
4025 primitive("lefthyphenmin", assign_int, int_base + left_hyphen_min_code);
4026 primitive("righthyphenmin", assign_int, int_base + right_hyphen_min_code);
4027 primitive("holdinginserts", assign_int, int_base + holding_inserts_code);
4028 primitive("errorcontextlines", assign_int, int_base + error_context_lines_code);
4029 primitive("parindent", assign_dimen, dimen_base + par_indent_code);
4030 primitive("mathsurround", assign_dimen, dimen_base + math_surround_code);
4031 primitive("lineskiplimit", assign_dimen, dimen_base + line_skip_limit_code);
4032 primitive("hsize", assign_dimen, dimen_base + hsize_code);
4033 primitive("vsize", assign_dimen, dimen_base + vsize_code);
4034 primitive("maxdepth", assign_dimen, dimen_base + max_depth_code);
4035 primitive("splitmaxdepth", assign_dimen, dimen_base + split_max_depth_code);
4036 primitive("boxmaxdepth", assign_dimen, dimen_base + box_max_depth_code);
4037 primitive("hfuzz", assign_dimen, dimen_base + hfuzz_code);
4038 primitive("vfuzz", assign_dimen, dimen_base + vfuzz_code);
4039 primitive("delimitershortfall", assign_dimen, dimen_base + delimiter_shortfall_code);
4040 primitive("nulldelimiterspace", assign_dimen, dimen_base + null_delimiter_space_code);
4041 primitive("scriptspace", assign_dimen, dimen_base + script_space_code);
4042 primitive("predisplaysize", assign_dimen, dimen_base + pre_display_size_code);
4043 primitive("displaywidth", assign_dimen, dimen_base + display_width_code);
4044 primitive("displayindent", assign_dimen, dimen_base + display_indent_code);
4045 primitive("overfullrule", assign_dimen, dimen_base + overfull_rule_code);
4046 primitive("hangindent", assign_dimen, dimen_base + hang_indent_code);
4047 primitive("hoffset", assign_dimen, dimen_base + h_offset_code);
4048 primitive("voffset", assign_dimen, dimen_base + v_offset_code);
4049 primitive("emergencystretch", assign_dimen, dimen_base + emergency_stretch_code);
4050 primitive(" ", ex_space, 0);
4051 primitive("/", ital_corr, 0);
4052 primitive("accent", accent, 0);
4053 primitive("advance", advance, 0);
4054 primitive("afterassignment", after_assignment, 0);
4055 primitive("aftergroup", after_group, 0);
4056 primitive("begingroup", begin_group, 0);
4057 primitive("char", char_num, 0);
4058 primitive("csname", cs_name, 0);
4059 primitive("delimiter", delim_num, 0);
4060 primitive("divide", divide, 0);
4061 primitive("endcsname", end_cs_name, 0);
4062 primitive("endgroup", end_group, 0);
4063 text(frozen_end_group) = make_string_pool("endgroup");
4064 eqtb[frozen_end_group] = eqtb[cur_val];
4065 primitive("expandafter", expand_after, 0);
4066 primitive("font", def_font, 0);
4067 primitive("fontdimen", assign_font_dimen, 0);
4068 primitive("halign", halign, 0);
4069 primitive("hrule", hrule, 0);
4070 primitive("ignorespaces", ignore_spaces, 0);
4071 primitive("insert", insert, 0);
4072 primitive("mark", mark, 0);
4073 primitive("mathaccent", math_accent, 0);
4074 primitive("mathchar", math_char_num, 0);
4075 primitive("mathchoice", math_choice, 0);
4076 primitive("multiply", multiply, 0);
4077 primitive("noalign", no_align, 0);
4078 primitive("noboundary", no_boundary, 0);
4079 primitive("noexpand", no_expand, 0);
4080 primitive("nonscript", non_script, 0);
4081 primitive("omit", omit, 0);
4082 primitive("parshape", set_shape, 0);
4083 primitive("penalty", break_penalty, 0);
4084 primitive("prevgraf", set_prev_graf, 0);
4085 primitive("radical", radical, 0);
4086 primitive("read", read_to_cs, 0);
4087 primitive("relax", relax, 256);
4088 text(frozen_relax) = make_string_pool("relax");
4089 eqtb[frozen_relax] = eqtb[cur_val];
4090 primitive("setbox", set_box, 0);
4091 primitive("the", the, 0);
4092 primitive("toks", toks_register, 0);
4093 primitive("vadjust", vadjust, 0);
4094 primitive("valign", valign, 0);
4095 primitive("vcenter", vcenter, 0);
4096 primitive("vrule", vrule, 0);
4097 primitive("par", par_end, 256);
4099 par_token = cs_token_flag + par_loc;
4100 primitive("input", input, 0);
4101 primitive("endinput", input, 1);
4102 primitive("topmark", top_bot_mark, 0);
4103 primitive("firstmark", top_bot_mark, 1);
4104 primitive("botmark", top_bot_mark, 2);
4105 primitive("splitfirstmark", top_bot_mark, 3);
4106 primitive("splitbotmark", top_bot_mark, 4);
4107 primitive("count", tex_register, 0);
4108 primitive("dimen", tex_register, 1);
4109 primitive("skip", tex_register, 2);
4110 primitive("muskip", tex_register, 3);
4111 primitive("spacefactor", set_aux, 102);
4112 primitive("prevdepth", set_aux, 1);
4113 primitive("deadcycles", set_page_int, 0);
4114 primitive("insertpenalties", set_page_int, 1);
4115 primitive("wd", set_box_dimen, 1);
4116 primitive("ht", set_box_dimen, 3);
4117 primitive("dp", set_box_dimen, 2);
4118 primitive("lastpenalty", last_item, 0);
4119 primitive("lastkern", last_item, 1);
4120 primitive("lastskip", last_item, 2);
4121 primitive("inputlineno", last_item, 3);
4122 primitive("badness", last_item, 4);
4123 primitive("number", convert, 0);
4124 primitive("romannumeral", convert, 1);
4125 primitive("string", convert, 2);
4126 primitive("meaning", convert, 3);
4127 primitive("fontname", convert, 4);
4128 primitive("jobname", convert, 5);
4129 primitive("if", if_test, 0);
4130 primitive("ifcat", if_test, 1);
4131 primitive("ifnum", if_test, 2);
4132 primitive("ifdim", if_test, 3);
4133 primitive("ifodd", if_test, 4);
4134 primitive("ifvmode", if_test, 5);
4135 primitive("ifhmode", if_test, 6);
4136 primitive("ifmmode", if_test, 7);
4137 primitive("ifinner", if_test, 8);
4138 primitive("ifvoid", if_test, 9);
4139 primitive("ifhbox", if_test, 10);
4140 primitive("ifvbox", if_test, 11);
4141 primitive("ifx", if_test, 12);
4142 primitive("ifeof", if_test, 13);
4143 primitive("iftrue", if_test, 14);
4144 primitive("iffalse", if_test, 15);
4145 primitive("ifcase", if_test, 16);
4146 primitive("fi", fi_or_else, 2);
4147 text(frozen_fi) = make_string_pool("fi");
4148 eqtb[frozen_fi] = eqtb[cur_val];
4149 primitive("or", fi_or_else, 4);
4150 primitive("else", fi_or_else, 3);
4151 primitive("nullfont", set_font, 0);
4152 text(frozen_null_font) = 795;
4153 eqtb[frozen_null_font] = eqtb[cur_val];
4154 primitive("span", tab_mark, 256);
4155 primitive("cr", car_ret, 257);
4156 text(frozen_cr) = make_string_pool("cr");
4157 eqtb[frozen_cr] = eqtb[cur_val];
4158 primitive("crcr", car_ret, 258);
4159 text(frozen_end_template) = make_string_pool("endtemplate");
4160 text(frozen_endv) = make_string_pool("endtemplate");
4161 eq_type(frozen_endv) = endv;
4162 equiv(frozen_endv) = null_list;
4163 eq_level(frozen_endv) = level_one;
4164 eqtb[frozen_end_template] = eqtb[frozen_endv];
4165 eq_type(frozen_end_template) = end_template;
4166 primitive("pagegoal", set_page_dimen, 0);
4167 primitive("pagetotal", set_page_dimen, 1);
4168 primitive("pagestretch", set_page_dimen, 2);
4169 primitive("pagefilstretch", set_page_dimen, 3);
4170 primitive("pagefillstretch", set_page_dimen, 4);
4171 primitive("pagefilllstretch", set_page_dimen, 5);
4172 primitive("pageshrink", set_page_dimen, 6);
4173 primitive("pagedepth", set_page_dimen, 7);
4174 primitive("end", end_match, 0);
4175 primitive("dump", stop, 1);
4176 primitive("hskip", hskip, 4);
4177 primitive("hfil", hskip, 0);
4178 primitive("hfill", hskip, 1);
4179 primitive("hss", hskip, 2);
4180 primitive("hfilneg", hskip, 3);
4181 primitive("vskip", vskip, 4);
4182 primitive("vfil", vskip, 0);
4183 primitive("vfill", vskip, 1);
4184 primitive("vss", vskip, 2);
4185 primitive("vfilneg", vskip, 3);
4186 primitive("mskip", mskip, 5);
4187 primitive("kern", kern, 1);
4188 primitive("mkern", mkern, 99);
4189 primitive("moveleft", hmove, 1);
4190 primitive("moveright", hmove, 0);
4191 primitive("raise", vmove, 1);
4192 primitive("lower", vmove, 0);
4193 primitive("box", make_box, 0);
4194 primitive("copy", make_box, 1);
4195 primitive("lastbox", make_box, 2);
4196 primitive("vsplit", make_box, 3);
4197 primitive("vtop", make_box, 4);
4198 primitive("vbox", make_box, 5);
4199 primitive("hbox", make_box, 106);
4200 primitive("shipout", leader_ship, 99);
4201 primitive("leaders", leader_ship, 100);
4202 primitive("cleaders", leader_ship, 101);
4203 primitive("xleaders", leader_ship, 102);
4204 primitive("indent", start_par, 1);
4205 primitive("noindent", start_par, 0);
4206 primitive("unpenalty", remove_item, 12);
4207 primitive("unkern", remove_item, 11);
4208 primitive("unskip", remove_item, 10);
4209 primitive("unhbox", un_hbox, 0);
4210 primitive("unhcopy", un_hbox, 1);
4211 primitive("unvbox", un_vbox, 0);
4212 primitive("unvcopy", un_vbox, 1);
4213 primitive("-", discretionary, 1);
4214 primitive("discretionary", discretionary, 0);
4215 primitive("eqno", eq_no, 0);
4216 primitive("leqno", eq_no, 1);
4217 primitive("mathord", math_comp, 16);
4218 primitive("mathop", math_comp, 17);
4219 primitive("mathbin", math_comp, 18);
4220 primitive("mathrel", math_comp, 19);
4221 primitive("mathopen", math_comp, 20);
4222 primitive("mathclose", math_comp, 21);
4223 primitive("mathpunct", math_comp, 22);
4224 primitive("mathinner", math_comp, 23);
4225 primitive("underline", math_comp, 26);
4226 primitive("overline", math_comp, 27);
4227 primitive("displaylimits", limit_switch, 0);
4228 primitive("limits", limit_switch, 1);
4229 primitive("nolimits", limit_switch, 2);
4230 primitive("displaystyle", math_style, 0);
4231 primitive("textstyle", math_style, 2);
4232 primitive("scriptstyle", math_style, 4);
4233 primitive("scriptscriptstyle", math_style, 6);
4234 primitive("above", above, 0);
4235 primitive("over", above, 1);
4236 primitive("atop", above, 2);
4237 primitive("abovewithdelims", above, 3);
4238 primitive("overwithdelims", above, 4);
4239 primitive("atopwithdelims", above, 5);
4240 primitive("left", left_right, 30);
4241 primitive("right", left_right, 31);
4242 text(frozen_right) = make_string_pool("right");
4243 eqtb[frozen_right] = eqtb[cur_val];
4244 primitive("long", prefix, 1);
4245 primitive("outer", prefix, 2);
4246 primitive("global", prefix, 4);
4247 primitive("def", def, 0);
4248 primitive("gdef", def, 1);
4249 primitive("edef", def, 2);
4250 primitive("xdef", def, 3);
4251 primitive("let", let, 0);
4252 primitive("futurelet", let, 1);
4253 primitive("chardef", shorthand_def, 0);
4254 primitive("mathchardef", shorthand_def, 1);
4255 primitive("countdef", shorthand_def, 2);
4256 primitive("dimendef", shorthand_def, 3);
4257 primitive("skipdef", shorthand_def, 4);
4258 primitive("muskipdef", shorthand_def, 5);
4259 primitive("toksdef", shorthand_def, 6);
4260 primitive("catcode", def_code, (hash_size + 1883));
4261 primitive("mathcode", def_code, (hash_size + 2907));
4262 primitive("lccode", def_code, (hash_size + 2139));
4263 primitive("uccode", def_code, (hash_size + 2395));
4264 primitive("sfcode", def_code, (hash_size + 2651));
4265 primitive("delcode", def_code, (hash_size + 3474));
4266 primitive("textfont", def_family, (hash_size + 1835));
4267 primitive("scriptfont", def_family, (hash_size + 1851));
4268 primitive("scriptscriptfont", def_family, (hash_size + 1867));
4269 primitive("hyphenation", hyph_data, 0);
4270 primitive("patterns", hyph_data, 1);
4271 primitive("hyphenchar", assign_font_int, 0);
4272 primitive("skewchar", assign_font_int, 1);
4273 primitive("batchmode", set_interaction, 0);
4274 primitive("nonstopmode", set_interaction, 1);
4275 primitive("scrollmode", set_interaction, 2);
4276 primitive("errorstopmode", set_interaction, 3);
4277 primitive("openin", in_stream, 1);
4278 primitive("closein", in_stream, 0);
4279 primitive("message", message, 0);
4280 primitive("errmessage", message, 1);
4281 primitive("lowercase", case_shift, (hash_size + 2139));
4282 primitive("uppercase", case_shift, (hash_size + 2395));
4283 primitive("show", xray, 0);
4284 primitive("showbox", xray, 1);
4285 primitive("showthe", xray, 2);
4286 primitive("showlists", xray, 3);
4287 primitive("openout", extension, 0);
4288 primitive("write", extension, 1);
4289 write_loc = cur_val;
4290 primitive("closeout", extension, 2);
4291 primitive("special", extension, 3);
4292 primitive("immediate", extension, 4);
4293 primitive("setlanguage", extension, 5);
4294 no_new_control_sequence = true;