6 #pragma warning(disable:4115) // kill rpcasync.h complaint
8 #define MYLIBAPI __declspec(dllexport)
13 #pragma warning(disable:4131) // old style declarator
14 #pragma warning(disable:4135) // conversion between different integral types
15 #pragma warning(disable:4127) // conditional expression is constant
23 #pragma warning(disable:4244) /* 96/Jan/10 */
25 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
27 void build_page (void)
33 /* unsigned char n; */
34 unsigned int n; /* 95/Jan/7 */
37 /* begin if (link(contrib_head)=null)or output_active then return; l.19351 */
38 if ((mem[contrib_head].hh.v.RH == 0) || output_active)
43 p = mem[contrib_head].hh.v.RH;
44 /* if (last_glue != 262143L) */
45 if (last_glue != empty_flag)
46 delete_glue_ref(last_glue);
49 if (mem[p].hh.b0 == 10)
51 last_glue = mem[p + 1].hh.v.LH;
52 incr(mem[last_glue].hh.v.RH);
56 /* last_glue = 262143L; */
57 last_glue = empty_flag;
58 if (mem[p].hh.b0 == 12)
59 last_penalty = mem[p + 1].cint;
60 else if (mem[p].hh.b0 == 11)
61 last_kern = mem[p + 1].cint;
68 if (page_contents < 2)
70 if (page_contents == 0)
74 q = new_skip_param(9);
75 if (mem[temp_ptr + 1].cint > mem[p + 3].cint)
76 mem[temp_ptr + 1].cint = mem[temp_ptr + 1].cint - mem[p + 3].cint;
78 mem[temp_ptr + 1].cint = 0;
80 mem[contrib_head].hh.v.RH = q;
85 page_so_far[1] = page_so_far[1] + page_so_far[7] + mem[p + 3].cint;
86 page_so_far[7] = mem[p + 2].cint;
94 if (page_contents < 2)
96 else if ((mem[page_tail].hh.b0 < 9))
102 if (page_contents < 2)
104 else if (mem[p].hh.v.RH == 0)
106 else if (mem[mem[p].hh.v.RH].hh.b0 == 10)
112 if (page_contents < 2)
115 pi = mem[p + 1].cint;
122 if (page_contents == 0)
123 freeze_page_specs(1);
126 while (n >= mem[mem[r].hh.v.RH].hh.b1)
129 if (mem[r].hh.b1 != n)
132 mem[q].hh.v.RH = mem[r].hh.v.RH;
138 if (eqtb[(hash_size + 1578) + n].hh.v.RH == 0)
141 mem[r + 3].cint = mem[eqtb[(hash_size + 1578) + n].hh.v.RH + 3].cint + mem[eqtb[(hash_size + 1578) + n].hh.v.RH + 2].cint;
142 mem[r + 2].hh.v.LH = 0;
143 q = eqtb[(hash_size + 800) + n].hh.v.RH;
144 if (eqtb[(hash_size + 3218) + n].cint == 1000)
147 h = x_over_n(mem[r + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint;
148 page_so_far[0]= page_so_far[0]- h - mem[q + 1].cint;
149 page_so_far[2 + mem[q].hh.b0]= page_so_far[2 + mem[q].hh.b0]+ mem[q + 2].cint;
150 page_so_far[6]= page_so_far[6]+ mem[q + 3].cint;
151 if ((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0))
153 print_err("Infinite glue shrinkage inserted from ");
156 help3("The correction glue for page breaking with insertions",
157 "must have finite shrinkability. But you may proceed,",
158 "since the offensive shrinkability has been made finite.");
162 if (mem[r].hh.b0 == 1)
163 insert_penalties = insert_penalties + mem[p + 1].cint;
166 mem[r + 2].hh.v.RH = p;
167 delta = page_so_far[0] - page_so_far[1] - page_so_far[7] + page_so_far[6];
168 if (eqtb[(hash_size + 3218) + n].cint == 1000)
171 h = x_over_n(mem[p + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint;
172 if (((h <= 0) || (h <= delta)) && (mem[p + 3].cint + mem[r + 3].cint <= eqtb[(hash_size + 3751) + n].cint))
174 page_so_far[0] = page_so_far[0]- h;
175 mem[r + 3].cint = mem[r + 3].cint + mem[p + 3].cint;
179 if (eqtb[(hash_size + 3218) + n].cint <= 0)
180 w = 1073741823L; /* 2^30 - 1 */
183 w = page_so_far[0] - page_so_far[1] - page_so_far[7];
184 if (eqtb[(hash_size + 3218) + n].cint != 1000)
185 w = x_over_n(w, eqtb[(hash_size + 3218) + n].cint)* 1000;
187 if (w > eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint)
188 w = eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint;
189 q = vert_break(mem[p + 4].hh.v.LH, w, mem[p + 2].cint);
190 mem[r + 3].cint = mem[r + 3].cint + best_height_plus_depth;
193 if (tracing_pages > 0)
201 print_scaled(best_height_plus_depth);
203 if (q == 0) /* if q=null l.19614 */
205 else if (mem[q].hh.b0 == 12)
206 print_int(mem[q + 1].cint);
209 end_diagnostic(false);
212 if (eqtb[(hash_size + 3218) + n].cint != 1000)
213 best_height_plus_depth = x_over_n(best_height_plus_depth, 1000) * eqtb[(hash_size + 3218) + n].cint;
214 page_so_far[0]= page_so_far[0]- best_height_plus_depth;
216 mem[r + 1].hh.v.RH = q;
217 mem[r + 1].hh.v.LH = p;
219 insert_penalties = insert_penalties - 10000;
220 else if (mem[q].hh.b0 == 12)
221 insert_penalties = insert_penalties + mem[q + 1].cint;
230 return; // abort_flag set
234 if (pi < 10000)/* pi may be used ... */
236 if (page_so_far[1] < page_so_far[0])
237 if ((page_so_far[3] != 0) || (page_so_far[4] != 0) || (page_so_far[5] != 0))
240 b = badness(page_so_far[0] - page_so_far[1], page_so_far[2]);
241 else if (page_so_far[1]- page_so_far[0]> page_so_far[6])
242 b = 1073741823L; /* 2^30 - 1 */
244 b = badness(page_so_far[1]- page_so_far[0], page_so_far[6]);
245 if (b < 1073741823L) /* 2^30 - 1 */
249 c = b + pi + insert_penalties;
254 if (insert_penalties >= 10000)
255 c = 1073741823L; /* 2^30 - 1 */
258 if (tracing_pages > 0)
265 print_scaled(page_so_far[0]);
267 if (b == 1073741823L) /* 2^30 - 1 */
274 if (c == 1073741823L) /* 2^30 - 1 */
278 if (c <= least_page_cost)
280 end_diagnostic(false);
283 if (c <= least_page_cost)
286 best_size = page_so_far[0];
288 r = mem[mem_top].hh.v.RH;
291 mem[r + 2].hh.v.LH = mem[r + 2].hh.v.RH;
295 if ((c == 1073741823L) || (pi <= -10000)) /* 2^30 - 1 */
303 if ((mem[p].hh.b0 < 10)||(mem[p].hh.b0 > 11))
306 if (mem[p].hh.b0 == 11)
310 q = mem[p + 1].hh.v.LH;
311 page_so_far[2 + mem[q].hh.b0] = page_so_far[2 + mem[q].hh.b0] + mem[q + 2].cint;
312 page_so_far[6]= page_so_far[6]+ mem[q + 3].cint;
313 if ((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0))
315 print_err("Infinite glue shrinkage found on current page");
316 help4("The page about to be output contains some infinitely",
317 "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
318 "Such glue doesn't belong there; but you can safely proceed,",
319 "since the offensive shrinkability has been made finite.");
324 mem[p + 1].hh.v.LH = r;
328 page_so_far[1] = page_so_far[1] + page_so_far[7] + mem[q + 1].cint;
331 if (page_so_far[7]> page_max_depth)
333 page_so_far[1] = page_so_far[1] + page_so_far[7] - page_max_depth;
334 page_so_far[7] = page_max_depth;
336 mem[page_tail].hh.v.RH = p;
338 mem[contrib_head].hh.v.RH = mem[p].hh.v.RH;
342 mem[contrib_head].hh.v.RH = mem[p].hh.v.RH;
346 } while (!(mem[contrib_head].hh.v.RH == 0));
350 nest[0].tail_field = contrib_head;
353 void app_space (void)
357 if ((space_factor >= 2000) && (xspace_skip != zero_glue))
358 q = new_param_glue(xspace_skip_code);
361 if (space_skip != zero_glue)
365 main_p = font_glue[cur_font];
368 main_p = new_spec(zero_glue);
369 main_k = param_base[cur_font] + 2;
370 width(main_p) = font_info[main_k].cint;
371 stretch(main_p) = font_info[main_k + 1].cint;
372 shrink(main_p) = font_info[main_k + 2].cint;
373 font_glue[cur_font] = main_p;
376 main_p = new_spec(main_p);
378 if (space_factor >= 2000)
379 width(main_p) = width(main_p) + font_info[7 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint;
380 stretch(main_p) = xn_over_d(stretch(main_p), space_factor, 1000);
381 shrink(main_p) = xn_over_d(shrink(main_p), 1000, space_factor);
382 q = new_glue(main_p);
383 glue_ref_count(main_p) = 0;
388 /* called from tex8.c only */
390 void insert_dollar_sign (void)
394 print_err("Missing $ inserted");
395 help2("I've inserted a begin-math/end-math symbol since I think",
396 "you left one out. Proceed, with fingers crossed.");
402 print_err("You can't use `");
403 print_cmd_chr(cur_cmd, cur_chr);
404 print_string("' in ");
408 void report_illegal_case (void)
411 help4("Sorry, but I'm not programmed to handle this case;",
412 "I'll just pretend that you didn't ask for it.",
413 "If you're in the wrong mode, you might be able to",
414 "return to the right one by typing `I}' or `I$' or `I\\par'.");
418 bool privileged (void)
426 report_illegal_case();
431 bool its_all_over (void)
433 register bool Result;
437 if ((page_head == page_tail) && (head == cur_list.tail_field) && (dead_cycles == 0))
443 tail_append(new_null_box());
445 tail_append(new_glue(8));
446 tail_append(new_penalty(-1073741824L));
453 void append_glue (void)
481 tail_append(new_glue(cur_val));
485 decr(mem[cur_val].hh.v.RH);
487 mem[tail].hh.b1 = 99;
491 void append_kern (void)
497 scan_dimen(s == mu_glue, false, false);
498 tail_append(new_kern(cur_val));
509 print_cmd_chr(cur_cmd, cur_chr);
510 help1("Things are pretty mixed up, but I think the worst is over.");
517 mem[temp_head].hh.v.RH = p;
518 print_err("Missing ");
524 /* mem[p].hh.v.LH = (hash_size + 4611); */
525 /* mem[p].hh.v.LH = (hash_size + 4095 + 516); */
526 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 516); /* 96/Jan/10 */
527 print_esc("endgroup");
532 mem[p].hh.v.LH = 804;
538 /* mem[p].hh.v.LH = (hash_size + 4612); */
539 /* mem[p].hh.v.LH = (hash_size + 4095 + 517); */
540 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 517); /* 96/Jan/10 */
541 mem[p].hh.v.RH = get_avail();
543 mem[p].hh.v.LH = 3118;
549 mem[p].hh.v.LH = 637;
554 print_string(" inserted");
555 begin_token_list(mem[temp_head].hh.v.RH, 4);
556 help5("I've inserted something that you may have forgotten.",
557 "(See the <inserted text> above.)",
558 "With luck, this will get me unwedged. But if you",
559 "really didn't forget anything, try typing `2' now; then",
560 "my insertion and my current dilemma will both disappear.");
564 /* only called from tex8.c */
566 void extra_right_brace (void)
568 print_err("Extra }, or forgotten ");
573 print_esc("endgroup");
582 help5("I've deleted a group-closing symbol because it seems to be",
583 "spurious, as in `$x}$'. But perhaps the } is legitimate and",
584 "you forgot something else, as in `\\hbox{$x}'. In such cases",
585 "the way to recover is to insert both the forgotten and the",
586 "deleted material, e.g., by typing `I$}'.");
591 void normal_paragraph (void)
594 eq_word_define(int_base + looseness_code, 0);
596 if (hang_indent != 0)
597 eq_word_define(dimen_base + hang_indent_code, 0);
600 eq_word_define(int_base + hang_after_code, 1);
602 if (par_shape_ptr != 0)
603 eq_define(par_shape_loc, shape_ref, 0);
606 void box_end_(integer boxcontext)
610 if (boxcontext < box_flag)
614 shift_amount(cur_box) = boxcontext;
615 if (abs(mode) == vmode)
617 append_to_vlist(cur_box);
618 if (adjust_tail != 0)
620 if (adjust_head != adjust_tail)
622 link(tail) = link(adjust_head);
633 if (abs(mode) == hmode)
638 math_type(nucleus(p)) = sub_box;
639 info(nucleus(p)) = cur_box;
642 link(tail) = cur_box;
647 else if (boxcontext < ship_out_flag)
648 if (boxcontext < (box_flag + 256))
649 eq_define((box_base - box_flag) + boxcontext, box_ref, cur_box);
651 geq_define((box_base - box_flag - 256) + boxcontext, box_ref, cur_box);
652 else if (cur_box != 0)
653 if (boxcontext > (ship_out_flag))
659 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
661 if (((cur_cmd == hskip) && (abs(mode)!= vmode)) || ((cur_cmd == vskip) && (abs(mode) == vmode)))
664 subtype(tail) = boxcontext - (leader_flag - a_leaders);
665 leader_ptr(tail) = cur_box;
669 print_err("Leaders not followed by proper glue");
670 help3("You should say `\\leaders <box or rule><hskip or vskip>'.",
671 "I found the <box or rule>, but there's no suitable",
672 "<hskip or vskip>, so I'm ignoring these leaders.");
674 flush_node_list(cur_box);
680 /* called only from tex8.c */
682 void begin_box_(integer boxcontext)
693 scan_eight_bit_int();
694 cur_box = box(cur_val);
700 scan_eight_bit_int();
701 cur_box = copy_node_list(box(cur_val));
708 if (abs(mode) == mmode)
711 help1("Sorry; this \\lastbox will be void.");
714 else if ((mode == vmode) && (head == cur_list.tail_field))
717 help2("Sorry...I usually can't take things from the current page.",
718 "This \\lastbox will therefore be void.");
723 if (!(tail >= hi_mem_min))
724 if ((type(tail) == hlist_node) || (type(tail) == vlist_node))
730 if (!(q >= hi_mem_min))
731 if (type(q) == disc_node)
733 for (m = 1; m <= replace_count(q); m++)
741 while (!(q == tail));
743 shift_amount(cur_box) = 0;
754 scan_eight_bit_int();
756 if (!scan_keyword("to"))
758 print_err("Missing `to' inserted");
759 help2("I'm working on `\\vsplit<box number> to <dimen>';",
760 "will look for the <dimen> next.");
763 scan_dimen(false, false, false);
764 cur_box = vsplit(n, cur_val);
769 k = cur_chr - vtop_code;
770 save_stack[save_ptr + 0].cint = boxcontext;
773 if ((boxcontext < box_flag) && (abs(mode) == vmode))
774 scan_spec(adjust_hbox_group, true);
776 scan_spec(hbox_group, true);
780 scan_spec(vbox_group, true);
783 scan_spec(vtop_group, true);
789 mode = - (integer) k;
793 prev_depth = ignore_depth;
796 begin_token_list(every_vbox, every_vbox_text);
803 begin_token_list(every_hbox, every_vbox_text);
812 void scan_box_(integer boxcontext)
818 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
820 if (cur_cmd == make_box)
822 begin_box(boxcontext);
824 else if ((boxcontext >= leader_flag) && ((cur_cmd == hrule) || (cur_cmd == vrule)))
826 cur_box = scan_rule_spec();
831 print_err("A <box> was supposed to be here");
832 help3("I was expecting to see \\hbox or \\vbox or \\copy or \\box or",
833 "something like that. So you might find something missing in",
834 "your output. But keep trying; you can fix this later.");
838 /****************************************************************************/
839 void package_ (small_number);
840 /****************************************************************************/
842 small_number norm_min_ (integer h)
852 void new_graf_(bool indented)
856 if ((mode == vmode) || (head != tail))
857 tail_append(new_param_glue(par_skip_code));
864 prev_graf =(norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;
868 tail = new_null_box();
870 width(tail) = par_indent;
874 begin_token_list(every_par, every_par_text);
879 /* procedure indent_in_hmode; l.21058 */
881 void indent_in_hmode (void)
888 width(p) = par_indent;
890 if (abs(mode) == hmode)
895 math_type(nucleus(q)) = sub_box;
896 info(nucleus(q)) = p;
902 /* only called from tex8.c */
904 void head_for_vmode (void)
907 if (cur_cmd != hrule)
911 print_err("You can't use `");
913 print_string("' here except with leaders");
914 help2("To put a horizontal rule in an hbox or an alignment,",
915 "you should use \\leaders or \\hrulefill (see The TeXbook).");
923 cur_input.index_field = inserted;
934 line_break(widow_penalty);
940 /* only called form tex8.c */
942 void begin_insert_or_adjust (void)
944 if (cur_cmd == vadjust)
948 scan_eight_bit_int();
952 print_err("You can't ");
955 help1("I'm changing to \\insert0; box 255 is special.");
960 save_stack[save_ptr + 0].cint = cur_val;
962 new_save_level(insert_group);
967 prev_depth = ignore_depth;
970 void make_mark (void)
973 p = scan_toks(false, true);
974 p = get_node(small_node_size);
977 mark_ptr(p) = def_ref;
982 void append_penalty (void)
985 tail_append(new_penalty(cur_val));
990 /* only called from tex8.c */
992 void delete_last (void)
997 if ((mode == vmode) && (tail == head))
999 if ((cur_chr != glue_node) || (last_glue != empty_flag))
1002 help2("Sorry...I usually can't take things from the current page.",
1003 "Try `I\\vskip-\\lastskip' instead.");
1005 if (cur_chr == kern_node)
1006 help_line[0] = "Try `I\\kern-\\last_kern' instead.";
1007 else if (cur_chr != glue_node)
1008 help_line[0] = "Perhaps you can make the output routine do it.";
1014 if (!(tail >= hi_mem_min))
1015 if (type(tail) == cur_chr)
1023 if (!(q >= hi_mem_min))
1024 if (type(q) == disc_node)
1026 for (m = 1; m <= replace_count(q); m++)
1034 while (!(q == tail));
1036 flush_node_list(tail);
1041 /* only called from tex8.c */
1042 /* procedure unpackage; l.21256 */
1044 void unpackage (void)
1050 scan_eight_bit_int();
1055 if ((abs(mode) == mmode) || ((abs(mode) == vmode) && (type(p) != vlist_node)) ||
1056 ((abs(mode) == hmode) && (type(p) != hlist_node)))
1058 print_err("Incompatible list can't be unboxed");
1059 help3("Sorry, Pandora. (You sneaky devil.)",
1060 "I refuse to unbox an \\hbox in vertical mode or vice versa.",
1061 "And I can't open any boxes in math mode.");
1067 link(tail) = copy_node_list(list_ptr(p));
1070 link(tail) = list_ptr(p);
1072 free_node(p, box_node_size);
1075 while (link(tail) != 0)
1079 void append_italic_correction (void)
1082 internal_font_number f;
1086 if ((tail >= hi_mem_min))
1088 else if (type(tail) == ligature_node)
1093 tail_append(new_kern(font_info[italic_base[f] + (font_info[char_base[f] + mem[p].hh.b1].qqqq.b2) / 4].cint));
1094 subtype(tail) = explicit;
1098 void append_discretionary (void)
1102 tail_append(new_disc());
1106 c = hyphen_char[cur_font];
1109 pre_break(tail) = new_character(cur_font, c);
1114 save_stack[save_ptr - 1].cint = 0;
1115 new_save_level(disc_group);
1119 space_factor = 1000;
1122 /* only called form tex8.c */
1124 void build_discretionary (void)
1136 if (!(p >= hi_mem_min))
1137 if (mem[p].hh.b0 > 2)
1138 if (mem[p].hh.b0 != 11)
1139 if (mem[p].hh.b0 != 6)
1141 print_err("Improper discretionary list");
1142 help1("Discretionary lists must contain only boxes and kerns.");
1145 print_nl("The following discretionary sublist has been deleted:");
1147 end_diagnostic(true);
1158 p = mem[head].hh.v.RH;
1161 switch (save_stack[save_ptr - 1].cint)
1164 mem[tail + 1].hh.v.LH = p;
1167 mem[tail + 1].hh.v.RH = p;
1171 if ((n > 0) && (abs(mode)== 203))
1173 print_err("Illegal math ");
1174 print_esc("discretionary");
1175 help2("Sorry: The third part of a discretionary break must be",
1176 "empty, in math formulas. I had to delete your third part.");
1182 mem[tail].hh.v.RH = p;
1183 /* if n <= max_quarterword then replace_count(tail) <- n; p.1120 */
1184 /* if (n <= 255) */ /* 94/Apr/4 ? */
1185 if (n <= max_quarterword) /* 96/Oct/12 ??? */
1186 mem[tail].hh.b1 = n;
1189 print_err("Discretionary list is too long");
1190 help2("Wow---I never thought anybody would tweak me here.",
1191 "You can't seriously need such a huge discretionary list?");
1201 incr(save_stack[save_ptr - 1].cint);
1206 space_factor = 1000;
1208 /* called only from tex8.c */
1210 void make_accent (void)
1214 internal_font_number f;
1215 scaled a, h, x, w, delta;
1220 p = new_character(f, cur_val);
1225 s = slant(f) / ((double) 65536.0);
1226 a = char_width(f, char_info(f, character(p)));
1231 if ((cur_cmd == letter) || (cur_cmd == other_char) || (cur_cmd == char_given))
1232 q = new_character(f, cur_chr);
1233 else if (cur_cmd == char_num)
1236 q = new_character(f, cur_val);
1243 t = slant(f) / ((double) 65536.0);
1244 i = char_info(f, character(q));
1245 w = char_width(f, i);
1246 h = char_height(f, height_depth(i));
1251 shift_amount(p) = x - h;
1253 delta = round((w - a) / ((double) 2.0)+ h * t - x * s);
1254 r = new_kern(delta);
1255 subtype(r) = acc_kern;
1258 tail = new_kern(- (integer) a - delta);
1259 subtype(tail) = acc_kern;
1265 space_factor = 1000;
1269 void align_error (void)
1271 if (abs(align_state) > 2)
1273 print_err("Misplaced ");
1274 print_cmd_chr(cur_cmd, cur_chr);
1275 if (cur_tok == 1062)
1277 help6("I can't figure out why you would want to use a tab mark",
1278 "here. If you just want an ampersand, the remedy is",
1279 "simple: Just type `I\\&' now. But if some right brace",
1280 "up above has ended a previous alignment prematurely,",
1281 "you're probably due for more error messages, and you",
1282 "might try typing `S' now just to see what is salvageable.");
1286 help5("I can't figure out why you would want to use a tab mark",
1287 "or \\cr or \\span just now. If something like a right brace",
1288 "up above has ended a previous alignment prematurely,",
1289 "you're probably due for more error messages, and you",
1290 "might try typing `S' now just to see what is salvageable.");
1298 if (align_state < 0)
1300 print_err("Missing { inserted");
1302 cur_tok = 379; /* belowdisplayshortskip ? */
1306 print_err("Missing } inserted");
1310 help3("I've put in what seems to be necessary to fix",
1311 "the current column of the current alignment.",
1312 "Try to go on, since this might almost work.");
1317 void noalign_error (void)
1319 print_err("Misplaced ");
1320 print_esc("noalign");
1321 help2("I expect to see \\noalign only after the \\cr of",
1322 "an alignment. Proceed, and I'll ignore this case.");
1325 /* only called from tex8.c */
1327 void omit_error (void)
1329 print_err("Misplaced ");
1331 help2("I expect to see \\omit only after tab marks or the \\cr of",
1332 "an alignment. Proceed, and I'll ignore this case.");
1348 /* only called form tex8.c */
1350 void cs_error (void)
1352 print_err("Extra ");
1353 print_esc("endcsname");
1354 help1("I'm ignoring this, since I wasn't doing a \\csname.");
1358 void push_math_(group_code c)
1362 cur_list.aux_field.cint = 0;
1366 void init_math (void)
1373 internal_font_number f;
1380 if ((cur_cmd == 3) && (mode > 0))
1385 w = -1073741823L; /* - (2^30 - 1) */
1389 line_break(display_widow_penalty);
1390 v = mem[just_box + 4].cint + 2 * font_info[6 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint;
1391 w = -1073741823L; /* - (2^30 - 1) */
1392 p = mem[just_box + 5].hh.v.RH;
1396 if ((p >= hi_mem_min))
1399 d = font_info[width_base[f] + font_info[char_base[f] + mem[p].hh.b1].qqqq.b0].cint;
1402 switch (mem[p].hh.b0)
1408 d = mem[p + 1].cint;
1414 mem[lig_trick]= mem[p + 1];
1415 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
1422 d = mem[p + 1].cint;
1426 q = mem[p + 1].hh.v.LH;
1427 d = mem[q + 1].cint;
1428 if (mem[just_box + 5].hh.b0 == 1)
1430 if ((mem[just_box + 5].hh.b1 == mem[q].hh.b0) && (mem[q + 2].cint != 0))
1431 v = 1073741823L; /* - (2^30 - 1) */
1433 else if (mem[just_box + 5].hh.b0 == 2)
1435 if ((mem[just_box + 5].hh.b1 == mem[q].hh.b1) && (mem[q + 3].cint != 0))
1436 v = 1073741823L; /* - (2^30 - 1) */
1438 if (mem[p].hh.b1 >= 100)
1449 if (v < 1073741823L) /* - (2^30 - 1) */
1453 if (v < 1073741823L) /* - (2^30 - 1) */
1460 w = 1073741823L; /* - (2^30 - 1) */
1469 if (par_shape_ptr == 0)
1470 if ((hang_indent != 0) && (((hang_after >= 0) && (prev_graf + 2 > hang_after)) || (prev_graf + 1 < - (integer) hang_after)))
1472 l = hsize - abs(hang_indent);
1473 if (hang_indent > 0)
1485 n = mem[par_shape_ptr].hh.v.LH;
1486 if (prev_graf + 2 >= n)
1487 p = par_shape_ptr + 2 * n;
1489 p = par_shape_ptr + 2 *(prev_graf + 2);
1490 s = mem[p - 1].cint;
1495 eq_word_define((hash_size + 3207), -1);
1496 eq_word_define((hash_size + 3743), w);
1497 eq_word_define((hash_size + 3744), l);
1498 eq_word_define((hash_size + 3745), s);
1500 if (every_display != 0)/* everydisplay */
1501 begin_token_list(every_display, 9);
1513 eq_word_define((hash_size + 3207), -1);
1514 if (every_math != 0)/* everymath */
1515 begin_token_list(every_math, 8);
1520 void start_eq_no (void)
1522 save_stack[save_ptr + 0].cint = cur_chr;
1525 push_math(math_shift_group);
1526 eq_word_define(int_base + cur_fam_code, -1);
1528 if (every_math != 0)
1529 begin_token_list(every_math, every_math_text);
1533 void scan_math_(halfword p)
1542 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
1551 c = math_code(cur_chr);
1556 cur_cs = cur_chr + active_base;
1557 cur_cmd = eq_type(cur_cs);
1558 cur_chr = equiv(cur_cs);
1570 cur_cmd = char_given;
1576 scan_fifteen_bit_int();
1585 scan_twenty_seven_bit_int();
1593 save_stack[save_ptr + 0].cint = p;
1595 push_math(math_group);
1600 math_type(p) = math_char;
1601 character(p) = c % 256;
1603 if ((c >= var_code) && ((cur_fam >= 0) && (cur_fam < 16)))
1606 fam(p) = (c / 256) % 16;
1609 void set_math_char_(integer c)
1615 cur_cs = cur_chr + active_base;
1616 cur_cmd = eq_type(cur_cs);
1617 cur_chr = equiv(cur_cs);
1624 math_type(nucleus(p)) = math_char;
1625 character(nucleus(p)) = c % 256;
1626 fam(nucleus(p)) = (c / 256) % 16;
1630 if (((cur_fam >= 0) && (cur_fam < 16)))
1631 fam(nucleus(p)) = cur_fam;
1636 type(p) = ord_noad + (c / 4096);
1643 void math_limit_switch (void)
1646 if (mem[tail].hh.b0 == op_noad)
1648 subtype(tail) = cur_chr;
1652 print_err("Limit controls must follow a math operator");
1653 help1("I'm ignoring this misplaced \\limits or \\nolimits command.");
1657 void scan_delimiter_(halfword p, bool r)
1661 scan_twenty_seven_bit_int();
1669 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
1675 cur_val = del_code(cur_chr);
1678 scan_twenty_seven_bit_int();
1688 print_err("Missing delimiter (. inserted)");
1689 help6("I was expecting to see something like `(' or `\\{' or",
1690 "`\\}' here. If you typed, e.g., `{' instead of `\\{', you",
1691 "should probably delete the `{' by typing `1' now, so that",
1692 "braces don't get unbalanced. Otherwise just proceed.",
1693 "Acceptable delimiters are characters whose \\delcode is",
1694 "nonnegative, or you can use `\\delimiter <delimiter code>'.");
1699 small_fam(p) = (cur_val / 1048576L) % 16;
1700 small_char(p) = (cur_val / 4096) % 256;
1701 large_fam(p) = (cur_val / 256) % 16;
1702 large_char(p) = cur_val % 256;
1705 void math_radical (void)
1707 tail_append(get_node(radical_noad_size));
1708 type(tail) = radical_noad;
1709 subtype(tail) = normal;
1710 mem[nucleus(tail)].hh = empty_field;
1711 mem[subscr(tail)].hh = empty_field;
1712 mem[supscr(tail)].hh = empty_field;
1713 scan_delimiter(left_delimiter(tail), true);
1714 scan_math(nucleus(tail));
1719 if (cur_cmd == accent)
1721 print_err("Please use ");
1722 print_esc("mathaccent");
1723 print_string(" for accents in math mode");
1724 help2("I'm changing \\accent to \\mathaccent here; wish me luck.",
1725 "(Accents are not the same in formulas as they are in text.)");
1729 tail_append(get_node(5));
1730 type(tail) = accent_noad;
1731 subtype(tail) = normal;
1732 mem[nucleus(tail)].hh = empty_field;
1733 mem[subscr(tail)].hh = empty_field;
1734 mem[supscr(tail)].hh = empty_field;
1735 math_type(accent_chr(tail)) = math_char;
1736 scan_fifteen_bit_int();
1737 character(accent_chr(tail)) = cur_val % 256;
1739 if ((cur_val >= var_code) && ((cur_fam >= 0) && (cur_fam < 16)))
1740 fam(accent_chr(tail)) = cur_fam;
1742 fam(accent_chr(tail)) = (cur_val / 256) % 16;
1744 scan_math(nucleus(tail));
1747 void append_choices (void)
1749 tail_append(new_choice());
1751 save_stack[save_ptr - 1].cint = 0;
1752 push_math(math_choice_group);
1756 halfword fin_mlist_(halfword p)
1758 register halfword Result;
1761 if (incompleat_noad != 0)
1763 math_type(denominator(incompleat_noad)) = sub_mlist;
1764 info(denominator(incompleat_noad)) = link(head);
1767 q = incompleat_noad;
1770 q = info(numerator(incompleat_noad));
1772 if (type(q) != left_noad)
1775 return 0; // abort_flag set
1778 info(numerator(incompleat_noad)) = link(q);
1779 link(q) = incompleat_noad;
1780 link(incompleat_noad) = p;
1793 void build_choices (void)
1800 switch (save_stack[save_ptr - 1].cint)
1803 display_mlist(tail) = p;
1806 text_mlist(tail) = p;
1809 script_mlist(tail) = p;
1813 script_script_mlist(tail) = p;
1819 incr(save_stack[save_ptr - 1].cint);
1820 push_math(math_choice_group);
1826 /* small_number t; */
1827 int t; /* 95/Jan/7 */
1834 if ((mem[tail].hh.b0 >= 16) && (mem[tail].hh.b0 < 30))
1836 p = supscr(tail) + cur_cmd - sup_mark;
1840 if ((p == 0) || (t != 0))
1842 tail_append(new_noad());
1843 p = supscr(tail) + cur_cmd - sup_mark;
1847 if (cur_cmd == sup_mark)
1849 print_err("Double superscript");
1850 help1("I treat `x^1^2' essentially like `x^1{}^2'.");
1854 print_err("Double subscript");
1855 help1("I treat `x_1_2' essentially like `x_1{}_2'.");
1862 /* used to continue here with math_fraction etc in tex7.c */
1863 /*****************************************************************************/
1864 /* moved down here to avoid pragma optimize questions 96/Sep/12 */
1866 void package_(small_number c)
1874 save_ptr = save_ptr - 3;
1877 cur_box = hpack(link(head), save_stack[save_ptr + 2].cint, save_stack[save_ptr + 1].cint);
1880 cur_box = vpackage(link(head), save_stack[save_ptr + 2].cint, save_stack[save_ptr + 1].cint, d);
1885 p = list_ptr(cur_box);
1888 if (type(p) <= rule_node)
1891 depth(cur_box) = depth(cur_box) - h + height(cur_box);
1892 height(cur_box) = h;
1896 box_end(save_stack[save_ptr + 0].cint);
1898 #pragma optimize ("", on) /* 96/Sep/12 */