1 /* Copyright 2014 Clerk Ma
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 void show_box_(pointer p)
25 depth_threshold = show_box_depth;
26 breadth_max = show_box_breadth;
32 if (pool_ptr + depth_threshold >= current_pool_size)
33 str_pool = realloc_str_pool(increment_pool_size);
35 if (pool_ptr + depth_threshold >= current_pool_size)
36 depth_threshold = current_pool_size - pool_ptr - 1;
38 if (pool_ptr + depth_threshold >= pool_size)
39 depth_threshold = pool_size - pool_ptr - 1;
46 void delete_token_ref_(pointer p)
48 if (token_ref_count(p) == 0)
51 decr(token_ref_count(p));
54 void delete_glue_ref_(pointer p)
56 if (glue_ref_count(p) == 0)
57 free_node(p, glue_spec_size);
59 decr(glue_ref_count(p));
62 void flush_node_list_(pointer p)
66 while (is_char_node(p))
81 flush_node_list(list_ptr(p));
82 delete_glue_ref(space_ptr(p)); // fast
83 delete_glue_ref(xspace_ptr(p)); // fast
84 free_node(p, box_node_size);
90 free_node(p, rule_node_size);
96 flush_node_list(ins_ptr(p));
97 delete_glue_ref(split_top_ptr(p));
98 free_node(p, ins_node_size);
107 free_node(p, open_node_size);
112 delete_token_ref(write_tokens(p));
113 free_node(p, write_node_size);
118 case set_language_code:
119 free_node(p, small_node_size);
124 return; // abort_flag set
133 if (mem[mem[p + 1].hh.lh].hh.rh == 0)
134 free_node(mem[p + 1].hh.lh, 4);
136 decr(mem[mem[p + 1].hh.lh].hh.rh);
139 if (leader_ptr(p) != 0)
140 flush_node_list(leader_ptr(p));
148 flush_node_list(lig_ptr(p));
151 delete_token_ref(mark_ptr(p));
154 flush_node_list(pre_break(p));
155 flush_node_list(post_break(p));
158 flush_node_list(adjust_ptr(p));
162 free_node(p, style_node_size);
168 flush_node_list(display_mlist(p));
169 flush_node_list(text_mlist(p));
170 flush_node_list(script_mlist(p));
171 flush_node_list(script_script_mlist(p));
172 free_node(p, style_node_size);
190 if (math_type(nucleus(p)) >= sub_box)
191 flush_node_list(info(nucleus(p)));
193 if (math_type(supscr(p)) >= sub_box)
194 flush_node_list(info(supscr(p)));
196 if (math_type(subscr(p)) >= sub_box)
197 flush_node_list(info(subscr(p)));
199 if (type(p) == radical_noad)
200 free_node(p, radical_noad_size);
203 if (type(p) == accent_noad)
204 free_node(p, accent_noad_size);
206 free_node(p, noad_size);
214 free_node(p, noad_size);
220 flush_node_list(info(numerator(p)));
221 flush_node_list(info(denominator(p)));
222 free_node(p, fraction_noad_size);
228 confusion("flushing");
229 return; // abort_flag set
234 free_node(p, small_node_size);
242 pointer copy_node_list_(pointer p)
256 if ((p >= hi_mem_min))
258 else switch (type(p))
265 r = get_node(box_node_size);
266 mem[r + 7] = mem[p + 7];
267 mem[r + 6] = mem[p + 6];
268 mem[r + 5] = mem[p + 5];
269 add_glue_ref(space_ptr(r));
270 add_glue_ref(xspace_ptr(r));
271 list_ptr(r) = copy_node_list(list_ptr(p));
277 r = get_node(rule_node_size);
278 words = rule_node_size;
283 r = get_node(ins_node_size);
284 mem[r + 5] = mem[p + 5];
285 mem[r + 4] = mem[p + 4];
286 add_glue_ref(split_top_ptr(p));
287 ins_ptr(r) = copy_node_list(ins_ptr(p));
288 words = ins_node_size - 2;
296 r = get_node(open_node_size);
297 words = open_node_size;
304 r = get_node(write_node_size);
305 add_token_ref(write_tokens(p));
306 words = write_node_size;
313 r = get_node(small_node_size);
314 words = small_node_size;
321 return 0; // abort_flag set
329 r = get_node(small_node_size);
330 add_glue_ref(glue_ptr(p));
331 glue_ptr(r) = glue_ptr(p);
332 leader_ptr(r) = copy_node_list(leader_ptr(p));
341 r = get_node(small_node_size);
342 words = small_node_size;
348 r = get_node(small_node_size);
349 mem[lig_char(r)] = mem[lig_char(p)];
350 lig_ptr(r) = copy_node_list(lig_ptr(p));
356 r = get_node(small_node_size);
357 pre_break(r) = copy_node_list(pre_break(p));
358 post_break(r) = copy_node_list(pre_break(p));
364 r = get_node(small_node_size);
365 add_token_ref(mark_ptr(p));
366 words = small_node_size;
372 r = get_node(small_node_size);
373 adjust_ptr(r) = copy_node_list(adjust_ptr(p));
379 confusion("copying");
380 return 0; // abort_flag set
388 mem[r + words] = mem[p + words]; /* r may be used without having ... */
403 void print_mode_(integer m)
407 switch (m / (max_command + 1))
410 print_string("vertical");
413 print_string("horizontal");
416 print_string("display math");
428 switch ((- (integer) m) / (max_command + 1))
431 print_string("internal vertical");
434 print_string("restricted horizontal");
437 print_string("math");
443 print_string(" mode");
446 void push_nest (void)
448 if (nest_ptr > max_nest_stack)
450 max_nest_stack = nest_ptr;
452 #ifdef ALLOCATEINPUTSTACK
453 if (nest_ptr == current_nest_size)
454 nest = realloc_nest_stack(increment_nest_size);
456 if (nest_ptr == current_nest_size)
458 overflow("semantic nest size", current_nest_size);
459 return; // abort_flag set
462 if (nest_ptr == nest_size)
464 overflow("semantic nest size", nest_size);
465 return; // abort_flag set
470 nest[nest_ptr]= cur_list;
472 head = new_null_box();//head = get_avail();
484 delete_glue_ref(space_ptr(head)); // fast
485 delete_glue_ref(xspace_ptr(head)); // fast
486 free_node(head, box_node_size);
488 cur_list = nest[nest_ptr];
491 void show_activities (void)
499 nest[nest_ptr] = cur_list;
503 for (p = nest_ptr; p >= 0; p--)
505 m = nest[p].mode_field;
506 a = nest[p].aux_field;
508 print_direction(nest[p].dir_field);
511 print_string(" entered at line ");
512 print_int(abs(nest[p].ml_field));
516 if (nest[p].pg_field != 040600000)
518 print_string(" (language");
519 print_int(nest[p].pg_field % 65536L);
520 print_string(":hyphenmin");
521 print_int(nest[p].pg_field / 4194304L);
523 print_int((nest[p].pg_field / 65536L) % 64);
528 if (nest[p].ml_field < 0)
530 print_string(" (\\output routine)");
535 if (page_head != page_tail)
537 print_nl("### current page:");
541 print_string(" (held over for next output)");
544 show_box(link(page_head));
546 if (page_contents > 0)
548 print_nl("total height ");
550 print_nl(" goal height ");
551 print_scaled(page_so_far[0]);
552 r = link(page_ins_head);
560 print_string(" adds ");
562 if (count(t) == 1000)
565 t = x_over_n(height(r), 1000) * count(t);
569 if (type(r) == split_up)
578 if ((type(q) == ins_node) && (subtype(q) == subtype(r)))
581 while (!(q == broken_ins(r)));
585 print_string(" might split");
592 if (link(contrib_head) != 0)
593 print_nl("### recent contributions:");
596 show_box(link(nest[p].head_field));
598 switch (abs(m) / (max_command + 1))
602 print_nl("prevdepth ");
604 if (a.cint <= ignore_depth)
605 print_string("ignored");
607 print_scaled(a.cint);
609 if (nest[p].pg_field != 0)
611 print_string(", prevgraf ");
612 print_int(nest[p].pg_field);
613 print_string(" line");
615 if (nest[p].pg_field != 1)
623 print_nl("spacefactor ");
630 print_string(", current language ");
640 print_string("this will be denominator of:");
648 void print_param_(integer n)
652 case pretolerance_code:
653 print_esc("pretolerance");
657 print_esc("tolerance");
660 case line_penalty_code:
661 print_esc("linepenalty");
664 case hyphen_penalty_code:
665 print_esc("hyphenpenalty");
668 case ex_hyphen_penalty_code:
669 print_esc("exhyphenpenalty");
672 case club_penalty_code:
673 print_esc("clubpenalty");
676 case widow_penalty_code:
677 print_esc("widowpenalty");
680 case display_widow_penalty_code:
681 print_esc("displaywidowpenalty");
684 case broken_penalty_code:
685 print_esc("brokenpenalty");
688 case bin_op_penalty_code:
689 print_esc("binoppenalty");
692 case rel_penalty_code:
693 print_esc("relpenalty");
696 case pre_display_penalty_code:
697 print_esc("predisplaypenalty");
700 case post_display_penalty_code:
701 print_esc("postdisplaypenalty");
704 case inter_line_penalty_code:
705 print_esc("interlinepenalty");
708 case double_hyphen_demerits_code:
709 print_esc("doublehyphendemerits");
712 case final_hyphen_demerits_code:
713 print_esc("finalhyphendemerits");
716 case adj_demerits_code:
717 print_esc("adjdemerits");
724 case delimiter_factor_code:
725 print_esc("delimiterfactor");
729 print_esc("looseness");
748 case show_box_breadth_code:
749 print_esc("showboxbreadth");
752 case show_box_depth_code:
753 print_esc("showboxdepth");
757 print_esc("hbadness");
761 print_esc("vbadness");
765 print_esc("pausing");
768 case tracing_online_code:
769 print_esc("tracingonline");
772 case tracing_macros_code:
773 print_esc("tracingmacros");
776 case tracing_stats_code:
777 print_esc("tracingstats");
780 case tracing_paragraphs_code:
781 print_esc("tracingparagraphs");
784 case tracing_pages_code:
785 print_esc("tracingpages");
788 case tracing_output_code:
789 print_esc("tracingoutput");
792 case tracing_lost_chars_code:
793 print_esc("tracinglostchars");
796 case tracing_commands_code:
797 print_esc("tracingcommands");
800 case tracing_restores_code:
801 print_esc("tracingrestores");
808 case output_penalty_code:
809 print_esc("outputpenalty");
812 case max_dead_cycles_code:
813 print_esc("maxdeadcycles");
816 case hang_after_code:
817 print_esc("hangafter");
820 case floating_penalty_code:
821 print_esc("floatingpenalty");
824 case global_defs_code:
825 print_esc("globaldefs");
832 case escape_char_code:
833 print_esc("escapechar");
836 case default_hyphen_char_code:
837 print_esc("defaulthyphenchar");
840 case default_skew_char_code:
841 print_esc("defaultskewchar");
844 case end_line_char_code:
845 print_esc("endlinechar");
848 case new_line_char_code:
849 print_esc("newlinechar");
856 case jchr_widow_penalty_code:
857 print_esc("jcharwidowpenalty");
861 print_esc("language");
864 case left_hyphen_min_code:
865 print_esc("lefthyphenmin");
868 case right_hyphen_min_code:
869 print_esc("righthyphenmin");
872 case holding_inserts_code:
873 print_esc("holdinginserts");
876 case error_context_lines_code:
877 print_esc("errorcontextlines");
881 print_string("[unknown integer parameter!]");
886 void begin_diagnostic (void)
888 old_setting = selector;
890 if ((tracing_online <= 0) && (selector == term_and_log))
894 if (history == spotless)
895 history = warning_issued;
899 void end_diagnostic_(boolean blankline)
906 selector = old_setting;
909 void print_length_param_ (integer n)
913 case par_indent_code:
914 print_esc("parindent");
917 case math_surround_code:
918 print_esc("mathsurround");
921 case line_skip_limit_code:
922 print_esc("lineskiplimit");
934 print_esc("maxdepth");
937 case split_max_depth_code:
938 print_esc("splitmaxdepth");
941 case box_max_depth_code:
942 print_esc("boxmaxdepth");
953 case delimiter_shortfall_code:
954 print_esc("delimitershortfall");
957 case null_delimiter_space_code:
958 print_esc("nulldelimiterspace");
961 case script_space_code:
962 print_esc("scriptspace");
965 case pre_display_size_code:
966 print_esc("predisplaysize");
969 case display_width_code:
970 print_esc("displaywidth");
973 case display_indent_code:
974 print_esc("displayindent");
977 case overfull_rule_code:
978 print_esc("overfullrule");
981 case hang_indent_code:
982 print_esc("hangindent");
986 print_esc("hoffset");
990 print_esc("voffset");
993 case t_baseline_shift_code:
994 print_esc("tbaselineshift");
997 case y_baseline_shift_code:
998 print_esc("ybaselineshift");
1001 case emergency_stretch_code:
1002 print_esc("emergencystretch");
1006 print_string("[unknown dimen parameter!]");
1011 void print_cmd_chr_ (quarterword cmd, halfword chr_code)
1016 print_string("begin-group character ");
1021 print_string("end-group character ");
1026 print_string("math shift character ");
1031 print_string("macro parameter character ");
1036 print_string("superscript character ");
1041 print_string("subscript character ");
1046 print_string("end of alignment template");
1050 print_string("blank space ");
1055 print_string("the letter ");
1060 print_string("the character ");
1067 print_string("kanji character ");
1068 print_kanji(chr_code);
1072 case assign_mu_glue:
1073 if (chr_code < skip_base)
1075 print_skip_param(chr_code - glue_base);
1079 if (chr_code < mu_skip_base)
1082 print_int(chr_code - skip_base);
1086 print_esc("muskip");
1087 print_int(chr_code - mu_skip_base);
1093 if (chr_code >= toks_base)
1096 print_int(chr_code - toks_base);
1102 case output_routine_loc:
1103 print_esc("output");
1107 print_esc("everypar");
1110 case every_math_loc:
1111 print_esc("everymath");
1114 case every_display_loc:
1115 print_esc("everydisplay");
1118 case every_hbox_loc:
1119 print_esc("everyhbox");
1122 case every_vbox_loc:
1123 print_esc("everyvbox");
1127 print_esc("everyjob");
1131 print_esc("everycr");
1135 print_esc("errhelp");
1142 if (chr_code < count_base)
1144 print_param(chr_code - int_base);
1149 print_int(chr_code - count_base);
1154 if (chr_code < scaled_base)
1156 print_length_param(chr_code - dimen_base);
1161 print_int(chr_code - scaled_base);
1166 print_esc("accent");
1170 print_esc("advance");
1173 case after_assignment:
1174 print_esc("afterassignment");
1178 print_esc("aftergroup");
1181 case assign_font_dimen:
1182 print_esc("fontdimen");
1186 print_esc("begingroup");
1190 print_esc("penalty");
1198 print_esc("csname");
1214 print_esc("delimiter");
1218 print_esc("divide");
1222 print_esc("endcsname");
1226 print_esc("endgroup");
1234 print_esc("expandafter");
1238 print_esc("halign");
1246 print_esc("ignorespaces");
1250 print_esc("insert");
1262 print_esc("mathaccent");
1266 print_esc("mathchar");
1270 print_esc("mathchoice");
1274 print_esc("multiply");
1278 print_esc("noalign");
1282 print_esc("noboundary");
1286 print_esc("noexpand");
1290 print_esc("nonscript");
1298 print_esc("radical");
1310 print_esc("setbox");
1314 print_esc("prevgraf");
1318 print_esc("parshape");
1330 print_esc("vadjust");
1334 print_esc("valign");
1338 print_esc("vcenter");
1353 print_esc("endinput");
1359 case first_mark_code:
1360 print_esc("firstmark");
1364 print_esc("botmark");
1367 case split_first_mark_code:
1368 print_esc("splitfirstmark");
1371 case split_bot_mark_code:
1372 print_esc("splitbotmark");
1376 print_esc("topmark");
1382 if (chr_code == int_val)
1384 else if (chr_code == dimen_val)
1386 else if (chr_code == glue_val)
1389 print_esc("muskip");
1392 case set_kansuji_char:
1393 print_esc("kansujichar");
1396 case set_auto_spacing:
1398 if ((chr_code % 2) == 0)
1399 print_esc("noauto");
1403 print_string("spacing");
1405 print_string("xspacing");
1410 print_esc("inhibitglue");
1413 case assign_inhibit_xsp_code:
1414 print_esc("inhibitxspcode");
1417 case assign_kinsoku:
1420 case pre_break_penalty_code:
1421 print_esc("prebreakpenalty");
1423 case post_break_penalty_code:
1424 print_esc("postbreakpenalty");
1430 if (chr_code == vmode)
1431 print_esc("prevdepth");
1433 print_esc("spacefactor");
1438 print_esc("deadcycles");
1440 print_esc("insertpenalties");
1444 if (chr_code == width_offset)
1446 else if (chr_code == height_offset)
1456 print_esc("lastpenalty");
1460 print_esc("lastkern");
1464 print_esc("lastskip");
1467 case input_line_no_code:
1468 print_esc("inputlineno");
1472 print_esc("badness");
1481 print_esc("number");
1484 case roman_numeral_code:
1485 print_esc("romannumeral");
1489 print_esc("string");
1493 print_esc("meaning");
1496 case font_name_code:
1497 print_esc("fontname");
1501 print_esc("kansuji");
1521 print_esc("jobname");
1546 print_esc("ifvmode");
1550 print_esc("ifhmode");
1554 print_esc("ifmmode");
1558 print_esc("ifinner");
1562 print_esc("ifvoid");
1566 print_esc("ifhbox");
1570 print_esc("ifvbox");
1582 print_esc("iftrue");
1586 print_esc("iffalse");
1590 print_esc("ifcase");
1594 print_esc("iftdir");
1598 print_esc("ifydir");
1602 print_esc("ifddir");
1606 print_esc("ifmdir");
1610 print_esc("iftbox");
1614 print_esc("ifybox");
1618 print_esc("ifdbox");
1628 if (chr_code == fi_code)
1630 else if (chr_code == or_code)
1637 if (chr_code == span_code)
1641 print_string("alignment tab character ");
1647 if (chr_code == cr_code)
1653 case set_page_dimen:
1657 print_esc("pagegoal");
1661 print_esc("pagetotal");
1665 print_esc("pagestretch");
1669 print_esc("pagefilstretch");
1673 print_esc("pagefillstretch");
1677 print_esc("pagefilllstretch");
1681 print_esc("pageshrink");
1685 print_esc("pagedepth");
1717 print_esc("hfilneg");
1742 print_esc("vfilneg");
1761 print_esc("moveleft");
1763 print_esc("moveright");
1785 print_esc("lastbox");
1789 print_esc("vsplit");
1796 case vtop_code + vmode:
1807 if (chr_code == a_leaders)
1808 print_esc("leaders");
1809 else if (chr_code == c_leaders)
1810 print_esc("cleaders");
1811 else if (chr_code == x_leaders)
1812 print_esc("xleaders");
1814 print_esc("shipout");
1819 print_esc("noindent");
1821 print_esc("indent");
1825 if (chr_code == glue_node)
1826 print_esc("unskip");
1827 else if (chr_code == kern_node)
1828 print_esc("unkern");
1830 print_esc("unpenalty");
1834 if (chr_code == copy_code)
1835 print_esc("unhcopy");
1837 print_esc("unhbox");
1841 if (chr_code == copy_code)
1842 print_esc("unvcopy");
1844 print_esc("unvbox");
1851 print_esc("discretionary");
1865 print_esc("mathord");
1869 print_esc("mathop");
1873 print_esc("mathbin");
1877 print_esc("mathrel");
1881 print_esc("mathopen");
1885 print_esc("mathclose");
1889 print_esc("mathpunct");
1893 print_esc("mathinner");
1897 print_esc("underline");
1901 print_esc("overline");
1907 if (chr_code == limits)
1908 print_esc("limits");
1909 else if (chr_code == no_limits)
1910 print_esc("nolimits");
1912 print_esc("displaylimits");
1916 print_style(chr_code);
1930 case delimited_code + above_code:
1931 print_esc("abovewithdelims");
1934 case delimited_code + over_code:
1935 print_esc("overwithdelims");
1938 case delimited_code + atop_code:
1939 print_esc("atopwithdelims");
1949 if (chr_code == left_noad)
1958 else if (chr_code == 2)
1961 print_esc("global");
1967 else if (chr_code == 1)
1969 else if (chr_code == 2)
1976 if (chr_code != normal)
1977 print_esc("futurelet");
1986 print_esc("chardef");
1989 case math_char_def_code:
1990 print_esc("mathchardef");
1993 case count_def_code:
1994 print_esc("countdef");
1997 case dimen_def_code:
1998 print_esc("dimendef");
2002 print_esc("skipdef");
2005 case mu_skip_def_code:
2006 print_esc("muskipdef");
2010 print_esc("toksdef");
2017 print_hex(chr_code);
2021 print_esc("mathchar");
2022 print_hex(chr_code);
2026 if (chr_code == cat_code_base)
2027 print_esc("catcode");
2028 else if (chr_code == kcat_code_base)
2029 print_esc("kcatcode");
2030 else if (chr_code == auto_xsp_code_base)
2031 print_esc("xspcode");
2032 else if (chr_code == math_code_base)
2033 print_esc("mathcode");
2034 else if (chr_code == lc_code_base)
2035 print_esc("lccode");
2036 else if (chr_code == uc_code_base)
2037 print_esc("uccode");
2038 else if (chr_code == sf_code_base)
2039 print_esc("sfcode");
2041 print_esc("delcode");
2045 print_size(chr_code - math_font_base);
2050 print_esc("patterns");
2052 print_esc("hyphenation");
2055 case assign_font_int:
2057 print_esc("hyphenchar");
2059 print_esc("skewchar");
2063 print_string("select font ");
2064 slow_print(font_name[chr_code]);
2066 if (font_size[chr_code] != font_dsize[chr_code])
2068 print_string(" at ");
2069 print_scaled(font_size[chr_code]);
2074 case set_interaction:
2078 print_esc("batchmode");
2082 print_esc("nonstopmode");
2086 print_esc("scrollmode");
2090 print_esc("errorstopmode");
2097 print_esc("closein");
2099 print_esc("openin");
2104 print_esc("message");
2106 print_esc("errmessage");
2110 if (chr_code == lc_code_base)
2111 print_esc("lowercase");
2113 print_esc("uppercase");
2120 print_esc("showbox");
2124 print_esc("showthe");
2128 print_esc("showlists");
2132 // print_esc("showmode");
2142 print_string("undefined");
2146 print_string("macro");
2150 print_esc("long macro");
2154 print_esc("outer macro");
2157 case long_outer_call:
2159 print_esc("outer macro");
2163 print_esc("outer endtemplate");
2170 print_esc("openout");
2178 print_esc("closeout");
2182 print_esc("special");
2185 case immediate_code:
2186 print_esc("immediate");
2189 case set_language_code:
2190 print_esc("setlanguage");
2194 print_string("[unknown extension!]");
2200 print_string("[unknown command code!]");
2206 void show_eqtb_(halfword n)
2208 if (n < active_base)
2210 else if (n < glue_base)
2214 print_cmd_chr(eq_type(n), equiv(n));
2216 if (eq_type(n) >= call)
2219 show_token_list(link(equiv(n)), 0, 32);
2222 else if (n < local_base)
2225 print_skip_param(n - glue_base);
2228 if (n < glue_base + thin_mu_skip_code)
2229 print_spec(equiv(n), "pt");
2231 print_spec(equiv(n), "mu");
2233 else if (n < mu_skip_base)
2236 print_int(n - skip_base);
2238 print_spec(equiv(n), "pt");
2242 print_esc("muskip");
2243 print_int(n - mu_skip_base);
2245 print_spec(equiv(n), "mu");
2247 else if (n < int_base)
2248 if (n == par_shape_loc)
2250 print_esc("parshape");
2253 if (par_shape_ptr == 0)
2256 print_int(info(par_shape_ptr));
2258 else if (n < toks_base)
2260 print_cmd_chr(assign_toks, n);
2264 show_token_list(link(equiv(n)), 0, 32);
2266 else if (n < box_base)
2269 print_int(n - toks_base);
2273 show_token_list(link(equiv(n)), 0, 32);
2275 else if (n < cur_font_loc)
2278 print_int(n - box_base);
2282 print_string("void");
2285 depth_threshold = 0;
2287 show_node_list(equiv(n));
2290 else if (n < cat_code_base)
2292 if (n == cur_font_loc)
2293 print_string("current font");
2294 else if (n < math_font_base + 16)
2296 print_esc("textfont");
2297 print_int(n - math_font_base);
2299 else if (n < math_font_base + 32)
2301 print_esc("scriptfont");
2302 print_int(n - math_font_base - 16);
2306 print_esc("scriptscriptfont");
2307 print_int(n - math_font_base - 32);
2312 print(hash[font_id_base + equiv(n)].rh);
2314 else if (n < math_code_base)
2316 if (n < kcat_code_base)
2318 print_esc("catcode");
2319 print_int(n - cat_code_base);
2321 else if (n < auto_xsp_code_base)
2323 print_esc("kcatcode");
2324 print_int(n - kcat_code_base);
2326 else if (n < inhibit_xsp_code_base)
2328 print_esc("xspcode");
2329 print_int(n - auto_xsp_code_base);
2331 else if (n < kinsoku_base)
2333 print("(inhibitxspcode table) ");
2334 print_int(n - inhibit_xsp_code_base);
2336 else if (n < kansuji_base)
2338 print("(kinsoku table) ");
2339 print_int(n - kinsoku_base);
2341 else if (n < lc_code_base)
2343 print_esc("kansujichar");
2344 print_int(n - kansuji_base);
2346 else if (n < uc_code_base)
2348 print_esc("lccode");
2349 print_int(n - lc_code_base);
2351 else if (n < sf_code_base)
2353 print_esc("uccode");
2354 print_int(n - uc_code_base);
2358 print_esc("sfcode");
2359 print_int(n - sf_code_base);
2363 print_int(equiv(n));
2367 print_esc("mathcode");
2368 print_int(n - math_code_base);
2370 print_int(equiv(n));
2372 else if (n < dimen_base)
2375 print_param(n - int_base);
2376 else if (n < del_code_base)
2379 print_int(n - count_base);
2383 print_esc("delcode");
2384 print_int(n - del_code_base);
2388 print_int(eqtb[n].cint);
2390 else if (n < kinsoku_penalty_base)
2392 if (n < scaled_base)
2393 print_length_param(n - dimen_base);
2397 print_int(n - scaled_base);
2401 print_scaled(eqtb[n].cint);
2404 else if (n <= eqtb_size)
2405 print_string("kinsoku");
2411 halfword id_lookup_(integer j, integer l)
2420 for (k = j + 1; k <= j + l - 1; k++)
2422 h = h + h + buffer[k];
2424 while (h >= hash_prime)
2433 if (length(text(p)) == l)
2434 if (str_eq_buf(text(p), j))
2439 if (no_new_control_sequence)
2441 p = undefined_control_sequence;
2451 overflow("hash size", hash_size + hash_extra); /* 96/Jan/10 */
2452 return 0; // abort_flag set
2457 while (!(text(hash_used) == 0));
2460 if (hash_used > 65535L) /* debugging only 1996/Jan/20 */
2462 sprintf(log_line, "ERROR: %s too large %d\n", "hash entry", hash_used);
2463 show_line(log_line, 1);
2467 next(p) = hash_used;
2474 while (pool_ptr > str_start[str_ptr])
2477 str_pool[pool_ptr + l] = str_pool[pool_ptr];
2480 for (k = j; k <= j + l - 1; k++)
2481 append_char(buffer[k]);
2485 pool_pointer tempstring = make_string();
2487 if (tempstring > 65535L) /* cannot happen */
2489 sprintf(log_line, "ERROR: %s too large %d\n", "string ptr", tempstring);
2490 show_line(log_line, 1);
2492 text(p) = tempstring;
2495 text(p) = make_string();
2498 pool_ptr = pool_ptr + d;
2505 str_pool[pool_ptr] = '\0';
2506 sprintf(log_line, " tex1 cs_count++ '%s' ", &str_pool[pool_ptr - l - d]);
2507 show_line(log_line, 0); /* debugging */
2521 void new_save_level_(group_code c)
2523 if (save_ptr > max_save_stack)
2525 max_save_stack = save_ptr;
2527 #ifdef ALLOCATESAVESTACK
2528 if (max_save_stack > current_save_size - 6)
2529 save_stack = realloc_save_stack(increment_save_size);
2531 if (max_save_stack > current_save_size - 6) /* check again after allocation */
2533 overflow("save size", current_save_size);
2534 return; // abort_flag set
2537 if (max_save_stack > save_size - 6) /* save size - not dynamic */
2539 overflow("save size", save_size);
2540 return; // abort_flag set
2545 save_type(save_ptr) = level_boundary;
2546 save_level(save_ptr) = (quarterword) cur_group;
2547 save_index(save_ptr) = cur_boundary;
2549 if (cur_level == max_quarterword)
2551 overflow("grouping levels", max_quarterword - min_quarterword); /* 96/Oct/12 ??? */
2552 return; // abort_flag set
2555 cur_boundary = save_ptr;
2561 void eq_destroy_(memory_word w)
2565 switch (eq_type_field(w))
2570 case long_outer_call:
2571 delete_token_ref(equiv_field(w));
2575 delete_glue_ref(equiv_field(w));
2582 free_node(q, info(q) + info(q) + 1);
2586 flush_node_list(equiv_field(w));
2594 void eq_save_(halfword p, quarterword l)
2596 if (save_ptr > max_save_stack)
2598 max_save_stack = save_ptr;
2600 #ifdef ALLOCATESAVESTACK
2601 if (max_save_stack > current_save_size - 6)
2602 save_stack = realloc_save_stack (increment_save_size);
2604 if (max_save_stack > current_save_size - 6) /* check again after allocation */
2606 overflow("save size", current_save_size);
2607 return; // abort_flag set
2610 if (max_save_stack > save_size - 6) /* save size not dynamic */
2612 overflow("save size", save_size);
2613 return; // abort_flag set
2618 if (l == level_zero)
2619 save_type(save_ptr) = restore_zero;
2622 save_stack[save_ptr] = eqtb[p];
2624 save_type(save_ptr) = restore_old_value;
2627 save_level(save_ptr) = l;
2628 save_index(save_ptr) = p;
2632 void eq_define_(halfword p, quarterword t, halfword e)
2634 if (eq_level(p) == cur_level)
2635 eq_destroy(eqtb[p]);
2636 else if (cur_level > level_one)
2637 eq_save(p, eq_level(p));
2639 eq_level(p) = (quarterword) cur_level; /* because cur_level padded out */
2644 void eq_word_define_(halfword p, integer w)
2646 if (xeq_level[p] != cur_level)
2648 eq_save(p, xeq_level[p]);
2649 xeq_level[p] = (quarterword) cur_level; /* because cur_level padded out */
2655 void geq_define_(halfword p, quarterword t, halfword e)
2657 eq_destroy(eqtb[p]);
2658 eq_level(p) = level_one;
2663 void geq_word_define_(halfword p, integer w)
2669 void save_for_after_(halfword t)
2673 if (save_ptr > max_save_stack)
2675 max_save_stack = save_ptr;
2677 #ifdef ALLOCATESAVESTACK
2678 if (max_save_stack > current_save_size - 6)
2679 save_stack = realloc_save_stack (increment_save_size);
2681 if (max_save_stack > current_save_size - 6) /* check again after allocation */
2683 overflow("save size", current_save_size);
2684 return; // abort_flag set
2687 if (max_save_stack > save_size - 6) /* save satck - not dynamic */
2689 overflow("save size", save_size);
2690 return; // abort_flag set
2695 save_type(save_ptr) = insert_token;
2696 save_level(save_ptr) = level_zero;
2697 save_index(save_ptr) = t;
2701 /* restore_trace_, unsave followed in the old tex1.c */