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
22 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
24 void show_box_(halfword p)
26 depth_threshold = show_box_depth;
27 breadth_max = show_box_breadth;
33 if (pool_ptr + depth_threshold >= current_pool_size)
34 str_pool = realloc_str_pool(increment_pool_size);
36 if (pool_ptr + depth_threshold >= current_pool_size)
37 depth_threshold = current_pool_size - pool_ptr - 1;
39 if (pool_ptr + depth_threshold >= pool_size)
40 depth_threshold = pool_size - pool_ptr - 1;
47 void delete_token_ref_(halfword p)
49 if (token_ref_count(p) == 0)
52 decr(token_ref_count(p));
55 void delete_glue_ref_(halfword p)
57 if (glue_ref_count(p) == 0)
58 free_node(p, glue_spec_size);
60 decr(glue_ref_count(p));
63 void flush_node_list_(halfword p)
67 while (p != 0) { /* while p<>null */
80 flush_node_list(list_ptr(p));
81 free_node(p, box_node_size);
87 free_node(p, rule_node_size);
93 flush_node_list(ins_ptr(p));
94 delete_glue_ref(split_top_ptr(p));
95 free_node(p, ins_node_size);
104 free_node(p, open_node_size);
109 delete_token_ref(write_tokens(p));
110 free_node(p, write_node_size);
115 case set_language_code:
116 free_node(p, small_node_size);
121 return; // abort_flag set
130 if (mem[mem[p + 1].hh.v.LH].hh.v.RH == 0)
131 free_node(mem[p + 1].hh.v.LH, 4);
133 decr(mem[mem[p + 1].hh.v.LH].hh.v.RH);
136 if (leader_ptr(p) != 0)
137 flush_node_list(leader_ptr(p));
144 flush_node_list(lig_ptr(p));
147 delete_token_ref(mark_ptr(p));
150 flush_node_list(pre_break(p));
151 flush_node_list(post_break(p));
154 flush_node_list(adjust_ptr(p));
158 free_node(p, style_node_size);
164 flush_node_list(display_mlist(p));
165 flush_node_list(text_mlist(p));
166 flush_node_list(script_mlist(p));
167 flush_node_list(script_script_mlist(p));
168 free_node(p, style_node_size);
186 if (math_type(nucleus(p)) >= sub_box)
187 flush_node_list(info(nucleus(p)));
189 if (math_type(supscr(p)) >= sub_box)
190 flush_node_list(info(supscr(p)));
192 if (math_type(subscr(p)) >= sub_box)
193 flush_node_list(info(subscr(p)));
195 if (type(p) == radical_noad)
196 free_node(p, radical_noad_size);
199 if (type(p) == accent_noad)
200 free_node(p, accent_noad_size);
202 free_node(p, noad_size);
210 free_node(p, noad_size);
216 flush_node_list(info(numerator(p)));
217 flush_node_list(info(denominator(p)));
218 free_node(p, fraction_noad_size);
224 confusion("flushing");
225 return; // abort_flag set
229 free_node(p, small_node_size);
236 halfword copy_node_list_(halfword p)
238 register halfword Result;
247 while (p != 0) { /* while p<>null do l.3969 */
250 if ((p >= hi_mem_min))
252 else switch (type(p))
258 r = get_node(box_node_size);
259 mem[r + 6] = mem[p + 6];
260 mem[r + 5] = mem[p + 5];
261 list_ptr(r) = copy_node_list(list_ptr(p));
267 r = get_node(rule_node_size);
268 words = rule_node_size;
273 r = get_node(ins_node_size);
274 mem[r + 4] = mem[p + 4];
275 add_glue_ref(split_top_ptr(p));
276 ins_ptr(r) = copy_node_list(ins_ptr(p));
277 words = ins_node_size - 1;
285 r = get_node(open_node_size);
286 words = open_node_size;
293 r = get_node(write_node_size);
294 add_token_ref(write_tokens(p));
295 words = write_node_size;
302 r = get_node(small_node_size);
303 words = small_node_size;
310 return 0; // abort_flag set
318 r = get_node(small_node_size);
319 add_glue_ref(glue_ptr(p));
320 glue_ptr(r) = glue_ptr(p);
321 leader_ptr(r) = copy_node_list(leader_ptr(p));
329 r = get_node(small_node_size);
330 words = small_node_size;
336 r = get_node(small_node_size);
337 mem[lig_char(r)] = mem[lig_char(p)];
338 lig_ptr(r) = copy_node_list(lig_ptr(p));
344 r = get_node(small_node_size);
345 pre_break(r) = copy_node_list(pre_break(p));
346 post_break(r) = copy_node_list(pre_break(p));
352 r = get_node(small_node_size);
353 add_token_ref(mark_ptr(p));
354 words = small_node_size;
360 r = get_node(small_node_size);
361 adjust_ptr(r) = copy_node_list(adjust_ptr(p));
367 confusion("copying");
368 return 0; // abort_flag set
376 mem[r + words] = mem[p + words]; /* r may be used without having ... */
392 void print_mode_(integer m)
396 switch (m / (max_command + 1))
399 print_string("vertical");
402 print_string("horizontal");
405 print_string("display math");
417 switch ((- (integer) m) / (max_command + 1))
420 print_string("internal vertical");
423 print_string("restricted horizontal");
426 print_string("math");
431 print_string(" mode");
434 void push_nest (void)
436 if (nest_ptr > max_nest_stack)
438 max_nest_stack = nest_ptr;
440 #ifdef ALLOCATEINPUTSTACK
441 if (nest_ptr == current_nest_size)
442 nest = realloc_nest_stack(increment_nest_size);
444 if (nest_ptr == current_nest_size) /* check again after allocation */
446 overflow("semantic nest size", current_nest_size);
447 return; // abort_flag set
450 if (nest_ptr == nest_size)
452 overflow("semantic nest size", nest_size); /* semantic next size - not dynamic */
453 return; // abort_flag set
457 nest[nest_ptr]= cur_list;
469 cur_list = nest[nest_ptr];
472 void show_activities (void)
480 nest[nest_ptr] = cur_list;
484 for (p = nest_ptr; p >= 0; p--)
486 m = nest[p].mode_field;
487 a = nest[p].aux_field;
490 print_string(" entered at line ");
491 print_int(abs(nest[p].ml_field));
495 if (nest[p].pg_field != 040600000)
497 print_string(" (language");
498 print_int(nest[p].pg_field % 65536L);
499 print_string(":hyphenmin");
500 print_int(nest[p].pg_field / 4194304L);
502 print_int((nest[p].pg_field / 65536L) % 64);
507 if (nest[p].ml_field < 0)
509 print_string(" (\\output routine)");
514 if (page_head != page_tail)
516 print_nl("### current page:");
520 print_string(" (held over for next output)");
523 show_box(link(page_head));
525 if (page_contents > 0)
527 print_nl("total height ");
529 print_nl(" goal height ");
530 print_scaled(page_so_far[0]);
531 r = link(page_ins_head);
539 print_string(" adds ");
541 if (count(t) == 1000)
544 t = x_over_n(height(r), 1000) * count(t);
548 if (type(r) == split_up)
557 if ((type(q) == ins_node) && (subtype(q) == subtype(r)))
560 while (!(q == broken_ins(r)));
564 print_string(" might split");
571 if (link(contrib_head) != 0)
572 print_nl("### recent contributions:");
575 show_box(link(nest[p].head_field));
577 switch (abs(m) / (max_command + 1))
581 print_nl("prevdepth ");
583 if (a.cint <= ignore_depth)
584 print_string("ignored");
586 print_scaled(a.cint);
588 if (nest[p].pg_field != 0)
590 print_string(", prevgraf ");
591 print_int(nest[p].pg_field);
592 print_string(" line");
594 if (nest[p].pg_field != 1)
602 print_nl("spacefactor ");
603 print_int(a.hh.v.LH);
609 print_string(", current language ");
610 print_int(a.hh.v.RH);
619 print_string("this will be denominator of:");
627 void print_param_(integer n)
631 case pretolerance_code:
632 print_esc("pretolerance");
636 print_esc("tolerance");
639 case line_penalty_code:
640 print_esc("linepenalty");
643 case hyphen_penalty_code:
644 print_esc("hyphenpenalty");
647 case ex_hyphen_penalty_code:
648 print_esc("exhyphenpenalty");
651 case club_penalty_code:
652 print_esc("clubpenalty");
655 case widow_penalty_code:
656 print_esc("widowpenalty");
659 case display_widow_penalty_code:
660 print_esc("displaywidowpenalty");
663 case broken_penalty_code:
664 print_esc("brokenpenalty");
667 case bin_op_penalty_code:
668 print_esc("binoppenalty");
671 case rel_penalty_code:
672 print_esc("relpenalty");
675 case pre_display_penalty_code:
676 print_esc("predisplaypenalty");
679 case post_display_penalty_code:
680 print_esc("postdisplaypenalty");
683 case inter_line_penalty_code:
684 print_esc("interlinepenalty");
687 case double_hyphen_demerits_code:
688 print_esc("doublehyphendemerits");
691 case final_hyphen_demerits_code:
692 print_esc("finalhyphendemerits");
695 case adj_demerits_code:
696 print_esc("adjdemerits");
703 case delimiter_factor_code:
704 print_esc("delimiterfactor");
708 print_esc("looseness");
727 case show_box_breadth_code:
728 print_esc("showboxbreadth");
731 case show_box_depth_code:
732 print_esc("showboxdepth");
736 print_esc("hbadness");
740 print_esc("vbadness");
744 print_esc("pausing");
747 case tracing_online_code:
748 print_esc("tracingonline");
751 case tracing_macros_code:
752 print_esc("tracingmacros");
755 case tracing_stats_code:
756 print_esc("tracingstats");
759 case tracing_paragraphs_code:
760 print_esc("tracingparagraphs");
763 case tracing_pages_code:
764 print_esc("tracingpages");
767 case tracing_output_code:
768 print_esc("tracingoutput");
771 case tracing_lost_chars_code:
772 print_esc("tracinglostchars");
775 case tracing_commands_code:
776 print_esc("tracingcommands");
779 case tracing_restores_code:
780 print_esc("tracingrestores");
787 case output_penalty_code:
788 print_esc("outputpenalty");
791 case max_dead_cycles_code:
792 print_esc("maxdeadcycles");
795 case hang_after_code:
796 print_esc("hangafter");
799 case floating_penalty_code:
800 print_esc("floatingpenalty");
803 case global_defs_code:
804 print_esc("globaldefs");
811 case escape_char_code:
812 print_esc("escapechar");
815 case default_hyphen_char_code:
816 print_esc("defaulthyphenchar");
819 case default_skew_char_code:
820 print_esc("defaultskewchar");
823 case end_line_char_code:
824 print_esc("endlinechar");
827 case new_line_char_code:
828 print_esc("newlinechar");
832 print_esc("language");
835 case left_hyphen_min_code:
836 print_esc("lefthyphenmin");
839 case right_hyphen_min_code:
840 print_esc("righthyphenmin");
843 case holding_inserts_code:
844 print_esc("holdinginserts");
847 case error_context_lines_code:
848 print_esc("errorcontextlines");
852 print_string("[unknown integer parameter!]");
857 void begin_diagnostic (void)
859 old_setting = selector;
861 if ((tracing_online <= 0) && (selector == term_and_log))
865 if (history == spotless)
866 history = warning_issued;
870 void end_diagnostic_(bool blankline)
877 selector = old_setting;
880 void print_length_param_ (integer n)
884 case par_indent_code:
885 print_esc("parindent");
888 case math_surround_code:
889 print_esc("mathsurround");
892 case line_skip_limit_code:
893 print_esc("lineskiplimit");
905 print_esc("maxdepth");
908 case split_max_depth_code:
909 print_esc("splitmaxdepth");
912 case box_max_depth_code:
913 print_esc("boxmaxdepth");
924 case delimiter_shortfall_code:
925 print_esc("delimitershortfall");
928 case null_delimiter_space_code:
929 print_esc("nulldelimiterspace");
932 case script_space_code:
933 print_esc("scriptspace");
936 case pre_display_size_code:
937 print_esc("predisplaysize");
940 case display_width_code:
941 print_esc("displaywidth");
944 case display_indent_code:
945 print_esc("displayindent");
948 case overfull_rule_code:
949 print_esc("overfullrule");
952 case hang_indent_code:
953 print_esc("hangindent");
957 print_esc("hoffset");
961 print_esc("voffset");
964 case emergency_stretch_code:
965 print_esc("emergencystretch");
969 print_string("[unknown dimen parameter!]");
974 void print_cmd_chr_ (quarterword cmd, halfword chr_code)
979 print_string("begin-group character ");
984 print_string("end-group character ");
989 print_string("math shift character ");
994 print_string("macro parameter character ");
999 print_string("superscript character ");
1004 print_string("subscript character ");
1009 print_string("end of alignment template");
1013 print_string("blank space ");
1018 print_string("the letter ");
1023 print_string("the character ");
1028 case assign_mu_glue:
1029 if (chr_code < skip_base)
1031 print_skip_param(chr_code - glue_base);
1035 if (chr_code < mu_skip_base)
1038 print_int(chr_code - skip_base);
1042 print_esc("muskip");
1043 print_int(chr_code - mu_skip_base);
1049 if (chr_code >= toks_base)
1052 print_int(chr_code - toks_base);
1058 case output_routine_loc:
1059 print_esc("output");
1063 print_esc("everypar");
1066 case every_math_loc:
1067 print_esc("everymath");
1070 case every_display_loc:
1071 print_esc("everydisplay");
1074 case every_hbox_loc:
1075 print_esc("everyhbox");
1078 case every_vbox_loc:
1079 print_esc("everyvbox");
1083 print_esc("everyjob");
1087 print_esc("everycr");
1091 print_esc("errhelp");
1098 if (chr_code < count_base)
1100 print_param(chr_code - int_base);
1105 print_int(chr_code - count_base);
1110 if (chr_code < scaled_base)
1112 print_length_param(chr_code - dimen_base);
1117 print_int(chr_code - scaled_base);
1122 print_esc("accent");
1126 print_esc("advance");
1129 case after_assignment:
1130 print_esc("afterassignment");
1134 print_esc("aftergroup");
1137 case assign_font_dimen:
1138 print_esc("fontdimen");
1142 print_esc("begingroup");
1146 print_esc("penalty");
1154 print_esc("csname");
1162 print_esc("delimiter");
1166 print_esc("divide");
1170 print_esc("endcsname");
1174 print_esc("endgroup");
1182 print_esc("expandafter");
1186 print_esc("halign");
1194 print_esc("ignorespaces");
1198 print_esc("insert");
1210 print_esc("mathaccent");
1214 print_esc("mathchar");
1218 print_esc("mathchoice");
1222 print_esc("multiply");
1226 print_esc("noalign");
1230 print_esc("noboundary");
1234 print_esc("noexpand");
1238 print_esc("nonscript");
1246 print_esc("radical");
1258 print_esc("setbox");
1262 print_esc("prevgraf");
1266 print_esc("parshape");
1278 print_esc("vadjust");
1282 print_esc("valign");
1286 print_esc("vcenter");
1301 print_esc("endinput");
1307 case first_mark_code:
1308 print_esc("firstmark");
1312 print_esc("botmark");
1315 case split_first_mark_code:
1316 print_esc("splitfirstmark");
1319 case split_bot_mark_code:
1320 print_esc("splitbotmark");
1324 print_esc("topmark");
1330 if (chr_code == int_val)
1332 else if (chr_code == dimen_val)
1334 else if (chr_code == glue_val)
1337 print_esc("muskip");
1341 if (chr_code == vmode)
1342 print_esc("prevdepth");
1344 print_esc("spacefactor");
1349 print_esc("deadcycles");
1351 print_esc("insertpenalties");
1355 if (chr_code == width_offset)
1357 else if (chr_code == height_offset)
1367 print_esc("lastpenalty");
1371 print_esc("lastkern");
1375 print_esc("lastskip");
1378 case input_line_no_code:
1379 print_esc("inputlineno");
1383 print_esc("badness");
1392 print_esc("number");
1395 case roman_numeral_code:
1396 print_esc("romannumeral");
1400 print_esc("string");
1404 print_esc("meaning");
1407 case font_name_code:
1408 print_esc("fontname");
1412 print_esc("jobname");
1437 print_esc("ifvmode");
1441 print_esc("ifhmode");
1445 print_esc("ifmmode");
1449 print_esc("ifinner");
1453 print_esc("ifvoid");
1457 print_esc("ifhbox");
1461 print_esc("ifvbox");
1473 print_esc("iftrue");
1477 print_esc("iffalse");
1481 print_esc("ifcase");
1491 if (chr_code == fi_code)
1493 else if (chr_code == or_code)
1500 if (chr_code == span_code)
1504 print_string("alignment tab character ");
1510 if (chr_code == cr_code)
1516 case set_page_dimen:
1520 print_esc("pagegoal");
1524 print_esc("pagetotal");
1528 print_esc("pagestretch");
1532 print_esc("pagefilstretch");
1536 print_esc("pagefillstretch");
1540 print_esc("pagefilllstretch");
1544 print_esc("pageshrink");
1548 print_esc("pagedepth");
1580 print_esc("hfilneg");
1605 print_esc("vfilneg");
1624 print_esc("moveleft");
1626 print_esc("moveright");
1648 print_esc("lastbox");
1652 print_esc("vsplit");
1659 case vtop_code + vmode:
1670 if (chr_code == a_leaders)
1671 print_esc("leaders");
1672 else if (chr_code == c_leaders)
1673 print_esc("cleaders");
1674 else if (chr_code == x_leaders)
1675 print_esc("xleaders");
1677 print_esc("shipout");
1682 print_esc("noindent");
1684 print_esc("indent");
1688 if (chr_code == glue_node)
1689 print_esc("unskip");
1690 else if (chr_code == kern_node)
1691 print_esc("unkern");
1693 print_esc("unpenalty");
1697 if (chr_code == copy_code)
1698 print_esc("unhcopy");
1700 print_esc("unhbox");
1704 if (chr_code == copy_code)
1705 print_esc("unvcopy");
1707 print_esc("unvbox");
1714 print_esc("discretionary");
1728 print_esc("mathord");
1732 print_esc("mathop");
1736 print_esc("mathbin");
1740 print_esc("mathrel");
1744 print_esc("mathopen");
1748 print_esc("mathclose");
1752 print_esc("mathpunct");
1756 print_esc("mathinner");
1760 print_esc("underline");
1764 print_esc("overline");
1770 if (chr_code == limits)
1771 print_esc("limits");
1772 else if (chr_code == no_limits)
1773 print_esc("nolimits");
1775 print_esc("displaylimits");
1779 print_style(chr_code);
1793 case delimited_code + above_code:
1794 print_esc("abovewithdelims");
1797 case delimited_code + over_code:
1798 print_esc("overwithdelims");
1801 case delimited_code + atop_code:
1802 print_esc("atopwithdelims");
1812 if (chr_code == left_noad)
1821 else if (chr_code == 2)
1824 print_esc("global");
1830 else if (chr_code == 1)
1832 else if (chr_code == 2)
1839 if (chr_code != normal)
1840 print_esc("futurelet");
1849 print_esc("chardef");
1852 case math_char_def_code:
1853 print_esc("mathchardef");
1856 case count_def_code:
1857 print_esc("countdef");
1860 case dimen_def_code:
1861 print_esc("dimendef");
1865 print_esc("skipdef");
1868 case mu_skip_def_code:
1869 print_esc("muskipdef");
1873 print_esc("toksdef");
1880 print_hex(chr_code);
1884 print_esc("mathchar");
1885 print_hex(chr_code);
1889 if (chr_code == cat_code_base)
1890 print_esc("catcode");
1891 else if (chr_code == math_code_base)
1892 print_esc("mathcode");
1893 else if (chr_code == lc_code_base)
1894 print_esc("lccode");
1895 else if (chr_code == uc_code_base)
1896 print_esc("uccode");
1897 else if (chr_code == sf_code_base)
1898 print_esc("sfcode");
1900 print_esc("delcode");
1904 print_size(chr_code - math_font_base);
1909 print_esc("patterns");
1911 print_esc("hyphenation");
1914 case assign_font_int:
1916 print_esc("hyphenchar");
1918 print_esc("skewchar");
1922 print_string("select font ");
1923 slow_print(font_name[chr_code]);
1925 if (font_size[chr_code] != font_dsize[chr_code])
1927 print_string(" at ");
1928 print_scaled(font_size[chr_code]);
1933 case set_interaction:
1937 print_esc("batchmode");
1941 print_esc("nonstopmode");
1945 print_esc("scrollmode");
1949 print_esc("errorstopmode");
1956 print_esc("closein");
1958 print_esc("openin");
1963 print_esc("message");
1965 print_esc("errmessage");
1969 if (chr_code == lc_code_base)
1970 print_esc("lowercase");
1972 print_esc("uppercase");
1979 print_esc("showbox");
1983 print_esc("showthe");
1987 print_esc("showlists");
1997 print_string("undefined");
2001 print_string("macro");
2005 print_esc("long macro");
2009 print_esc("outer macro");
2012 case long_outer_call:
2014 print_esc("outer macro");
2018 print_esc("outer endtemplate");
2025 print_esc("openout");
2033 print_esc("closeout");
2037 print_esc("special");
2040 case immediate_code:
2041 print_esc("immediate");
2044 case set_language_code:
2045 print_esc("setlanguage");
2049 print_string("[unknown extension!]");
2055 print_string("[unknown command code!]");
2061 void show_eqtb_(halfword n)
2063 if (n < active_base)
2070 print_cmd_chr(eq_type(n), equiv(n));
2072 if (eq_type(n) >= call)
2075 show_token_list(link(equiv(n)), 0, 32);
2082 print_skip_param(n - glue_base);
2085 if (n < glue_base + thin_mu_skip_code)
2086 print_spec(equiv(n), "pt");
2088 print_spec(equiv(n), "mu");
2091 if (n < mu_skip_base)
2094 print_int(n - skip_base);
2096 print_spec(equiv(n), "pt");
2100 print_esc("muskip");
2101 print_int(n - mu_skip_base);
2103 print_spec(equiv(n), "mu");
2107 if (n == par_shape_loc)
2109 print_esc("parshape");
2112 if (par_shape_ptr == 0)
2115 print_int(info(par_shape_ptr));
2120 print_cmd_chr(assign_toks, n);
2124 show_token_list(link(equiv(n)), 0, 32);
2130 print_int(n - toks_base);
2134 show_token_list(link(equiv(n)), 0, 32);
2137 if (n < cur_font_loc)
2140 print_int(n - box_base);
2144 print_string("void");
2147 depth_threshold = 0;
2149 show_node_list(equiv(n));
2153 if (n < cat_code_base)
2155 if (n == cur_font_loc)
2156 print_string("current font");
2158 if (n < math_font_base + 16)
2160 print_esc("textfont");
2161 print_int(n - math_font_base);
2164 if (n < math_font_base + 32)
2166 print_esc("scriptfont");
2167 print_int(n - math_font_base - 16);
2171 print_esc("scriptscriptfont");
2172 print_int(n - math_font_base - 32);
2177 print(hash[font_id_base + equiv(n)].v.RH);
2180 if (n < math_code_base)
2182 if (n < lc_code_base)
2184 print_esc("catcode");
2185 print_int(n - cat_code_base);
2188 if (n < uc_code_base)
2190 print_esc("lccode");
2191 print_int(n - lc_code_base);
2194 if (n < sf_code_base)
2196 print_esc("uccode");
2197 print_int(n - uc_code_base);
2201 print_esc("sfcode");
2202 print_int(n - sf_code_base);
2206 print_int(equiv(n));
2210 print_esc("mathcode");
2211 print_int(n - math_code_base);
2213 print_int(equiv(n));
2219 print_param(n - int_base);
2221 if (n < del_code_base)
2224 print_int(n - count_base);
2228 print_esc("delcode");
2229 print_int(n - del_code_base);
2233 print_int(eqtb[n].cint);
2238 if (n < scaled_base)
2239 print_length_param(n - dimen_base);
2243 print_int(n - scaled_base);
2247 print_scaled(eqtb[n].cint);
2255 halfword id_lookup_(integer j, integer l)
2264 for (k = j + 1; k <= j + l - 1; k++)
2266 h = h + h + buffer[k];
2268 while (h >= hash_prime)
2277 if (length(text(p)) == l)
2278 if (str_eq_buf(text(p), j))
2283 if (no_new_control_sequence)
2285 p = undefined_control_sequence;
2295 overflow("hash size", hash_size + hash_extra); /* 96/Jan/10 */
2296 return 0; // abort_flag set
2301 while (!(text(hash_used) == 0));
2304 if (hash_used > 65535L) /* debugging only 1996/Jan/20 */
2306 sprintf(log_line, "ERROR: %s too large %d\n", "hash entry", hash_used);
2307 show_line(log_line, 1);
2311 next(p) = hash_used;
2318 while (pool_ptr > str_start[str_ptr])
2321 str_pool[pool_ptr + l] = str_pool[pool_ptr];
2324 for (k = j; k <= j + l - 1; k++)
2325 append_char(buffer[k]);
2329 pool_pointer tempstring = make_string();
2331 if (tempstring > 65535L) /* cannot happen */
2333 sprintf(log_line, "ERROR: %s too large %d\n", "string ptr", tempstring);
2334 show_line(log_line, 1);
2336 text(p) = tempstring;
2339 text(p) = make_string();
2342 pool_ptr = pool_ptr + d;
2349 str_pool[pool_ptr] = '\0';
2350 sprintf(log_line, " tex1 cs_count++ '%s' ", &str_pool[pool_ptr-l-d]);
2351 show_line(log_line, 0); /* debugging */
2365 void new_save_level_(group_code c)
2367 if (save_ptr > max_save_stack)
2369 max_save_stack = save_ptr;
2371 #ifdef ALLOCATESAVESTACK
2372 if (max_save_stack > current_save_size - 6)
2373 save_stack = realloc_save_stack(increment_save_size);
2375 if (max_save_stack > current_save_size - 6) /* check again after allocation */
2377 overflow("save size", current_save_size);
2378 return; // abort_flag set
2381 if (max_save_stack > save_size - 6) /* save size - not dynamic */
2383 overflow("save size", save_size);
2384 return; // abort_flag set
2388 save_type(save_ptr) = level_boundary;
2389 save_level(save_ptr) = (quarterword) cur_group;
2390 save_index(save_ptr) = cur_boundary;
2392 if (cur_level == max_quarterword)
2394 overflow("grouping levels", max_quarterword - min_quarterword); /* 96/Oct/12 ??? */
2395 return; // abort_flag set
2398 cur_boundary = save_ptr;
2404 void eq_destroy_(memory_word w)
2408 switch (eq_type_field(w))
2413 case long_outer_call:
2414 delete_token_ref(equiv_field(w));
2418 delete_glue_ref(equiv_field(w));
2425 free_node(q, info(q) + info(q) + 1);
2429 flush_node_list(equiv_field(w));
2437 void eq_save_(halfword p, quarterword l)
2439 if (save_ptr > max_save_stack)
2441 max_save_stack = save_ptr;
2443 #ifdef ALLOCATESAVESTACK
2444 if (max_save_stack > current_save_size - 6)
2445 save_stack = realloc_save_stack (increment_save_size);
2447 if (max_save_stack > current_save_size - 6) /* check again after allocation */
2449 overflow("save size", current_save_size);
2450 return; // abort_flag set
2453 if (max_save_stack > save_size - 6) /* save size not dynamic */
2455 overflow("save size", save_size);
2456 return; // abort_flag set
2461 if (l == level_zero)
2462 save_type(save_ptr) = restore_zero;
2465 save_stack[save_ptr] = eqtb[p];
2467 save_type(save_ptr) = restore_old_value;
2470 save_level(save_ptr) = l;
2471 save_index(save_ptr) = p;
2475 void eq_define_(halfword p, quarterword t, halfword e)
2477 if (eq_level(p) == cur_level)
2478 eq_destroy(eqtb[p]);
2479 else if (cur_level > level_one)
2480 eq_save(p, eq_level(p));
2482 eq_level(p) = (quarterword) cur_level; /* because cur_level padded out */
2487 void eq_word_define_(halfword p, integer w)
2489 if (xeq_level[p] != cur_level)
2491 eq_save(p, xeq_level[p]);
2492 xeq_level[p] = (quarterword) cur_level; /* because cur_level padded out */
2498 void geq_define_(halfword p, quarterword t, halfword e)
2500 eq_destroy(eqtb[p]);
2501 eq_level(p) = level_one;
2506 void geq_word_define_(halfword p, integer w)
2512 void save_for_after_(halfword t)
2516 if (save_ptr > max_save_stack)
2518 max_save_stack = save_ptr;
2520 #ifdef ALLOCATESAVESTACK
2521 if (max_save_stack > current_save_size - 6)
2522 save_stack = realloc_save_stack (increment_save_size);
2524 if (max_save_stack > current_save_size - 6) /* check again after allocation */
2526 overflow("save size", current_save_size);
2527 return; // abort_flag set
2530 if (max_save_stack > save_size - 6) /* save satck - not dynamic */
2532 overflow("save size", save_size);
2533 return; // abort_flag set
2538 save_type(save_ptr) = insert_token;
2539 save_level(save_ptr) = level_zero;
2540 save_index(save_ptr) = t;
2544 /* restore_trace_, unsave followed in the old tex1.c */