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
24 #define BEGINFMTCHECKSUM 367403084L
25 #define ENDFMTCHECKSUM 69069L
27 extern clock_t start_time, main_time, finish_time;
30 void do_initex (void);
34 void initialize (void)
38 integer flag; /* bkph */
40 #ifndef ALLOCATEHYPHEN
46 for (i = 0; i <= 255; i++)
50 xchr[32] = ' '; xchr[33] = '!'; xchr[34] = '"'; xchr[35] = '#';
51 xchr[36] = '$'; xchr[37] = '%'; xchr[38] = '&'; xchr[39] = '\'';
52 xchr[40] = '('; xchr[41] = ')'; xchr[42] = '*'; xchr[43] = '+';
53 xchr[44] = ','; xchr[45] = '-'; xchr[46] = '.'; xchr[47] = '/';
54 xchr[48] = '0'; xchr[49] = '1'; xchr[50] = '2'; xchr[51] = '3';
55 xchr[52] = '4'; xchr[53] = '5'; xchr[54] = '6'; xchr[55] = '7';
56 xchr[56] = '8'; xchr[57] = '9'; xchr[58] = ':'; xchr[59] = ';';
57 xchr[60] = '<'; xchr[61] = '='; xchr[62] = '>'; xchr[63] = '?';
58 xchr[64] = '@'; xchr[65] = 'A'; xchr[66] = 'B'; xchr[67] = 'C';
59 xchr[68] = 'D'; xchr[69] = 'E'; xchr[70] = 'F'; xchr[71] = 'G';
60 xchr[72] = 'H'; xchr[73] = 'I'; xchr[74] = 'J'; xchr[75] = 'K';
61 xchr[76] = 'L'; xchr[77] = 'M'; xchr[78] = 'N'; xchr[79] = 'O';
62 xchr[80] = 'P'; xchr[81] = 'Q'; xchr[82] = 'R'; xchr[83] = 'S';
63 xchr[84] = 'T'; xchr[85] = 'U'; xchr[86] = 'V'; xchr[87] = 'W';
64 xchr[88] = 'X'; xchr[89] = 'Y'; xchr[90] = 'Z'; xchr[91] = '[';
65 xchr[92] = '\\'; xchr[93] = ']'; xchr[94] = '^'; xchr[95] = '_';
66 xchr[96] = '`'; xchr[97] = 'a'; xchr[98] = 'b'; xchr[99] = 'c';
67 xchr[100] = 'd'; xchr[101] = 'e'; xchr[102] = 'f'; xchr[103] = 'g';
68 xchr[104] = 'h'; xchr[105] = 'i'; xchr[106] = 'j'; xchr[107] = 'k';
69 xchr[108] = 'l'; xchr[109] = 'm'; xchr[110] = 'n'; xchr[111] = 'o';
70 xchr[112] = 'p'; xchr[113] = 'q'; xchr[114] = 'r'; xchr[115] = 's';
71 xchr[116] = 't'; xchr[117] = 'u'; xchr[118] = 'v'; xchr[119] = 'w';
72 xchr[120] = 'x'; xchr[121] = 'y'; xchr[122] = 'z'; xchr[123] = '{';
73 xchr[124] = '|'; xchr[125] = '}'; xchr[126] = '~';
75 for (i = 0; i <= 31; i++)
78 for (i = 127; i <= 255; i++)
83 for (i = 0; i <= 255; i++)
87 for (i = 128; i <= 255 ; i++)
90 for (i = 0; i <= 126; i++)
94 for (i = 0; i <= 255; i++)
95 xord[xchr[i]] = (char) i;
103 for (k = 0; k < 256; k++)
112 show_line("Inverted mapping xord[] pairs:\n", 0);
114 for (k = 0; k < 256; k++)
118 sprintf(log_line, "%d => %d\n", k, xord[k]);
119 show_line(log_line, 0);
125 if (interaction < batch_mode)
126 interaction = error_stop_mode;
128 deletions_allowed = true;
129 set_box_allowed = true;
132 use_err_help = false;
134 OK_to_interrupt = true;
137 was_mem_end = mem_min;
138 /* was_lo_max = mem_min; */
139 was_lo_max = mem_bot;
140 /* was_hi_min = mem_max; */
141 was_hi_min = mem_top;
150 cur_list.aux_field.cint = ignore_depth;
155 page_tail = page_head;
162 last_glue = empty_flag;
168 for (k = int_base; k <= eqtb_size; k++)
169 xeq_level[k] = level_one;
171 no_new_control_sequence = true;
175 for (k = hash_base + 1; k <= undefined_control_sequence - 1; k++)
176 hash[k] = hash[hash_base];
194 for (k = 0; k <= 16; k++)
202 for (k = 0; k <= font_max; k++)
203 font_used[k] = false;
205 null_character.b0 = 0;
206 null_character.b1 = 0;
207 null_character.b2 = 0;
208 null_character.b3 = 0;
214 doing_leaders = false;
217 half_buf = dvi_buf_size / 2;
218 dvi_limit = dvi_buf_size;
227 empty_field.v.RH = 0;
228 empty_field.v.LH = 0;
229 null_delimiter.b0 = 0;
230 null_delimiter.b1 = 0;
231 null_delimiter.b2 = 0;
232 null_delimiter.b3 = 0;
241 /* *not* OK with ALLOCATEHYPHEN, since may not be allocated yet */
242 #ifndef ALLOCATEHYPHEN
243 for (z = 0; z <= hyphen_prime; z++)
251 output_active = false;
252 insert_penalties = 0;
253 ligature_present = false;
254 cancel_boundary = false;
259 long_help_seen = false;
262 for (k = 0; k <= 17; k++)
263 write_open[k] = false;
275 /* do the part of initialize() that requires mem_top, mem_max or mem[] */
276 /* do this part after allocating main memory */
279 void initialize_aux (void)
282 was_mem_end = mem_min;
283 /* was_lo_max = mem_min; */
284 was_lo_max = mem_bot;
285 /* was_hi_min = mem_max; */
286 was_hi_min = mem_top;
290 /* max_nest_stack = 0; */
294 cur_list.aux_field.cint = ignore_depth;
297 /* shown_mode = 0; */
298 /* page_contents = 0; */
299 page_tail = page_head;
302 #endif // end of ifdef ALLOCATEMAIN
304 void line_break_ (integer final_widow_penalty)
308 halfword q, r, s, prevs;
309 internal_font_number f;
310 /* small_number j; */
311 int j; /* 95/Jan/7 */
312 /* unsigned char c; */
313 unsigned int c; /* 95/Jan/7 */
314 /* savedbadness = 0; */ /* 96/Feb/9 */
316 pack_begin_line = mode_line;
317 link(temp_head) = link(head);
319 if ((tail >= hi_mem_min))
321 tail_append(new_penalty(inf_penalty));
323 else if (type(tail) != glue_node)
325 tail_append(new_penalty(inf_penalty));
329 type(tail) = penalty_node;
330 delete_glue_ref(glue_ptr(tail));
331 flush_node_list(leader_ptr(tail));
332 penalty(tail) = inf_penalty;
335 link(tail) = new_param_glue(par_fill_skip_code);
336 init_cur_lang = prev_graf % 65536L;
337 init_l_hyf = prev_graf / 4194304L; /* 2^22 */
338 init_r_hyf = (prev_graf / 65536L) % 64;
340 no_shrink_error_yet = true;
342 if ((shrink_order(left_skip) != normal) && (shrink(left_skip) != 0))
344 left_skip = finite_shrink(left_skip);
347 if ((shrink_order(right_skip) != normal) && (shrink(right_skip) != 0))
349 right_skip = finite_shrink(right_skip);
354 background[1] = width(q) + width(r);
359 background[2 + stretch_order(q)] = stretch(q);
360 background[2 + stretch_order(r)] = background[2 + stretch_order(r)] + stretch(r);
361 background[6] = shrink(q) + shrink(r);
363 minimum_demerits = 1073741823L; /* 2^30 - 1 *//* 40000000 hex - 1 */
364 minimal_demerits[tight_fit] = 1073741823L;
365 minimal_demerits[decent_fit] = 1073741823L;
366 minimal_demerits[loose_fit] = 1073741823L;
367 minimal_demerits[very_loose_fit] = 1073741823L;
369 if (par_shape_ptr == 0)
370 if (hang_indent == 0)
372 last_special_line = 0;
373 second_width = hsize;
378 last_special_line = abs(hang_after);
382 first_width = hsize - abs(hang_indent);
384 if (hang_indent >= 0)
385 first_indent = hang_indent;
389 second_width = hsize;
396 second_width = hsize - abs(hang_indent);
398 if (hang_indent >= 0)
399 second_indent = hang_indent;
406 last_special_line = info(par_shape_ptr) - 1;
407 second_width = mem[par_shape_ptr + 2 * (last_special_line + 1)].cint;
408 second_indent = mem[par_shape_ptr + 2 * last_special_line + 1].cint;
412 easyline = last_special_line;
414 easyline = empty_flag;
416 threshold = pretolerance;
422 if (tracing_paragraphs > 0)
425 print_nl("@firstpass");
431 first_pass_count++; /* 96 Feb 9 */
435 threshold = tolerance;
437 final_pass = (emergency_stretch <= 0);
440 if (tracing_paragraphs > 0)
447 if (threshold > inf_bad)
460 cur_lang = init_cur_lang;
466 type(q) = unhyphenated;
467 fitness(q) = decent_fit;
470 line_number(q) = prev_graf + 1;
471 total_demerits(q) = 0;
473 active_width[1] = background[1];
474 active_width[2] = background[2];
475 active_width[3] = background[3];
476 active_width[4] = background[4];
477 active_width[5] = background[5];
478 active_width[6] = background[6];
481 printed_node = temp_head;
483 font_in_short_display = 0;
485 cur_p = link(temp_head);
486 auto_breaking = true;
489 while((cur_p != 0) && (link(active) != active))
491 if ((cur_p >= hi_mem_min))
498 active_width[1] = active_width[1] + char_width(f, char_info(f, character(cur_p)));
501 while(!(!(cur_p >= hi_mem_min)));
509 active_width[1] = active_width[1] + width(cur_p);
512 if (subtype(cur_p) == language_node)
514 cur_lang = what_lang(cur_p);
515 lhyf = what_lhm(cur_p);
516 rhyf = what_rhm(cur_p);
523 if ((prevp >= hi_mem_min))
524 try_break(0, unhyphenated);
525 else if ((mem[prevp].hh.b0 < 9))
526 try_break(0, unhyphenated);
527 else if ((type(prevp) == kern_node) && (subtype(prevp) != explicit))
528 try_break(0, unhyphenated);
531 if ((mem[glue_ptr(cur_p)].hh.b1 != 0) && (mem[glue_ptr(cur_p) + 3].cint != 0))
533 glue_ptr(cur_p) = finite_shrink(glue_ptr(cur_p));
537 active_width[1] = active_width[1]+ width(q);
538 active_width[2 + stretch_order(q)] = active_width[2 + stretch_order(q)] + stretch(q);
539 active_width[6] = active_width[6] + shrink(q);
541 if (second_pass && auto_breaking)
550 if ((s >= hi_mem_min))
555 else if (type(s) == ligature_node)
564 else if ((type(s) == kern_node) && (subtype(s) == normal))
566 else if (type(s) == whatsit_node)
568 if (subtype(s) == language_node)
570 cur_lang = what_lang(s);
580 if ((lc_code(c) == (halfword) c) || (uc_hyph > 0)) /* fixed signed tyoe */
589 hyf_char = hyphen_char[hf];
599 if (lhyf + rhyf > 63)
606 if ((s >= hi_mem_min))
611 hyfbchar = character(s);
613 c = hyfbchar; /* unsigned char c; */
627 else if (type(s) == ligature_node)
629 if (font(lig_char(s)) != hf)
635 if (q != 0) /* 94/Mar/23 BUG FIX */
636 hyfbchar = character(q);
638 while (q != 0) /* 94/Mar/23 BUG FIX */
658 hyfbchar = font_bchar[hf];
662 else if ((type(s) == kern_node) && (subtype(s) == normal))
665 hyfbchar = font_bchar[hf];
673 if (hn < lhyf + rhyf)
678 if (!((s >= hi_mem_min)))
684 if (subtype(s) != normal)
709 if (subtype(cur_p) == explicit)
711 if (!(link(cur_p) >= hi_mem_min) && auto_breaking)
712 if (type(link(cur_p)) == glue_node)
713 try_break(0, unhyphenated);
715 active_width[1] = active_width[1] + width(cur_p);
718 active_width[1] = active_width[1] + width(cur_p);
722 f = font(lig_char(cur_p));
723 active_width[1] = active_width[1] + char_width(f, char_info(f, character(lig_char(cur_p))));
728 s = pre_break(cur_p);
732 try_break(ex_hyphen_penalty, hyphenated);
737 if ((s >= hi_mem_min))
740 disc_width = disc_width + char_width(f, char_info(f, character(s)));
746 f = font(lig_char(s));
747 disc_width = disc_width + font_info[width_base[f] + font_info[char_base[f]+ mem[s + 1].hh.b1].qqqq.b0].cint;
754 disc_width = disc_width + width(s);
759 return; // abort_flag set
767 active_width[1] = active_width[1] + disc_width;
768 try_break(hyphen_penalty, hyphenated);
769 active_width[1] = active_width[1] - disc_width;
771 r = replace_count(cur_p);
776 if ((s >= hi_mem_min))
779 active_width[1] = active_width[1] + char_width(f, char_info(f, character(s)));
785 f = font(lig_char(s));
786 active_width[1] = active_width[1] + char_width(f, char_info(f, character(lig_char(s))));
794 active_width[1] = active_width[1] + width(s);
800 return; // abort_flag set
817 auto_breaking = (subtype(cur_p) == 1);
819 if (!(link(cur_p) >= hi_mem_min) && auto_breaking)
820 if (type(link(cur_p)) == glue_node)
821 try_break(0, unhyphenated);
823 active_width[1] = active_width[1] + width(cur_p);
829 try_break(penalty(cur_p), unhyphenated);
839 confusion("paragraph");
840 return; // abort_flag set
852 try_break(eject_penalty, hyphenated);
854 if (link(active) != active)
857 fewest_demerits = 1073741823L; /* 2^30 - 1 */
862 if (total_demerits(r) < fewest_demerits)
864 fewest_demerits = total_demerits(r);
870 while (!(r == active));
872 best_line = line_number(best_bet);
876 goto lab30; /* normal exit */
881 actual_looseness = 0;
887 line_diff = toint(line_number(r)) - toint(best_line);
889 if (((line_diff < actual_looseness) && (looseness <= line_diff)) ||
890 ((line_diff > actual_looseness) && (looseness >= line_diff)))
893 actual_looseness = line_diff;
894 fewest_demerits = total_demerits(r);
896 else if ((line_diff == actual_looseness) && (total_demerits(r) < fewest_demerits))
899 fewest_demerits = total_demerits(r);
905 while (!(r == active));
907 best_line = line_number(best_bet);
910 if ((actual_looseness == looseness) || final_pass)
943 if (tracing_paragraphs > 0)
944 print_nl("@secondpass");
946 threshold = tolerance;
948 second_pass_count++; /* 96 Feb 9 */
949 final_pass = (emergency_stretch <= 0);
954 if (tracing_paragraphs > 0)
955 print_nl("@emergencypass");
957 /* can only get here is \emergencystretch has been set positive */
958 background[2] = background[2] + emergency_stretch;
960 ++final_pass_count; /* 96 Feb 9 */
961 } /* end of if second_pass */
962 } /* end of while(true)do */
963 /* cannot drop through from above loop */
964 lab30: /* common exit point */
969 if (tracing_paragraphs > 0)
971 end_diagnostic(true);
972 normalize_selector();
976 post_line_break(final_widow_penalty);
1000 pack_begin_line = 0;
1003 void prefixed_command (void)
1006 internal_font_number f;
1015 while (cur_cmd == prefix)
1017 if (!odd(a / cur_chr))
1024 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
1026 if (cur_cmd <= max_non_prefixed_command)
1028 print_err("You can't use a prefix with `");
1029 print_cmd_chr(cur_cmd, cur_chr);
1031 help1("I'll pretend you didn't say \\long or \\outer or \\global.");
1037 if ((cur_cmd != def) && (a % 4 != 0))
1039 print_err("You can't use `");
1041 print_string("' or `");
1043 print_string("' with `");
1044 print_cmd_chr(cur_cmd, cur_chr);
1046 help1("I'll pretend you didn't say \\long or \\outer here.");
1050 if (global_defs != 0)
1051 if (global_defs < 0)
1066 geq_define(cur_font_loc, data, cur_chr);
1068 eq_define(cur_font_loc, data, cur_chr);
1073 if (odd(cur_chr) && !(a >= 4) && (global_defs >= 0))
1079 q = scan_toks(true, e);
1082 geq_define(p, call + (a % 4), def_ref);
1084 eq_define(p, call + (a % 4), def_ref);
1100 while (!(cur_cmd != spacer));
1102 if (cur_tok == other_token + '=')
1106 if (cur_cmd == spacer)
1120 if (cur_cmd >= call)
1121 incr(mem[cur_chr].hh.v.LH);
1124 geq_define(p, cur_cmd, cur_chr);
1126 eq_define(p, cur_cmd, cur_chr);
1137 geq_define(p, relax, 256);
1139 eq_define(p, relax, 256);
1141 scan_optional_equals();
1150 geq_define(p, char_given, cur_val);
1152 eq_define(p, char_given, cur_val);
1156 case math_char_def_code:
1158 scan_fifteen_bit_int();
1161 geq_define(p, math_given, cur_val);
1163 eq_define(p, math_given, cur_val);
1169 scan_eight_bit_int();
1173 case count_def_code:
1175 geq_define(p, assign_int, count_base + cur_val);
1177 eq_define(p, assign_int, count_base + cur_val);
1180 case dimen_def_code:
1182 geq_define(p, assign_dimen, scaled_base + cur_val);
1184 eq_define(p, assign_dimen, scaled_base + cur_val);
1189 geq_define(p, assign_glue, skip_base + cur_val);
1191 eq_define(p, assign_glue, skip_base + cur_val);
1194 case mu_skip_def_code:
1196 geq_define(p, assign_mu_glue, mu_skip_base + cur_val);
1198 eq_define(p, assign_mu_glue, mu_skip_base + cur_val);
1203 geq_define(p, assign_toks, toks_base + cur_val);
1205 eq_define(p, assign_toks, toks_base + cur_val);
1219 if (! scan_keyword("to"))
1221 print_err("Missing `to' inserted");
1222 help2("You should have said `\\read<number> to \\cs'.",
1223 "I'm going to look for the \\cs now.");
1232 geq_define(p, call, cur_val);
1234 eq_define(p, call, cur_val);
1243 if (cur_cmd == toks_register)
1245 scan_eight_bit_int();
1246 p = toks_base + cur_val;
1251 scan_optional_equals();
1257 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
1259 if (cur_cmd != left_brace)
1261 if (cur_cmd == toks_register)
1263 scan_eight_bit_int();
1264 cur_cmd = assign_toks;
1265 cur_chr = toks_base + cur_val;
1268 if (cur_cmd == assign_toks)
1274 geq_define(p, undefined_cs, 0);
1276 eq_define(p, undefined_cs, 0);
1279 incr(mem[q].hh.v.LH);
1282 geq_define(p, call, q);
1284 eq_define(p, call, q);
1292 q = scan_toks(false, false);
1294 if (link(def_ref) == 0)
1297 geq_define(p, undefined_cs, 0);
1299 eq_define(p, undefined_cs, 0);
1301 free_avail(def_ref);
1305 if (p == output_routine_loc)
1307 link(q) = get_avail();
1309 info(q) = right_brace_token + '}';
1311 info(q) = left_brace_token + '{';
1312 link(q) = link(def_ref);
1317 geq_define(p, call, def_ref);
1319 eq_define(p, call, def_ref);
1327 scan_optional_equals();
1331 geq_word_define(p, cur_val);
1333 eq_word_define(p, cur_val);
1340 scan_optional_equals();
1341 scan_dimen(false, false, false);
1344 geq_word_define(p, cur_val);
1346 eq_word_define(p, cur_val);
1351 case assign_mu_glue:
1355 scan_optional_equals();
1357 if (n == assign_mu_glue)
1360 scan_glue(glue_val);
1365 geq_define(p, glue_ref, cur_val);
1367 eq_define(p, glue_ref, cur_val);
1373 if (cur_chr == cat_code_base)
1375 else if (cur_chr == math_code_base)
1376 n = 32768L; /* 2^15 */
1377 else if (cur_chr == sf_code_base)
1378 n = 32767; /* 2^15 - 1*/
1379 else if (cur_chr == del_code_base)
1380 n = 16777215L; /* 2^24 - 1 */
1382 n = 255; /* 2^8 - 1 */
1387 scan_optional_equals();
1390 if (((cur_val < 0) && (p < del_code_base)) ||(cur_val > n))
1392 print_err("Invalid code(");
1395 if (p < del_code_base)
1396 print_string("), should be in the range 0..");
1398 print_string("), should be at most ");
1401 help1("I'm going to use 0 instead of that illegal code value.");
1406 if (p < math_code_base)
1408 geq_define(p, data, cur_val);
1410 eq_define(p, data, cur_val);
1411 else if (p < del_code_base)
1413 geq_define(p, data, cur_val);
1415 eq_define(p, data, cur_val);
1418 geq_word_define(p, cur_val);
1420 eq_word_define(p, cur_val);
1427 scan_four_bit_int();
1429 scan_optional_equals();
1433 geq_define(p, data, cur_val);
1435 eq_define(p, data, cur_val);
1443 do_register_command(a);
1448 scan_eight_bit_int();
1455 scan_optional_equals();
1457 if (set_box_allowed)
1459 scan_box(box_flag + n);
1463 print_err("Improper ");
1464 print_esc("setbox");
1465 help2("Sorry, \\setbox is not allowed after \\halign in a display,",
1466 "or between \\accent and an accented character.");
1480 case set_page_dimen:
1481 alter_page_so_far();
1494 scan_optional_equals();
1502 p = get_node(2 * n + 1);
1505 for (j = 1; j <= n; j++)
1507 scan_dimen(false, false, false);
1508 mem[p + 2 * j - 1].cint = cur_val;
1509 scan_dimen(false, false, false);
1510 mem[p + 2 * j].cint = cur_val;
1515 geq_define(par_shape_loc, shape_ref, p);
1517 eq_define(par_shape_loc, shape_ref, p);
1531 print_err("Patterns can be loaded only by INITEX");
1539 while(!(cur_cmd == right_brace));
1545 new_hyph_exceptions();
1550 case assign_font_dimen:
1552 find_font_dimen(true);
1554 scan_optional_equals();
1555 scan_dimen(false, false, false);
1556 font_info[k].cint = cur_val;
1560 case assign_font_int:
1565 scan_optional_equals();
1569 hyphen_char[f] = cur_val;
1571 skew_char[f] = cur_val;
1579 case set_interaction:
1585 confusion("prefix");
1586 return; // abort_flag set
1592 if (after_token != 0)
1594 cur_tok = after_token;
1600 void bad_formator_pool (char *name, char *defaultname, char *envvar)
1605 sprintf(log_line, "(Perhaps %s is for an older version of TeX)\n", name);
1606 show_line(log_line, 0);
1607 name_of_file[name_length + 1] = '\0';
1608 sprintf(log_line, "(Alternatively, %s may have been corrupted)\n", name_of_file + 1);
1609 show_line(log_line, 0);
1610 name_of_file[name_length + 1] = ' ';
1611 sprintf(log_line, "(Perhaps your %s environment variable is not set correctly)\n", envvar);
1612 show_line(log_line, 0);
1617 if ((s = grabenv(envvar)) != NULL)
1619 sprintf(log_line, "(%s=%s)\n", envvar, s);
1620 show_line(log_line, 0);
1624 sprintf(log_line, "%s environment variable not set\n", envvar);
1625 show_line(log_line, 0);
1634 bool load_fmt_file (void)
1642 if (x != BEGINFMTCHECKSUM) /* magic FMT file start 4C 20 E6 15 hex */
1645 undump_int(x); /* mem_bot */
1650 undump_int(x); /* mem_top */
1653 /* we already read this once earlier to grab mem_top */
1656 sprintf(log_line, "Read from fmt file mem_top = %d TeX words\n", x);
1657 show_line(log_line, 0);
1660 mem = allocate_main_memory(x); /* allocate main memory at this point */
1663 exit(1); /* redundant sanity test ! */
1665 initialize_aux(); /* do `mem' part of initialize */
1666 /* mem = zmem; */ /* update pointer to main memory */
1672 undump_int(x); /* eqtb_size */
1674 if (x != (eqtb_size))
1677 undump_int(x); /* hash_prime */
1679 if (x != hash_prime)
1682 undump_int(x); /* hyphen_prime */
1684 #ifdef ALLOCATEHYPHEN
1685 /* allow format files dumped with arbitrary (prime) hyphenation exceptions */
1686 realloc_hyphen(x); /* reset_hyphen(); */
1690 if (x != hyphen_prime)
1694 undump_int(x); /* pool_size */
1699 #ifdef ALLOCATESTRING
1700 if (x > current_pool_size)
1704 sprintf(log_line, "undump string pool reallocation (%d > %d)\n", x, current_pool_size);
1705 show_line(log_line, 0);
1708 str_pool = realloc_str_pool (x - current_pool_size + increment_pool_size);
1711 if (x > current_pool_size) /* 94/Jan/24 */
1716 sprintf(log_line, "%s%s\n", "---! Must increase the ", "string pool size");
1717 show_line(log_line, 0);
1725 undump_int(x); /* max_strings */
1729 #ifdef ALLOCATESTRING
1730 if (x > current_max_strings)
1734 sprintf(log_line, "undump string pointer reallocation (%d > %d)\n", x, current_max_strings);
1735 show_line(log_line, 0);
1738 str_start = realloc_str_start(x - current_max_strings + increment_max_strings);
1741 if (x > current_max_strings) /* 94/Jan/24 */
1743 if (x > max_strings)
1746 sprintf(log_line, "%s%s\n", "---! Must increase the ", "max strings");
1747 show_line(log_line, 0);
1754 if (undumpthings(str_start[0], str_ptr + 1)) /* undump string ptrs */
1757 if (undumpthings(str_pool[0], pool_ptr)) /* undump string pool */
1760 init_str_ptr = str_ptr;
1761 init_pool_ptr = pool_ptr;
1763 /* undump the dynamic memory - paragraph 1312 in the book */
1767 if ((x < lo_mem_stat_max + 1000) || (x > hi_mem_stat_min - 1))
1776 if ((x < lo_mem_stat_max + 1) || (x > lo_mem_max))
1787 if (undumpthings(mem[p], q + 2 - p))
1790 p = q + node_size(q);
1792 if ((p > lo_mem_max) || ((q >= rlink(q)) && (rlink(q) != rover)))
1797 while (!(q == rover));
1799 if (undumpthings(mem[p], lo_mem_max + 1 - p))
1802 if (mem_min < mem_bot - 2) /* ? splice in block below */
1804 /* or call add_variable_space(mem_bot - (mem_min + 1)) */
1806 show_line("Splicing in mem_min space in undump!\n", 0);
1810 link(mem_min) = 0; /* null */
1811 info(mem_min) = 0; /* null */
1816 link(q) = empty_flag;
1817 node_size(q) = mem_bot - q; /* ? size of block */
1823 if ((x < lo_mem_max + 1) || (x > hi_mem_stat_min))
1832 if ((x < mem_bot) || (x > mem_top))
1840 if (undumpthings(mem[hi_mem_min], mem_end + 1 - hi_mem_min))
1843 undump_int(var_used);
1844 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];
1871 while(!(k > (eqtb_size)));
1876 if ((x < hash_base) || (x > (frozen_control_sequence))) /*96/Jan/10*/
1882 par_token = cs_token_flag + par_loc;
1887 if ((x < hash_base) || (x > (frozen_control_sequence))) /*96/Jan/10*/
1895 if ((x < hash_base) || (x > (frozen_control_sequence))) /*96/Jan/10*/
1908 if ((x < p + 1) || (x > hash_used))
1916 while (!(p == hash_used));
1918 if (undumpthings(hash[hash_used + 1], undefined_control_sequence - 1 - hash_used))
1921 undump_int(cs_count);
1925 sprintf(log_line, "itex undump cs_count %d ", cs_count);
1926 show_line(log_line, 0);
1930 undump_int(x); /* font_mem_size */
1938 sprintf(log_line, "Read from fmt fmem_ptr = %d\n", x);
1939 show_line(log_line, 0);
1942 if (x > current_font_mem_size) /* 93/Nov/28 dynamic allocate font_info */
1946 sprintf(log_line, "Undump realloc font_info (%d > %d)\n", x, current_font_mem_size);
1947 show_line(log_line, 0);
1950 font_info = realloc_font_info (x - current_font_mem_size + increment_font_mem_size);
1953 if (x > current_font_mem_size) /* in case allocation failed 94/Jan/24 */
1955 if (x > font_mem_size)
1958 sprintf(log_line, "%s%s\n", "---! Must increase the ", "font mem size");
1959 show_line(log_line, 0);
1967 if (undumpthings(font_info[0], fmem_ptr))
1971 undump_int(x); /* font_max */
1978 sprintf(log_line, "%s%s\n", "---! Must increase the ", "font max");
1979 show_line(log_line, 0);
1986 frozen_font_ptr = font_ptr; /* remember number of fonts frozen into format */
1988 if (undumpthings(font_check[0], font_ptr + 1))
1991 if (undumpthings(font_size[0], font_ptr + 1))
1994 if (undumpthings(font_dsize[0], font_ptr + 1))
1997 if (undumpthings(font_params[0], font_ptr + 1))
2000 if (undumpthings(hyphen_char[0], font_ptr + 1))
2003 if (undumpthings(skew_char[0], font_ptr + 1))
2006 if (undumpthings(font_name[0], font_ptr + 1))
2009 if (undumpthings(font_area[0], font_ptr + 1))
2012 if (undumpthings(font_bc[0], font_ptr + 1))
2015 if (undumpthings(font_ec[0], font_ptr + 1))
2018 if (undumpthings(char_base[0], font_ptr + 1))
2021 if (undumpthings(width_base[0], font_ptr + 1))
2024 if (undumpthings(height_base[0], font_ptr + 1))
2027 if (undumpthings(depth_base[0], font_ptr + 1))
2030 if (undumpthings(italic_base[0], font_ptr + 1))
2033 if (undumpthings(lig_kern_base[0], font_ptr + 1))
2036 if (undumpthings(kern_base[0], font_ptr + 1))
2039 if (undumpthings(exten_base[0], font_ptr + 1))
2042 if (undumpthings(param_base[0], font_ptr + 1))
2045 if (undumpthings(font_glue[0], font_ptr + 1))
2048 if (undumpthings(bchar_label[0], font_ptr + 1))
2051 if (undumpthings(font_bchar[0], font_ptr + 1))
2054 if (undumpthings(font_false_bchar[0], font_ptr + 1))
2058 /* log not opened yet, so can't show fonts frozen into format */
2059 /* May be able to avoid the following since we switched to */
2060 /* non_address from font_mem_size to 0 96/Jan/15 ??? */
2063 /* deal with fmt files dumped with *different* font_mem_size 93/Nov/29 */
2065 int count = 0, oldfont_mem_size = 0;
2067 for (x = 0; x <= font_ptr; x++)
2069 if (bchar_label[x] > oldfont_mem_size)
2070 oldfont_mem_size = bchar_label[x];
2073 /* somewhat arbitrary sanity check ... */
2074 if (oldfont_mem_size != non_address && oldfont_mem_size > font_max) /* 96/Jan/16 */
2076 for (x = 0; x <= font_ptr; x++)
2078 if (bchar_label[x] == oldfont_mem_size)
2080 /* bchar_label[x] = font_mem_size; */
2081 bchar_label[x] = non_address; /* 96/Jan/16 */
2088 sprintf(log_line, "oldfont_mem_size is %d --- hit %d times. Using non_address %d\n",
2089 oldfont_mem_size, count, non_address);
2090 show_line(log_line, 0);
2095 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2096 /* undump(0)(hyph_size)(hyph_count); */
2100 if ((x < 0) || (x > hyphen_prime))
2106 /* undump hypenation exception tables p.1325 */
2107 for (k = 1; k <= hyph_count; k++)
2112 if ((x < 0) || (x > hyphen_prime))
2121 if ((x < 0) || (x > str_ptr))
2130 if ((x < 0) || (x > max_halfword)) /* mem_top ? no p.1325 */
2137 #ifdef ALLOCATEHYPHEN
2138 /* if user specified new hyphen prime - flush existing exception patterns ! */
2139 /* but, we can reclaim the string storage wasted ... */
2142 if (new_hyphen_prime != 0)
2144 realloc_hyphen(new_hyphen_prime); /* reset_hyphen(); */
2145 hyphen_prime = new_hyphen_prime;
2156 #ifdef ALLOCATETRIES
2159 allocate_tries(x); /* allocate only as much as is needed */
2160 /* trie_size = x; */ /* ??? */
2166 sprintf(log_line, "%s%s\n", "---! Must increase the ", "trie size");
2167 show_line(log_line, 0);
2174 if (is_initex) /* bkph */
2177 if (undumpthings(trie_trl[0], j + 1))
2180 if (undumpthings(trie_tro[0], j + 1))
2183 if (undumpthings(trie_trc[0], j + 1))
2192 if (x > trie_op_size)
2194 sprintf(log_line, "%s%s\n", "---! Must increase the ", "trie op size");
2195 show_line(log_line, 0);
2203 if (is_initex) /* bkph */
2207 if (undumpthings(hyf_distance[1], j))
2210 if (undumpthings(hyf_num[1], j))
2213 if (undumpthings(hyf_next[1], j))
2217 if (is_initex) /* bkph */
2219 for (k = 0; k <= 255; k++)
2232 if ((x < 0) || (x > k - 1))
2241 if ((x < 1) || (x > j))
2247 if (is_initex) /* bkph */
2250 /* j:=j-x; op_start[k]:=qo(j); */
2255 if (is_initex) /* bkph */
2256 trie_not_ready = false;
2261 if ((x < batch_mode) || (x > error_stop_mode))
2264 if (interaction < batch_mode) /* may now set in local.c bkph 94/Jan/8 */
2271 if ((x < 0) || (x > str_ptr))
2279 if ((x != ENDFMTCHECKSUM) || feof(fmt_file))
2285 sprintf(log_line, "(Fatal format file error; I'm stymied)\n");
2286 show_line(log_line, 1);
2289 bad_formator_pool(format_file, "the format file", "TEXFORMATS");
2294 void final_cleanup (void)
2303 while (input_ptr > 0)
2305 if (cur_input.state_field == 0)
2313 while (open_parens > 0)
2319 if (cur_level > level_one)
2322 print_esc("end occurred ");
2323 print_string("inside a group at level ");
2324 print_int(cur_level - 1);
2328 while (cond_ptr != 0)
2331 print_esc("end occurred ");
2332 print_string("when ");
2333 print_cmd_chr('i', cur_if);
2337 print_string("on line ");
2341 print_string(" was incomplete)");
2342 if_line = mem[cond_ptr + 1].cint;
2343 cur_if = mem[cond_ptr].hh.b1;
2344 temp_ptr = cond_ptr;
2345 cond_ptr = mem[cond_ptr].hh.v.RH;
2346 free_node(temp_ptr, 2);
2349 if (history != spotless)
2350 if (((history == warning_issued) || (interaction < error_stop_mode)))
2351 if (selector == term_and_log)
2353 selector = term_only;
2354 print_nl("(see the transcript file for additional information)");
2355 selector = term_and_log;
2363 for (c = 0; c <= 4; c++)
2365 if (cur_mark[c] != 0)
2366 delete_token_ref(cur_mark[c]);
2369 if (last_glue != max_halfword)
2370 delete_glue_ref(last_glue);
2371 store_fmt_file(); // returns a value ?
2376 print_nl("(\\dump is performed only by INITEX)");
2380 void show_frozen (void)
2384 fprintf(log_file, "\n");
2385 fprintf(log_file, "(%d fonts frozen in format file:\n", font_ptr);
2387 for (i = 1; i <= font_ptr; i++)
2390 fprintf(log_file, ", ");
2393 fprintf(log_file, "\n");
2395 n = str_start[font_name[i] + 1] - str_start[font_name[i]];
2397 for (j = 0; j < n; j++)
2399 putc(str_pool[str_start[font_name[i]] + j], log_file);
2403 fprintf(log_file, ") ");
2408 history = fatal_error_stop;
2410 if (ready_already == 314159L)
2415 if ((half_error_line < 30) || (half_error_line > error_line - 15))
2418 if (max_print_line < 60)
2421 if (dvi_buf_size % 8 != 0)
2424 if (mem_bot + 1100 > mem_top)
2427 if (hash_prime > (hash_size + hash_extra))
2430 if (max_in_open >= 128)
2433 if (mem_top < 256 + 11)
2439 if ((mem_min != 0) || (mem_max != mem_top))
2444 if ((mem_min > mem_bot) || (mem_max < mem_top))
2447 if ((min_quarterword > 0) || (max_quarterword < 255))
2450 if ((min_halfword > 0) || (max_halfword < 32767))
2453 if ((min_quarterword < min_halfword) || (max_quarterword > max_halfword))
2456 if ((mem_min < min_halfword) || (mem_max >= max_halfword) || (mem_bot - mem_min >= max_halfword))
2459 if (mem_max > mem_top + mem_extra_high)
2462 if ((0 < min_quarterword) || (font_max > max_quarterword))
2465 #ifdef INCREASEFONTS
2466 if (font_max > 1024)
2472 if ((save_size > max_halfword) || (max_strings > max_halfword))
2475 if (buf_size > max_halfword)
2478 if (max_quarterword - min_quarterword < 255)
2481 if (cs_token_flag + undefined_control_sequence > max_halfword)
2484 if (format_default_length > PATHMAX)
2487 if (max_halfword < (mem_top - mem_min) / 2)
2492 sprintf(log_line, "%s%s%ld\n", "Ouch---my internal constants have been clobbered!",
2493 "---case ", (long) bad);
2494 show_line(log_line, 1);
2497 bad_formator_pool(format_file, "the format file", "TEXFORMATS");
2507 if (!get_strings_started())
2511 init_str_ptr = str_ptr;
2512 init_pool_ptr = pool_ptr;
2513 fix_date_and_time();
2517 ready_already = 314159L;
2520 selector = term_only;
2524 show_line(tex_version, 0);
2529 sprintf(log_line, " (%s %s/Windows 64bit)", application, yandyversion);
2531 sprintf(log_line, " (%s %s/Windows 32bit)", application, yandyversion);
2534 sprintf(log_line, " (%s %s/Linux)", application, yandyversion);
2538 show_line(log_line, 0);
2540 if (format_ident > 0)
2541 slow_print(format_ident);
2550 name_in_progress = false;
2552 output_file_name = 0;
2561 max_open_parens = 0;
2564 max_param_stack = 0;
2566 #ifdef ALLOCATEBUFFER
2567 memset (buffer, 0, current_buf_size);
2569 memset (buffer, 0, buf_size);
2576 cur_input.state_field = 33;
2577 cur_input.start_field = 1;
2578 cur_input.index_field = 0;
2580 cur_input.name_field = 0;
2582 align_state = 1000000L;
2584 if (!init_terminal())
2587 cur_input.limit_field = last;
2591 if ((format_ident == 0) ||
2592 (buffer[cur_input.loc_field] == '&') ||
2593 (buffer[cur_input.loc_field] == '+'))
2595 if (format_ident != 0)
2598 if (!open_fmt_file ())
2601 if (!load_fmt_file ())
2603 #ifdef COMPACTFORMAT
2604 gzclose(gz_fmt_file);
2611 #ifdef COMPACTFORMAT
2612 gzclose(gz_fmt_file);
2617 while ((cur_input.loc_field < cur_input.limit_field) &&
2618 (buffer[cur_input.loc_field] == ' '))
2619 incr(cur_input.loc_field);
2622 if ((end_line_char < 0) || (end_line_char > 255))
2623 decr(cur_input.limit_field);
2625 buffer[cur_input.limit_field] = end_line_char;
2627 fix_date_and_time();
2628 magic_offset = str_start[886] - 9 * ord_noad;
2630 if (interaction == batch_mode)
2631 selector = no_print;
2633 selector = term_only;
2635 if ((cur_input.loc_field < cur_input.limit_field) &&
2636 (cat_code(buffer[cur_input.loc_field]) != escape))
2640 if (show_tfm_flag && log_opened && font_ptr > 0)
2643 main_time = clock();
2647 print_cs_names(stdout, 0);
2652 print_cs_names(stdout, 1);
2656 close_files_and_terminate();
2668 if ((history != 0) && (history != 1))
2678 /* add a block of variable size node space below mem_bot */
2679 void add_variable_space(int size)
2690 mem_min = t - (size + 1); /* first word in new block - 1 */
2692 if (mem_min < mem_start) /* sanity test */
2695 show_line("WARNING: mem_min < mem_start!\n", 0);
2697 mem_min = mem_start;
2702 link(mem_min) = 0; /* insert blank word below ??? */
2703 info(mem_min) = 0; /* insert blank word below ??? */
2708 link(q) = empty_flag;
2709 info(q) = t - q; /* block size */
2714 /**************************************************************************/
2717 /* split out to allow sharing of code from do_initex and newpattern */
2718 void reset_trie (void)
2722 for (k = - (integer) trie_op_size; k <= trie_op_size; k++)
2723 trie_op_hash[k] = 0;
2725 for (k = 0; k <= 255; k++)
2726 trie_used[k] = min_trie_op;
2728 max_op_used = min_trie_op;
2730 trie_not_ready = true;
2734 trie_not_ready = true;
2736 /* borrowed code from initialize() */
2737 void reset_hyphen (void)
2741 for (z = 0; z <= hyphen_prime; z++)
2749 /* split out to allow optimize for space, not time */
2750 void do_initex (void)
2754 /* hyph_pointer z; */
2756 for (k = mem_bot + 1; k <= lo_mem_stat_max; k++)
2761 while (k <= lo_mem_stat_max)
2763 glue_ref_count(k) = 1;
2764 stretch_order(k) = normal;
2765 shrink_order(k) = normal;
2766 k = k + glue_spec_size;
2769 stretch(fil_glue) = 65535L;
2770 stretch_order(fil_glue) = fil;
2771 stretch(fill_glue) = 65535L;
2772 stretch_order(fill_glue) = fill;
2773 stretch(ss_glue) = 65535L;
2774 stretch_order(ss_glue) = fil;
2775 shrink(ss_glue) = 65535L;
2776 shrink_order(ss_glue) = fil;
2777 stretch(fil_neg_glue) = -65536L;
2778 stretch_order(fil_neg_glue) = fil;
2779 rover = lo_mem_stat_max + 1;
2780 link(rover) = empty_flag;
2781 node_size(rover) = block_size;
2782 llink(rover) = rover;
2783 rlink(rover) = rover;
2784 lo_mem_max = rover + block_size;
2785 link(lo_mem_max) = 0;
2786 info(lo_mem_max) = 0;
2788 for (k = hi_mem_stat_min; k <= mem_top; k++)
2789 mem[k] = mem[lo_mem_max];
2791 info(omit_template) = end_template_token;
2792 link(end_span) = max_quarterword + 1;
2794 type(last_active) = hyphenated;
2795 line_number(last_active) = max_halfword;
2796 subtype(last_active) = 0;
2797 subtype(page_ins_head) = 255;
2798 type(page_ins_head) = split_up;
2799 link(mem_top) = page_ins_head;
2800 type(page_head) = glue_node;
2801 subtype(page_head) = normal;
2802 avail = 0; /* avail <- null p.164 */
2804 hi_mem_min = hi_mem_stat_min;
2805 var_used = lo_mem_stat_max + 1 - mem_bot;
2806 dyn_used = hi_mem_stat_usage;
2807 eq_type(undefined_control_sequence) = undefined_cs;
2808 equiv(undefined_control_sequence) = 0;
2809 eq_level(undefined_control_sequence) = level_zero;
2811 for (k = active_base; k <= undefined_control_sequence - 1; k++)
2812 eqtb[k] = eqtb[undefined_control_sequence];
2814 equiv(glue_base) = zero_glue;
2815 eq_level(glue_base) = level_one;
2816 eq_type(glue_base) = glue_ref;
2818 for (k = glue_base + 1; k <= local_base - 1; k++)
2819 eqtb[k] = eqtb[glue_base];
2821 glue_ref_count(zero_glue) = glue_ref_count(zero_glue) + local_base - glue_base;
2824 eq_type(par_shape_loc) = shape_ref;
2825 eq_level(par_shape_loc) = level_one;
2827 for (k = output_routine_loc; k <= toks_base + 255; k++)
2828 eqtb[k] = eqtb[undefined_control_sequence];
2831 eq_type(box_base) = box_ref;
2832 eq_level(box_base) = level_one;
2834 for (k = box_base + 1; k <= box_base + 255; k++)
2835 eqtb[k] = eqtb[box_base];
2837 cur_font = null_font;
2838 eq_type(cur_font_loc) = data;
2839 eq_level(cur_font_loc) = level_one;
2841 for (k = math_font_base; k <= math_font_base + 47; k++)
2842 eqtb[k] = eqtb[cur_font_loc];
2844 equiv(cat_code_base) = 0;
2845 eq_type(cat_code_base) = data;
2846 eq_level(cat_code_base) = level_one;
2848 for (k = cat_code_base; k <= int_base - 1; k++)
2849 eqtb[k] = eqtb[cat_code_base];
2851 for (k = 0; k <= 255; k++)
2853 cat_code(k) = other_char;
2858 cat_code(carriage_return) = car_ret;
2859 cat_code(' ') = spacer;
2860 cat_code('\\') = escape;
2861 cat_code('%') = comment;
2862 cat_code(invalid_code) = invalid_char;
2863 cat_code(null_code) = ignore;
2865 for (k = '0'; k <= '9'; k++)
2866 math_code(k) = k + var_code;
2868 for (k = 'A'; k <= 'Z'; k++)
2870 cat_code(k) = letter;
2871 cat_code(k + 'a' - 'A') = letter;
2872 math_code(k) = k + var_code + 0x100;
2873 math_code(k + 'a' - 'A') = k + 'a' - 'A' + var_code + 0x100;
2874 lc_code(k) = k + 'a' - 'A';
2875 lc_code(k + 'a' - 'A') = k + 'a' - 'A';
2877 uc_code(k + 'a' - 'A') = k;
2881 for (k = int_base; k <= del_code_base - 1; k++)
2887 max_dead_cycles = 25;
2889 end_line_char = carriage_return;
2891 for (k = 0; k <= 255; k++)
2896 for (k = dimen_base; k <= eqtb_size; k++)
2899 hash_used = frozen_control_sequence;
2903 show_line("initex cs_count = 0 ", 0);
2905 eq_type(frozen_dont_expand) = dont_expand;
2906 text(frozen_dont_expand) = 499; /* notexpanded */
2908 font_ptr = null_font;
2910 font_name[null_font] = 795; /* nullfont */
2911 font_area[null_font] = 335; /* "" */
2912 hyphen_char[null_font] = '-';
2913 skew_char[null_font] = -1;
2914 bchar_label[null_font] = non_address;
2915 font_bchar[null_font] = non_char;
2916 font_false_bchar[null_font] = non_char;
2917 font_bc[null_font] = 1;
2918 font_ec[null_font] = 0;
2919 font_size[null_font] = 0;
2920 font_dsize[null_font] = 0;
2921 char_base[null_font] = 0;
2922 width_base[null_font] = 0;
2923 height_base[null_font] = 0;
2924 depth_base[null_font] = 0;
2925 italic_base[null_font] = 0;
2926 lig_kern_base[null_font] = 0;
2927 kern_base[null_font] = 0;
2928 exten_base[null_font] = 0;
2929 font_glue[null_font] = 0;
2930 font_params[null_font] = 7;
2931 param_base[null_font] = -1;
2933 text(frozen_protection) = 1184; /* "inaccessible" */
2934 format_ident = 1251;
2935 text(end_write) = 1290;
2936 eq_level(end_write) = level_one;
2937 eq_type(end_write) = outer_call;
2938 equiv(end_write) = 0;
2944 bool get_strings_started (void)
2953 for (k = 0; k <= 255; k++)
2955 if (((k < ' ') || (k > '~')))
2961 append_char(k + 64);
2964 append_char(k - 64);
2967 append_lc_hex(k / 16);
2968 append_lc_hex(k % 16);
2977 g = load_pool_strings(pool_size - string_vacancies);
2981 fprintf(stdout , "%s\n", "! You have to increase POOLSIZE." );
2991 void sort_avail (void)
2996 p = get_node(1073741824L); /* 2^30 merge adjacent free nodes */
2998 rlink(rover) = empty_flag;
3001 while (p != old_rover)
3014 while (rlink(q) < p)
3018 rlink(p) = rlink(q);
3026 while (rlink(p) != empty_flag)
3028 llink(rlink(p)) = p;
3038 str_number make_string_pool (char *s)
3040 int slen = strlen(s);
3044 return ((str_number)s[0]);
3048 memcpy(str_pool + pool_ptr, s, slen);
3050 return (make_string());
3054 void primitive_ (str_number s, quarterword c, halfword o)
3058 /* small_number l; */
3059 int l; /* 95/Jan/7 */
3062 cur_val = s + single_base;
3066 l = str_start[s + 1] - k; /* small_number l */
3068 for (j = 0; j <= l - 1; j++)
3069 buffer[j] = str_pool[k + j];
3071 cur_val = id_lookup(0, l);
3076 show_line("ERROR: hash entry too large\n", 1);
3082 eq_level(cur_val) = level_one;
3083 eq_type(cur_val) = c;
3090 trie_op_code new_trie_op_ (small_number d, small_number n, trie_op_code v)
3096 h = abs(n + 313 * d + 361 * v + 1009 * cur_lang) % (trie_op_size + trie_op_size) + neg_trie_op_size;
3100 l = trie_op_hash[h];
3104 if (trie_op_ptr == trie_op_size)
3106 overflow("pattern memory ops", trie_op_size);
3107 return 0; // abort_flag set
3110 u = trie_used[cur_lang];
3112 if (u == max_trie_op)
3114 overflow("pattern memory ops per language", max_trie_op - min_trie_op);
3115 return 0; // abort_flag set
3120 trie_used[cur_lang] = u;
3122 if (u > max_op_used)
3125 hyf_distance[trie_op_ptr] = d;
3126 hyf_num[trie_op_ptr] = n;
3127 hyf_next[trie_op_ptr] = v;
3128 trie_op_lang[trie_op_ptr] = cur_lang;
3129 trie_op_hash[h] = trie_op_ptr;
3130 trie_op_val[trie_op_ptr] = u;
3134 if ((hyf_distance[l]== d) && (hyf_num[l]== n) && (hyf_next[l]== v) && (trie_op_lang[l]== cur_lang))
3136 return trie_op_val[l];
3139 if (h > - (integer) trie_op_size)
3146 trie_pointer trie_node_ (trie_pointer p)
3151 /* the 1009, 2718, 3142 are hard-wired constants here (not hyphen_prime) */
3152 /* compute hash value */
3153 h = abs(trie_c[p] + 1009 * trie_o[p] + 2718 * trie_l[p] + 3142 * trie_r[p]) % trie_size;
3165 if ((trie_c[q] == trie_c[p]) && (trie_o[q] == trie_o[p]) &&
3166 (trie_l[q] == trie_l[p]) && (trie_r[q] == trie_r[p]))
3178 trie_pointer compress_trie_ (trie_pointer p)
3184 trie_l[p] = compress_trie(trie_l[p]);
3185 trie_r[p] = compress_trie(trie_r[p]);
3186 return trie_node(p);
3190 void first_fit_ (trie_pointer p)
3206 if (trie_max < h + 256)
3208 if (trie_size <= h + 256)
3210 overflow("pattern memory", trie_size);
3211 /* not dynamic ---- but can be set -h=... from command line in ini-TeX */
3212 return; // abort_flag set
3218 trie_taken[trie_max] = false;
3219 trie_trl[trie_max] = trie_max + 1;
3220 trie_tro[trie_max] = trie_max - 1;
3222 while (!(trie_max == h + 256));
3232 if (trie_trl[h + trie_c[q]] == 0)
3243 trie_taken[h] = true; /* h may be used without ... */
3259 ll = z; /* short ll */
3276 void trie_pack_ (trie_pointer p)
3284 if ((q > 0) && (trie_hash[q]== 0))
3295 void trie_fix_ (trie_pointer p)
3307 trie_trl[z + c] = trie_hash[q];
3308 trie_trc[z + c] = c;
3309 trie_tro[z + c] = trie_o[p];
3319 void new_patterns (void)
3321 /* ******************************************************************* */
3322 /* was small_number k, l; in 3.141 */
3324 /* ******************************************************************* */
3330 int c; /* 95/Jan/7 */
3332 if (!trie_not_ready) /* new stuff */
3337 show_line("Resetting patterns\n", 0);
3339 reset_trie(); /* RESET PATTERNS - 93/Nov/26 */
3341 if (reset_exceptions)
3344 show_line("Resetting exceptions\n", 0);
3346 reset_hyphen(); /* RESET HYPHENEXCEPTIONS - 93/Nov/26 */
3350 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
3357 digitsensed = false;
3367 if (digitsensed || (cur_chr < '0') || (cur_chr > '9'))
3373 cur_chr = lc_code(cur_chr);
3377 print_err("Nonletter");
3378 help1("(See Appendix H.)");
3388 digitsensed = false;
3393 hyf[k] = cur_chr - '0';
3413 v = new_trie_op(k - l, hyf[l], v);
3430 while ((p > 0) && (c > trie_c[p])) {
3436 if ((p == 0) || (c < trie_c[p]))
3438 if (trie_ptr == trie_size)
3440 overflow("pattern memory", trie_size); /* pattern memory - NOT DYNAMIC */
3441 /* not dynamic ---- but can be set -h=... from command line in ini-TeX */
3442 return; // abort_flag set
3446 trie_r[trie_ptr] = p;
3456 trie_o[p] = min_trie_op;
3461 if (trie_o[q]!= min_trie_op)
3463 print_err("Duplicate pattern");
3464 help1("(See Appendix H.)");
3471 if (cur_cmd == right_brace)
3476 digitsensed = false;
3482 print_esc("patterns");
3483 help1("(See Appendix H.)");
3493 print_err("Too late for ");
3494 print_esc("patterns");
3495 help1("All patterns must be given before typesetting begins.");
3497 link(garbage) = scan_toks(false, false);
3498 flush_list(def_ref);
3502 void init_trie (void)
3505 /* integer j, k, t; */
3507 int t; /* 95/Jan/7 */
3510 op_start[0] = - (integer) min_trie_op;
3512 for (j = 1; j <= 255; j++)
3514 op_start[j] = op_start[j - 1] + trie_used[j - 1];
3517 for (j = 1; j <= trie_op_ptr; j++)
3519 trie_op_hash[j] = op_start[trie_op_lang[j]] + trie_op_val[j];
3522 for (j = 1; j <= trie_op_ptr; j++)
3524 while (trie_op_hash[j] > j)
3526 k = trie_op_hash[j];
3527 t = hyf_distance[k];
3528 hyf_distance[k] = hyf_distance[j];
3529 hyf_distance[j] = t;
3531 hyf_num[k] = hyf_num[j];
3534 hyf_next[k] = hyf_next[j];
3536 trie_op_hash[j] = trie_op_hash[k];
3537 trie_op_hash[k] = k;
3541 for (p = 0; p <= trie_size; p++)
3546 trie_l[0] = compress_trie(trie_l[0]);
3548 for (p = 0; p <= trie_ptr; p++)
3553 for (p = 0; p <= 255; p++)
3555 trie_min[p] = p + 1;
3563 first_fit(trie_l[0]);
3564 trie_pack(trie_l[0]);
3569 for (r = 0; r <= 256; r++)
3572 trie_tro[r] = min_trie_op;
3579 trie_fix(trie_l[0]);
3587 trie_tro[r] = min_trie_op;
3593 while(!(r > trie_max));
3597 trie_not_ready = false;
3603 void store_fmt_file (void)
3611 show_line("! \\dump is performed only by INITEX\n", 1);
3614 show_line(" (Use -i on the command line)\n", 0);
3622 print_err("You can't dump inside a group");
3623 help1("`{...\\dump}' is a no-no.");
3627 selector = new_string;
3628 print_string(" (format=");
3638 if (interaction == 0)
3639 selector = log_only;
3641 selector = term_and_log;
3644 format_ident = make_string();
3645 pack_job_name(".fmt");
3647 while(!w_open_out(fmt_file))
3649 prompt_file_name("format file name", ".fmt");
3652 print_nl("Beginning to dump on file ");
3653 slow_print(w_make_name_string(fmt_file));
3656 slow_print(format_ident);
3658 dump_int(BEGINFMTCHECKSUM); /* magic FMT file start 4C 20 E6 15 hex */
3662 dump_int(eqtb_size);
3663 dump_int(hash_prime);
3664 dump_int(hyphen_prime); /* bkph */
3668 if (dumpthings(str_start[0], str_ptr + 1))
3671 if (dumpthings(str_pool[0], pool_ptr))
3676 print_string(" strings of total length ");
3677 print_int(pool_ptr);
3681 dump_int(lo_mem_max);
3689 if (dumpthings(mem[p], q + 2 - p))
3693 var_used = var_used + q - p;
3694 p = q + node_size(q);
3697 while (!(q == rover));
3699 var_used = var_used + lo_mem_max - p;
3700 dyn_used = mem_end + 1 - hi_mem_min;
3702 if (dumpthings(mem[p], lo_mem_max + 1 - p))
3705 x = x + lo_mem_max + 1 - p;
3706 dump_int(hi_mem_min);
3709 if (dumpthings(mem[hi_mem_min], mem_end + 1 - hi_mem_min))
3712 x = x + mem_end + 1 - hi_mem_min;
3725 print_string(" memory locations dumped; current usage is ");
3726 print_int(var_used);
3728 print_int(dyn_used);
3736 while (j < (int_base - 1))
3738 if ((equiv(j) == equiv(j + 1)) &&
3739 (eq_type(j) == eq_type(j + 1)) &&
3740 (eq_level(j) == eq_level(j + 1)))
3750 while (j < (int_base - 1))
3752 if ((equiv(j) != equiv(j + 1)) ||
3753 (eq_type(j) != eq_type(j + 1)) ||
3754 (eq_level(j) != eq_level(j + 1)))
3761 if (dumpthings(eqtb[k], l - k))
3767 while (!(k == (int_base)));
3773 while (j < (eqtb_size))
3775 if (eqtb[j].cint == eqtb[j + 1].cint)
3780 l = (eqtb_size + 1);
3786 while (j < (eqtb_size))
3788 if (eqtb[j].cint != eqtb[j + 1].cint)
3795 if (dumpthings(eqtb[k], l - k))
3801 while (!(k > (eqtb_size)));
3804 dump_int(write_loc);
3806 dump_int(hash_used);
3807 cs_count = frozen_control_sequence - 1 - hash_used;
3811 sprintf(log_line, "itex cs_count %d hash_size %d hash_extra %d hash_used %d",
3812 cs_count, hash_size, hash_extra, hash_used);
3813 show_line(log_line, 0);
3816 for (p = hash_base; p <= hash_used; p++)
3826 sprintf(log_line, "itex cs_count++ ");
3827 show_line(log_line, 0);
3832 if (dumpthings(hash[hash_used + 1], undefined_control_sequence - 1 - hash_used))
3837 print_int(cs_count);
3838 print_string(" multiletter control sequences");
3843 if (dumpthings(font_info[0], fmem_ptr))
3848 if (dumpthings(font_check[0], font_ptr + 1))
3851 if (dumpthings(font_size[0], font_ptr + 1))
3854 if (dumpthings(font_dsize[0], font_ptr + 1))
3857 if (dumpthings(font_params[0], font_ptr + 1))
3860 if (dumpthings(hyphen_char[0], font_ptr + 1))
3863 if (dumpthings(skew_char[0], font_ptr + 1))
3866 if (dumpthings(font_name[0], font_ptr + 1))
3869 if (dumpthings(font_area[0], font_ptr + 1))
3872 if (dumpthings(font_bc[0], font_ptr + 1))
3875 if (dumpthings(font_ec[0], font_ptr + 1))
3878 if (dumpthings(char_base[0], font_ptr + 1))
3881 if (dumpthings(width_base[0], font_ptr + 1))
3884 if (dumpthings(height_base[0], font_ptr + 1))
3887 if (dumpthings(depth_base[0], font_ptr + 1))
3890 if (dumpthings(italic_base[0], font_ptr + 1))
3893 if (dumpthings(lig_kern_base[0], font_ptr + 1))
3896 if (dumpthings(kern_base[0], font_ptr + 1))
3899 if (dumpthings(exten_base[0], font_ptr + 1))
3902 if (dumpthings(param_base[0], font_ptr + 1))
3905 if (dumpthings(font_glue[0], font_ptr + 1))
3908 if (dumpthings(bchar_label[0], font_ptr + 1))
3911 if (dumpthings(font_bchar[0], font_ptr + 1))
3914 if (dumpthings(font_false_bchar[0], font_ptr + 1))
3917 for (k = 0; k <= font_ptr; k++)
3921 print(font_id_text(k));
3923 print_file_name(font_name[k], font_area[k], 335);
3925 if (font_size[k] != font_dsize[k])
3927 print_string(" at ");
3928 print_scaled(font_size[k]);
3935 print_int(fmem_ptr - 7);
3936 print_string(" words of font info for ");
3937 print_int(font_ptr - 0);
3938 print_string(" preloaded font");
3943 dump_int(hyph_count);
3945 for (k = 0; k <= hyphen_prime; k++)
3947 if (hyph_word[k]!= 0)
3950 dump_int(hyph_word[k]);
3951 dump_int(hyph_list[k]);
3956 print_int(hyph_count);
3957 print_string(" hyphenation exception");
3959 if (hyph_count != 1)
3967 if (dumpthings(trie_trl[0], trie_max + 1))
3970 if (dumpthings(trie_tro[0], trie_max + 1))
3973 if (dumpthings(trie_trc[0], trie_max + 1))
3976 dump_int(trie_op_ptr);
3978 if (dumpthings(hyf_distance[1], trie_op_ptr))
3981 if (dumpthings(hyf_num[1], trie_op_ptr))
3984 if (dumpthings(hyf_next[1], trie_op_ptr))
3987 print_nl("Hyphenation trie of length ");
3988 print_int(trie_max);
3989 print_string(" has ");
3990 print_int(trie_op_ptr);
3991 print_string(" op");
3993 if (trie_op_ptr != 1)
3996 print_string(" out of ");
3997 print_int(trie_op_size);
3999 for (k = 255; k >= 0; k--)
4001 if (trie_used[k] > 0)
4004 print_int(trie_used[k]);
4005 print_string(" for language ");
4008 dump_int(trie_used[k]);
4012 dump_int(interaction);
4013 dump_int(format_ident);
4014 dump_int(ENDFMTCHECKSUM);
4017 #ifdef COMPACTFORMAT
4018 gzclose(gz_fmt_file);
4027 void init_prim (void)
4029 no_new_control_sequence = false;
4030 primitive("lineskip", assign_glue, glue_base + line_skip_code);
4031 primitive("baselineskip", assign_glue, glue_base + baseline_skip_code);
4032 primitive("parskip", assign_glue, glue_base + par_skip_code);
4033 primitive("abovedisplayskip", assign_glue, glue_base + above_display_skip_code);
4034 primitive("belowdisplayskip", assign_glue, glue_base + below_display_skip_code);
4035 primitive("abovedisplayshortskip", assign_glue, glue_base + above_display_short_skip_code);
4036 primitive("belowdisplayshortskip", assign_glue, glue_base + below_display_short_skip_code);
4037 primitive("leftskip", assign_glue, glue_base + left_skip_code);
4038 primitive("rightskip", assign_glue, glue_base + right_skip_code);
4039 primitive("topskip", assign_glue, glue_base + top_skip_code);
4040 primitive("splittopskip", assign_glue, glue_base + split_top_skip_code);
4041 primitive("tabskip", assign_glue, glue_base + tab_skip_code);
4042 primitive("spaceskip", assign_glue, glue_base + space_skip_code);
4043 primitive("xspaceskip", assign_glue, glue_base + xspace_skip_code);
4044 primitive("parfillskip", assign_glue, glue_base + par_fill_skip_code);
4045 primitive("thinmuskip", assign_mu_glue, glue_base + thin_mu_skip_code);
4046 primitive("medmuskip", assign_mu_glue, glue_base + med_mu_skip_code);
4047 primitive("thickmuskip", assign_mu_glue, glue_base + thick_mu_skip_code);
4048 primitive("output", assign_toks, output_routine_loc);
4049 primitive("everypar", assign_toks, every_par_loc);
4050 primitive("everymath", assign_toks, every_math_loc);
4051 primitive("everydisplay", assign_toks, every_display_loc);
4052 primitive("everyhbox", assign_toks, every_hbox_loc);
4053 primitive("everyvbox", assign_toks, every_vbox_loc);
4054 primitive("everyjob", assign_toks, every_job_loc);
4055 primitive("everycr", assign_toks, every_cr_loc);
4056 primitive("errhelp", assign_toks, err_help_loc);
4057 primitive("pretolerance", assign_int, int_base + pretolerance_code);
4058 primitive("tolerance", assign_int, int_base + tolerance_code);
4059 primitive("linepenalty", assign_int, int_base + line_penalty_code);
4060 primitive("hyphenpenalty", assign_int, int_base + hyphen_penalty_code);
4061 primitive("exhyphenpenalty", assign_int, int_base + ex_hyphen_penalty_code);
4062 primitive("clubpenalty", assign_int, int_base + club_penalty_code);
4063 primitive("widowpenalty", assign_int, int_base + widow_penalty_code);
4064 primitive("displaywidowpenalty", assign_int, int_base + display_widow_penalty_code);
4065 primitive("brokenpenalty", assign_int, int_base + broken_penalty_code);
4066 primitive("binoppenalty", assign_int, int_base + bin_op_penalty_code);
4067 primitive("relpenalty", assign_int, int_base + rel_penalty_code);
4068 primitive("predisplaypenalty", assign_int, int_base + pre_display_penalty_code);
4069 primitive("postdisplaypenalty", assign_int, int_base + post_display_penalty_code);
4070 primitive("interlinepenalty", assign_int, int_base + inter_line_penalty_code);
4071 primitive("doublehyphendemerits", assign_int, int_base + double_hyphen_demerits_code);
4072 primitive("finalhyphendemerits", assign_int, int_base + final_hyphen_demerits_code);
4073 primitive("adjdemerits", assign_int, int_base + adj_demerits_code);
4074 primitive("mag", assign_int, int_base + mag_code);
4075 primitive("delimiterfactor", assign_int, int_base + delimiter_factor_code);
4076 primitive("looseness", assign_int, int_base + looseness_code);
4077 primitive("time", assign_int, int_base + time_code);
4078 primitive("day", assign_int, int_base + day_code);
4079 primitive("month", assign_int, int_base + month_code);
4080 primitive("year", assign_int, int_base + year_code);
4081 primitive("showboxbreadth", assign_int, int_base + show_box_breadth_code);
4082 primitive("showboxdepth", assign_int, int_base + show_box_depth_code);
4083 primitive("hbadness", assign_int, int_base + hbadness_code);
4084 primitive("vbadness", assign_int, int_base + vbadness_code);
4085 primitive("pausing", assign_int, int_base + pausing_code);
4086 primitive("tracingonline", assign_int, int_base + tracing_online_code);
4087 primitive("tracingmacros", assign_int, int_base + tracing_macros_code);
4088 primitive("tracingstats", assign_int, int_base + tracing_stats_code);
4089 primitive("tracingparagraphs", assign_int, int_base + tracing_paragraphs_code);
4090 primitive("tracingpages", assign_int, int_base + tracing_pages_code);
4091 primitive("tracingoutput", assign_int, int_base + tracing_output_code);
4092 primitive("tracinglostchars", assign_int, int_base + tracing_lost_chars_code);
4093 primitive("tracingcommands", assign_int, int_base + tracing_commands_code);
4094 primitive("tracingrestores", assign_int, int_base + tracing_restores_code);
4095 primitive("uchyph", assign_int, int_base + uc_hyph_code);
4096 primitive("outputpenalty", assign_int, int_base + output_penalty_code);
4097 primitive("maxdeadcycles", assign_int, int_base + max_dead_cycles_code);
4098 primitive("hangafter", assign_int, int_base + hang_after_code);
4099 primitive("floatingpenalty", assign_int, int_base + floating_penalty_code);
4100 primitive("globaldefs", assign_int, int_base + global_defs_code);
4101 primitive("fam", assign_int, int_base + cur_fam_code);
4102 primitive("escapechar", assign_int, int_base + escape_char_code);
4103 primitive("defaulthyphenchar", assign_int, int_base + default_hyphen_char_code);
4104 primitive("defaultskewchar", assign_int, int_base + default_skew_char_code);
4105 primitive("endlinechar", assign_int, int_base + end_line_char_code);
4106 primitive("newlinechar", assign_int, int_base + new_line_char_code);
4107 primitive("language", assign_int, int_base + language_code);
4108 primitive("lefthyphenmin", assign_int, int_base + left_hyphen_min_code);
4109 primitive("righthyphenmin", assign_int, int_base + right_hyphen_min_code);
4110 primitive("holdinginserts", assign_int, int_base + holding_inserts_code);
4111 primitive("errorcontextlines", assign_int, int_base + error_context_lines_code);
4112 primitive("parindent", assign_dimen, dimen_base + par_indent_code);
4113 primitive("mathsurround", assign_dimen, dimen_base + math_surround_code);
4114 primitive("lineskiplimit", assign_dimen, dimen_base + line_skip_limit_code);
4115 primitive("hsize", assign_dimen, dimen_base + hsize_code);
4116 primitive("vsize", assign_dimen, dimen_base + vsize_code);
4117 primitive("maxdepth", assign_dimen, dimen_base + max_depth_code);
4118 primitive("splitmaxdepth", assign_dimen, dimen_base + split_max_depth_code);
4119 primitive("boxmaxdepth", assign_dimen, dimen_base + box_max_depth_code);
4120 primitive("hfuzz", assign_dimen, dimen_base + hfuzz_code);
4121 primitive("vfuzz", assign_dimen, dimen_base + vfuzz_code);
4122 primitive("delimitershortfall", assign_dimen, dimen_base + delimiter_shortfall_code);
4123 primitive("nulldelimiterspace", assign_dimen, dimen_base + null_delimiter_space_code);
4124 primitive("scriptspace", assign_dimen, dimen_base + script_space_code);
4125 primitive("predisplaysize", assign_dimen, dimen_base + pre_display_size_code);
4126 primitive("displaywidth", assign_dimen, dimen_base + display_width_code);
4127 primitive("displayindent", assign_dimen, dimen_base + display_indent_code);
4128 primitive("overfullrule", assign_dimen, dimen_base + overfull_rule_code);
4129 primitive("hangindent", assign_dimen, dimen_base + hang_indent_code);
4130 primitive("hoffset", assign_dimen, dimen_base + h_offset_code);
4131 primitive("voffset", assign_dimen, dimen_base + v_offset_code);
4132 primitive("emergencystretch", assign_dimen, dimen_base + emergency_stretch_code);
4133 primitive(" ", ex_space, 0);
4134 primitive("/", ital_corr, 0);
4135 primitive("accent", accent, 0);
4136 primitive("advance", advance, 0);
4137 primitive("afterassignment", after_assignment, 0);
4138 primitive("aftergroup", after_group, 0);
4139 primitive("begingroup", begin_group, 0);
4140 primitive("char", char_num, 0);
4141 primitive("csname", cs_name, 0);
4142 primitive("delimiter", delim_num, 0);
4143 primitive("divide", divide, 0);
4144 primitive("endcsname", end_cs_name, 0);
4145 primitive("endgroup", end_group, 0);
4146 text(frozen_end_group) = make_string_pool("endgroup");
4147 eqtb[frozen_end_group] = eqtb[cur_val];
4148 primitive("expandafter", expand_after, 0);
4149 primitive("font", def_font, 0);
4150 primitive("fontdimen", assign_font_dimen, 0);
4151 primitive("halign", halign, 0);
4152 primitive("hrule", hrule, 0);
4153 primitive("ignorespaces", ignore_spaces, 0);
4154 primitive("insert", insert, 0);
4155 primitive("mark", mark, 0);
4156 primitive("mathaccent", math_accent, 0);
4157 primitive("mathchar", math_char_num, 0);
4158 primitive("mathchoice", math_choice, 0);
4159 primitive("multiply", multiply, 0);
4160 primitive("noalign", no_align, 0);
4161 primitive("noboundary", no_boundary, 0);
4162 primitive("noexpand", no_expand, 0);
4163 primitive("nonscript", non_script, 0);
4164 primitive("omit", omit, 0);
4165 primitive("parshape", set_shape, 0);
4166 primitive("penalty", break_penalty, 0);
4167 primitive("prevgraf", set_prev_graf, 0);
4168 primitive("radical", radical, 0);
4169 primitive("read", read_to_cs, 0);
4170 primitive("relax", relax, 256);
4171 text(frozen_relax) = make_string_pool("relax");
4172 eqtb[frozen_relax] = eqtb[cur_val];
4173 primitive("setbox", set_box, 0);
4174 primitive("the", the, 0);
4175 primitive("toks", toks_register, 0);
4176 primitive("vadjust", vadjust, 0);
4177 primitive("valign", valign, 0);
4178 primitive("vcenter", vcenter, 0);
4179 primitive("vrule", vrule, 0);
4180 primitive("par", par_end, 256);
4182 par_token = cs_token_flag + par_loc;
4183 primitive("input", input, 0);
4184 primitive("endinput", input, 1);
4185 primitive("topmark", top_bot_mark, 0);
4186 primitive("firstmark", top_bot_mark, 1);
4187 primitive("botmark", top_bot_mark, 2);
4188 primitive("splitfirstmark", top_bot_mark, 3);
4189 primitive("splitbotmark", top_bot_mark, 4);
4190 primitive("count", tex_register, 0);
4191 primitive("dimen", tex_register, 1);
4192 primitive("skip", tex_register, 2);
4193 primitive("muskip", tex_register, 3);
4194 primitive("spacefactor", set_aux, 102);
4195 primitive("prevdepth", set_aux, 1);
4196 primitive("deadcycles", set_page_int, 0);
4197 primitive("insertpenalties", set_page_int, 1);
4198 primitive("wd", set_box_dimen, 1);
4199 primitive("ht", set_box_dimen, 3);
4200 primitive("dp", set_box_dimen, 2);
4201 primitive("lastpenalty", last_item, 0);
4202 primitive("lastkern", last_item, 1);
4203 primitive("lastskip", last_item, 2);
4204 primitive("inputlineno", last_item, 3);
4205 primitive("badness", last_item, 4);
4206 primitive("number", convert, 0);
4207 primitive("romannumeral", convert, 1);
4208 primitive("string", convert, 2);
4209 primitive("meaning", convert, 3);
4210 primitive("fontname", convert, 4);
4211 primitive("jobname", convert, 5);
4212 primitive("if", if_test, 0);
4213 primitive("ifcat", if_test, 1);
4214 primitive("ifnum", if_test, 2);
4215 primitive("ifdim", if_test, 3);
4216 primitive("ifodd", if_test, 4);
4217 primitive("ifvmode", if_test, 5);
4218 primitive("ifhmode", if_test, 6);
4219 primitive("ifmmode", if_test, 7);
4220 primitive("ifinner", if_test, 8);
4221 primitive("ifvoid", if_test, 9);
4222 primitive("ifhbox", if_test, 10);
4223 primitive("ifvbox", if_test, 11);
4224 primitive("ifx", if_test, 12);
4225 primitive("ifeof", if_test, 13);
4226 primitive("iftrue", if_test, 14);
4227 primitive("iffalse", if_test, 15);
4228 primitive("ifcase", if_test, 16);
4229 primitive("fi", fi_or_else, 2);
4230 text(frozen_fi) = make_string_pool("fi");
4231 eqtb[frozen_fi] = eqtb[cur_val];
4232 primitive("or", fi_or_else, 4);
4233 primitive("else", fi_or_else, 3);
4234 primitive("nullfont", set_font, 0);
4235 text(frozen_null_font) = 795;
4236 eqtb[frozen_null_font] = eqtb[cur_val];
4237 primitive("span", tab_mark, 256);
4238 primitive("cr", car_ret, 257);
4239 text(frozen_cr) = make_string_pool("cr");
4240 eqtb[frozen_cr] = eqtb[cur_val];
4241 primitive("crcr", car_ret, 258);
4242 text(frozen_end_template) = make_string_pool("endtemplate");
4243 text(frozen_endv) = make_string_pool("endtemplate");
4244 eq_type(frozen_endv) = endv;
4245 equiv(frozen_endv) = null_list;
4246 eq_level(frozen_endv) = level_one;
4247 eqtb[frozen_end_template] = eqtb[frozen_endv];
4248 eq_type(frozen_end_template) = end_template;
4249 primitive("pagegoal", set_page_dimen, 0);
4250 primitive("pagetotal", set_page_dimen, 1);
4251 primitive("pagestretch", set_page_dimen, 2);
4252 primitive("pagefilstretch", set_page_dimen, 3);
4253 primitive("pagefillstretch", set_page_dimen, 4);
4254 primitive("pagefilllstretch", set_page_dimen, 5);
4255 primitive("pageshrink", set_page_dimen, 6);
4256 primitive("pagedepth", set_page_dimen, 7);
4257 primitive("end", end_match, 0);
4258 primitive("dump", stop, 1);
4259 primitive("hskip", hskip, 4);
4260 primitive("hfil", hskip, 0);
4261 primitive("hfill", hskip, 1);
4262 primitive("hss", hskip, 2);
4263 primitive("hfilneg", hskip, 3);
4264 primitive("vskip", vskip, 4);
4265 primitive("vfil", vskip, 0);
4266 primitive("vfill", vskip, 1);
4267 primitive("vss", vskip, 2);
4268 primitive("vfilneg", vskip, 3);
4269 primitive("mskip", mskip, 5);
4270 primitive("kern", kern, 1);
4271 primitive("mkern", mkern, 99);
4272 primitive("moveleft", hmove, 1);
4273 primitive("moveright", hmove, 0);
4274 primitive("raise", vmove, 1);
4275 primitive("lower", vmove, 0);
4276 primitive("box", make_box, 0);
4277 primitive("copy", make_box, 1);
4278 primitive("lastbox", make_box, 2);
4279 primitive("vsplit", make_box, 3);
4280 primitive("vtop", make_box, 4);
4281 primitive("vbox", make_box, 5);
4282 primitive("hbox", make_box, 106);
4283 primitive("shipout", leader_ship, 99);
4284 primitive("leaders", leader_ship, 100);
4285 primitive("cleaders", leader_ship, 101);
4286 primitive("xleaders", leader_ship, 102);
4287 primitive("indent", start_par, 1);
4288 primitive("noindent", start_par, 0);
4289 primitive("unpenalty", remove_item, 12);
4290 primitive("unkern", remove_item, 11);
4291 primitive("unskip", remove_item, 10);
4292 primitive("unhbox", un_hbox, 0);
4293 primitive("unhcopy", un_hbox, 1);
4294 primitive("unvbox", un_vbox, 0);
4295 primitive("unvcopy", un_vbox, 1);
4296 primitive("-", discretionary, 1);
4297 primitive("discretionary", discretionary, 0);
4298 primitive("eqno", eq_no, 0);
4299 primitive("leqno", eq_no, 1);
4300 primitive("mathord", math_comp, 16);
4301 primitive("mathop", math_comp, 17);
4302 primitive("mathbin", math_comp, 18);
4303 primitive("mathrel", math_comp, 19);
4304 primitive("mathopen", math_comp, 20);
4305 primitive("mathclose", math_comp, 21);
4306 primitive("mathpunct", math_comp, 22);
4307 primitive("mathinner", math_comp, 23);
4308 primitive("underline", math_comp, 26);
4309 primitive("overline", math_comp, 27);
4310 primitive("displaylimits", limit_switch, 0);
4311 primitive("limits", limit_switch, 1);
4312 primitive("nolimits", limit_switch, 2);
4313 primitive("displaystyle", math_style, 0);
4314 primitive("textstyle", math_style, 2);
4315 primitive("scriptstyle", math_style, 4);
4316 primitive("scriptscriptstyle", math_style, 6);
4317 primitive("above", above, 0);
4318 primitive("over", above, 1);
4319 primitive("atop", above, 2);
4320 primitive("abovewithdelims", above, 3);
4321 primitive("overwithdelims", above, 4);
4322 primitive("atopwithdelims", above, 5);
4323 primitive("left", left_right, 30);
4324 primitive("right", left_right, 31);
4325 text(frozen_right) = make_string_pool("right");
4326 eqtb[frozen_right] = eqtb[cur_val];
4327 primitive("long", prefix, 1);
4328 primitive("outer", prefix, 2);
4329 primitive("global", prefix, 4);
4330 primitive("def", def, 0);
4331 primitive("gdef", def, 1);
4332 primitive("edef", def, 2);
4333 primitive("xdef", def, 3);
4334 primitive("let", let, 0);
4335 primitive("futurelet", let, 1);
4336 primitive("chardef", shorthand_def, 0);
4337 primitive("mathchardef", shorthand_def, 1);
4338 primitive("countdef", shorthand_def, 2);
4339 primitive("dimendef", shorthand_def, 3);
4340 primitive("skipdef", shorthand_def, 4);
4341 primitive("muskipdef", shorthand_def, 5);
4342 primitive("toksdef", shorthand_def, 6);
4343 primitive("catcode", def_code, cat_code_base);
4344 primitive("mathcode", def_code, math_code_base);
4345 primitive("lccode", def_code, lc_code_base);
4346 primitive("uccode", def_code, uc_code_base);
4347 primitive("sfcode", def_code, sf_code_base);
4348 primitive("delcode", def_code, (hash_size + 3474));
4349 primitive("textfont", def_family, (hash_size + 1835));
4350 primitive("scriptfont", def_family, (hash_size + 1851));
4351 primitive("scriptscriptfont", def_family, (hash_size + 1867));
4352 primitive("hyphenation", hyph_data, 0);
4353 primitive("patterns", hyph_data, 1);
4354 primitive("hyphenchar", assign_font_int, 0);
4355 primitive("skewchar", assign_font_int, 1);
4356 primitive("batchmode", set_interaction, 0);
4357 primitive("nonstopmode", set_interaction, 1);
4358 primitive("scrollmode", set_interaction, 2);
4359 primitive("errorstopmode", set_interaction, 3);
4360 primitive("openin", in_stream, 1);
4361 primitive("closein", in_stream, 0);
4362 primitive("message", message, 0);
4363 primitive("errmessage", message, 1);
4364 primitive("lowercase", case_shift, (hash_size + 2139));
4365 primitive("uppercase", case_shift, (hash_size + 2395));
4366 primitive("show", xray, 0);
4367 primitive("showbox", xray, 1);
4368 primitive("showthe", xray, 2);
4369 primitive("showlists", xray, 3);
4370 primitive("openout", extension, 0);
4371 primitive("write", extension, 1);
4372 write_loc = cur_val;
4373 primitive("closeout", extension, 2);
4374 primitive("special", extension, 3);
4375 primitive("immediate", extension, 4);
4376 primitive("setlanguage", extension, 5);
4377 no_new_control_sequence = true;