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)
41 lab22: p = mem[contrib_head].hh.v.RH;
42 /* if (last_glue != 262143L) */
43 if (last_glue != empty_flag)
44 delete_glue_ref(last_glue);
47 if (mem[p].hh.b0 == 10)
49 last_glue = mem[p + 1].hh.v.LH;
50 incr(mem[last_glue].hh.v.RH);
54 /* last_glue = 262143L; */
55 last_glue = empty_flag;
56 if (mem[p].hh.b0 == 12)
57 last_penalty = mem[p + 1].cint;
58 else if (mem[p].hh.b0 == 11)
59 last_kern = mem[p + 1].cint;
66 if (page_contents < 2)
68 if (page_contents == 0)
72 q = new_skip_param(9);
73 if (mem[temp_ptr + 1].cint > mem[p + 3].cint)
74 mem[temp_ptr + 1].cint = mem[temp_ptr + 1].cint - mem[p + 3].cint;
76 mem[temp_ptr + 1].cint = 0;
78 mem[contrib_head].hh.v.RH = q;
82 page_so_far[1]= page_so_far[1]+ page_so_far[7]+ mem[p + 3].cint;
83 page_so_far[7]= mem[p + 2].cint;
91 if (page_contents < 2)
93 else if ((mem[page_tail].hh.b0 < 9))
99 if (page_contents < 2)
101 else if (mem[p].hh.v.RH == 0)
103 else if (mem[mem[p].hh.v.RH].hh.b0 == 10)
109 if (page_contents < 2)
112 pi = mem[p + 1].cint;
119 if (page_contents == 0)
120 freeze_page_specs(1);
123 while(n >= mem[mem[r].hh.v.RH].hh.b1)
126 if (mem[r].hh.b1 != n)
129 mem[q].hh.v.RH = mem[r].hh.v.RH;
135 if (eqtb[(hash_size + 1578) + n].hh.v.RH == 0)
138 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;
139 mem[r + 2].hh.v.LH = 0;
140 q = eqtb[(hash_size + 800) + n].hh.v.RH;
141 if (eqtb[(hash_size + 3218) + n].cint == 1000)
144 h = x_over_n(mem[r + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint;
145 page_so_far[0]= page_so_far[0]- h - mem[q + 1].cint;
146 page_so_far[2 + mem[q].hh.b0]= page_so_far[2 + mem[q].hh.b0]+ mem[q + 2].cint;
147 page_so_far[6]= page_so_far[6]+ mem[q + 3].cint;
148 if ((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0))
150 print_err("Infinite glue shrinkage inserted from");
153 help3("The correction glue for page breaking with insertions",
154 "must have finite shrinkability. But you may proceed,",
155 "since the offensive shrinkability has been made finite.");
159 if (mem[r].hh.b0 == 1)
160 insert_penalties = insert_penalties + mem[p + 1].cint;
162 mem[r + 2].hh.v.RH = p;
163 delta = page_so_far[0]- page_so_far[1]- page_so_far[7] + page_so_far[6];
164 if (eqtb[(hash_size + 3218) + n].cint == 1000)
167 h = x_over_n(mem[p + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint;
168 if (((h <= 0)||(h <= delta)) &&(mem[p + 3].cint + mem[r + 3].cint <= eqtb[(hash_size + 3751) + n].cint))
170 page_so_far[0]= page_so_far[0]- h;
171 mem[r + 3].cint = mem[r + 3].cint + mem[p + 3].cint;
174 if (eqtb[(hash_size + 3218) + n].cint <= 0)
175 w = 1073741823L; /* 2^30 - 1 */
177 w = page_so_far[0]- page_so_far[1]- page_so_far[7];
178 if (eqtb[(hash_size + 3218) + n].cint != 1000)
179 w = x_over_n(w, eqtb[(hash_size + 3218) + n].cint)* 1000;
181 if (w > eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint)
182 w = eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint;
183 q = vert_break(mem[p + 4].hh.v.LH, w, mem[p + 2].cint);
184 mem[r + 3].cint = mem[r + 3].cint + best_height_plus_depth;
187 if (eqtb[(hash_size + 3196)].cint > 0)
195 print_scaled(best_height_plus_depth);
197 if (q == 0) /* if q=null l.19614 */
199 else if (mem[q].hh.b0 == 12)
200 print_int(mem[q + 1].cint);
201 else print_char('0');
202 end_diagnostic(false);
205 if (eqtb[(hash_size + 3218) + n].cint != 1000)
206 best_height_plus_depth = x_over_n(best_height_plus_depth, 1000) * eqtb[(hash_size + 3218) + n].cint;
207 page_so_far[0]= page_so_far[0]- best_height_plus_depth;
209 mem[r + 1].hh.v.RH = q;
210 mem[r + 1].hh.v.LH = p;
212 insert_penalties = insert_penalties - 10000;
213 else if (mem[q].hh.b0 == 12)
214 insert_penalties = insert_penalties + mem[q + 1].cint;
223 return; // abort_flag set
227 if (pi < 10000)/* pi may be used ... */
229 if (page_so_far[1]< page_so_far[0])
230 if ((page_so_far[3]!= 0)||(page_so_far[4]!= 0)||(page_so_far[5]!= 0))
233 b = badness(page_so_far[0]- page_so_far[1], page_so_far[2]);
234 else if (page_so_far[1]- page_so_far[0]> page_so_far[6])
235 b = 1073741823L; /* 2^30 - 1 */
237 b = badness(page_so_far[1]- page_so_far[0], page_so_far[6]);
238 if (b < 1073741823L) /* 2^30 - 1 */
242 c = b + pi + insert_penalties;
247 if (insert_penalties >= 10000)
248 c = 1073741823L; /* 2^30 - 1 */
251 if (eqtb[(hash_size + 3196)].cint > 0)
258 print_scaled(page_so_far[0]);
260 if (b == 1073741823L) /* 2^30 - 1 */
267 if (c == 1073741823L) /* 2^30 - 1 */
270 if (c <= least_page_cost)
272 end_diagnostic(false);
275 if (c <= least_page_cost)
278 best_size = page_so_far[0];
280 r = mem[mem_top].hh.v.RH;
281 while (r != mem_top) {
282 mem[r + 2].hh.v.LH = mem[r + 2].hh.v.RH;
286 if ((c == 1073741823L)||(pi <= -10000)) /* 2^30 - 1 */
289 if (output_active)return;
293 if ((mem[p].hh.b0 < 10)||(mem[p].hh.b0 > 11))
295 lab90: if (mem[p].hh.b0 == 11)
298 q = mem[p + 1].hh.v.LH;
299 page_so_far[2 + mem[q].hh.b0]= page_so_far[2 + mem[q].hh.b0]
301 page_so_far[6]= page_so_far[6]+ mem[q + 3].cint;
302 if ((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0))
304 print_err("Infinite glue shrinkage found on current page");
305 help4("The page about to be output contains some infinitely",
306 "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
307 "Such glue doesn't belong there; but you can safely proceed,",
308 "since the offensive shrinkability has been made finite.");
313 mem[p + 1].hh.v.LH = r;
317 page_so_far[1]= page_so_far[1]+ page_so_far[7]+ mem[q + 1].cint
320 lab80: if (page_so_far[7]> page_max_depth)
322 page_so_far[1]= page_so_far[1]+ page_so_far[7]- page_max_depth;
323 page_so_far[7]= page_max_depth;
325 mem[page_tail].hh.v.RH = p;
327 mem[contrib_head].hh.v.RH = mem[p].hh.v.RH;
330 lab31: mem[contrib_head].hh.v.RH = mem[p].hh.v.RH;
334 } while(!(mem[contrib_head].hh.v.RH == 0));
337 else nest[0].tail_field = contrib_head;
340 void app_space (void)
343 if ((space_factor >= 2000) && (eqtb[(hash_size + 795)].hh.v.RH != 0))
344 q = new_param_glue(13);
346 if (eqtb[(hash_size + 794)].hh.v.RH != 0)
347 main_p = eqtb[(hash_size + 794)].hh.v.RH;
349 main_p = font_glue[eqtb[(hash_size + 1834)].hh.v.RH];
352 main_p = new_spec(0);
353 main_k = param_base[eqtb[(hash_size + 1834)].hh.v.RH]+ 2;
354 mem[main_p + 1].cint = font_info[main_k].cint;
355 mem[main_p + 2].cint = font_info[main_k + 1].cint;
356 mem[main_p + 3].cint = font_info[main_k + 2].cint;
357 font_glue[eqtb[(hash_size + 1834)].hh.v.RH]= main_p;
360 main_p = new_spec(main_p);
361 if (space_factor >= 2000)
362 mem[main_p + 1].cint = mem[main_p + 1].cint + font_info[7 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint;
363 mem[main_p + 2].cint = xn_over_d(mem[main_p + 2].cint, cur_list.aux_field.hh.v.LH, 1000);
364 mem[main_p + 3].cint = xn_over_d(mem[main_p + 3].cint, 1000, space_factor);
365 q = new_glue(main_p);
366 mem[main_p].hh.v.RH = 0;
368 mem[tail].hh.v.RH = q;
371 /* called from tex8.c only */
373 void insert_dollar_sign (void)
377 print_err("Proceed; I'll discard its present contents.");
378 help2("I've inserted a begin-math/end-math symbol since I think",
379 "you left one out. Proceed, with fingers crossed.");
385 print_err("You can't use `");
386 print_cmd_chr(cur_cmd, cur_chr);
387 print_string("' in ");
391 void report_illegal_case (void)
394 help4("Sorry, but I'm not programmed to handle this case;",
395 "I'll just pretend that you didn't ask for it.",
396 "If you're in the wrong mode, you might be able to",
397 "return to the right one by typing `I}' or `I$' or `I\\par'.");
401 bool privileged (void)
403 register bool Result;
404 if (mode > 0)Result = true;
406 report_illegal_case ();
412 bool its_all_over (void)
414 register bool Result;
417 if ((page_head == page_tail) && (head == cur_list.tail_field) && (dead_cycles == 0))
424 mem[tail].hh.v.RH = new_null_box ();
425 tail = mem[tail].hh.v.RH;
427 mem[tail + 1].cint = eqtb[(hash_size + 3733)].cint;
429 mem[tail].hh.v.RH = new_glue(8);
430 tail = mem[tail].hh.v.RH;
433 mem[tail].hh.v.RH = new_penalty(-1073741824L);
435 tail = mem[tail].hh.v.RH;
443 void append_glue (void)
468 mem[tail].hh.v.RH = new_glue(cur_val);
469 tail = mem[tail].hh.v.RH;
473 decr(mem[cur_val].hh.v.RH);
475 mem[tail].hh.b1 = 99;
479 void append_kern (void)
483 scan_dimen(s == 99, false, false);
485 mem[tail].hh.v.RH = new_kern(cur_val);
486 tail = mem[tail].hh.v.RH;
497 print_cmd_chr(cur_cmd, cur_chr);
498 help1("Things are pretty mixed up, but I think the worst is over.");
503 mem[temp_head].hh.v.RH = p;
504 print_err("Missing ");
508 /* mem[p].hh.v.LH = (hash_size + 4611); */
509 /* mem[p].hh.v.LH = (hash_size + 4095 + 516); */
510 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 516); /* 96/Jan/10 */
511 print_esc("endgroup");
516 mem[p].hh.v.LH = 804;
522 /* mem[p].hh.v.LH = (hash_size + 4612); */
523 /* mem[p].hh.v.LH = (hash_size + 4095 + 517); */
524 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 517); /* 96/Jan/10 */
525 mem[p].hh.v.RH = get_avail ();
527 mem[p].hh.v.LH = 3118;
533 mem[p].hh.v.LH = 637;
538 print_string(" inserted");
539 begin_token_list(mem[temp_head].hh.v.RH, 4);
540 help5("I've inserted something that you may have forgotten.",
541 "(See the <inserted text> above.)",
542 "With luck, this will get me unwedged. But if you",
543 "really didn't forget anything, try typing `2' now; then",
544 "my insertion and my current dilemma will both disappear.");
548 /* only called from tex8.c */
550 void extra_right_brace (void)
552 print_err("Extra }, or forgotten");
555 print_esc("endgroup");
564 help5("I've deleted a group-closing symbol because it seems to be",
565 "spurious, as in `$x}$'. But perhaps the } is legitimate and",
566 "you forgot something else, as in `\\hbox{$x}'. In such cases",
567 "the way to recover is to insert both the forgotten and the",
568 "deleted material, e.g., by typing `I$}'.");
573 void normal_paragraph (void)
575 /* if looseness<>0 then eq_word_define(int_base+looseness_code,0); */
576 if (eqtb[(hash_size + 3182)].cint != 0)
577 eq_word_define((hash_size + 3182), 0);
578 if (eqtb[(hash_size + 3747)].cint != 0)
579 eq_word_define((hash_size + 3747), 0);
580 if (eqtb[(hash_size + 3204)].cint != 1)
581 eq_word_define((hash_size + 3204), 1);
582 if (eqtb[(hash_size + 1312)].hh.v.RH != 0)
583 eq_define((hash_size + 1312), 118, 0);
586 void box_end_(integer boxcontext)
589 /* if box_context<box_flag then ... 1073741824 2^30 */
590 if (boxcontext < 1073741824L)
594 mem[cur_box + 4].cint = boxcontext;
597 append_to_vlist(cur_box);
598 if (adjust_tail != 0)
600 if (adjust_head != adjust_tail)
602 mem[tail].hh.v.RH = mem[adjust_head].hh
618 mem[p + 1].hh.v.RH = 2;
619 mem[p + 1].hh.v.LH = cur_box;
622 mem[tail].hh.v.RH = cur_box;
628 /* following fixed 1994/Apr/5 1 day anno Yang --- moby sigh ... */
630 /* else if box_context<box_flag+512 then ... */
631 /* else if (boxcontext < 1073742336L)*/ /* 2^30 + 512 */
632 else if (boxcontext < (1073741824L + 512)) /* 2^30 + 512 */
633 /* else if box_context<box_flag+256 then ... */
634 /* if (boxcontext < 1073742080L)*/ /* 2^30 + 256 */
635 if (boxcontext < (1073741824L + 256))/* 2^30 + 256 */
636 /* eq_define(box_base-box_flag+box_context,box_ref,cur_box) */
637 /* eq_define((hash_size - 1073740246L) + boxcontext, 119, cur_box); */
638 eq_define((hash_size + 1578 - 1073741824L) + boxcontext, 119, cur_box);
639 /* else geq_define(box_base-box_flag-256+box_context,box_ref,cur_box) */
640 /* else geq_define((hash_size - 1073740502L) + boxcontext, 119, cur_box); */
641 else geq_define((hash_size + 1322 - 1073741824L) + boxcontext, 119, cur_box);
642 else if (cur_box != 0)
643 /* if (boxcontext > 1073742336L)*/ /* 2^30 + 512 */
644 if (boxcontext > (1073741824L + 512)) /* 2^30 + 512 */
648 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
649 /* 424 in tex82.bug */
650 if (((cur_cmd == 26) && (abs(mode)!= 1)) ||
651 ((cur_cmd == 27) && (abs(mode)== 1)))
653 /* begin append_glue; subtype(tail):=box_context-(leader_flag-a_leaders); */
655 /* -(2^30 + 513 - 100) */
656 mem[tail].hh.b1 = boxcontext -(1073742237L);
657 mem[tail + 1].hh.v.RH = cur_box;
660 print_err("Leaders not followed by proper glue");
661 help3("You should say `\\leaders <box or rule><hskip or vskip>'.",
662 "I found the <box or rule>, but there's no suitable",
663 "<hskip or vskip>, so I'm ignoring these leaders.");
665 flush_node_list(cur_box);
668 else ship_out(cur_box);
670 /* called only from tex8.c */
672 void begin_box_(integer boxcontext)
681 scan_eight_bit_int ();
682 cur_box = eqtb[(hash_size + 1578) + cur_val].hh.v.RH;
683 eqtb[(hash_size + 1578) + cur_val].hh.v.RH = 0;
688 scan_eight_bit_int ();
689 cur_box = copy_node_list(eqtb[(hash_size + 1578) + cur_val].hh.v.RH);
698 help1("Sorry; this \\lastbox will be void.");
701 else if ((mode == 1)&&(head == cur_list
705 help2("Sorry...I usually can't take things from the current page.",
706 "This \\lastbox will therefore be void.");
710 if (!(tail >= hi_mem_min))
711 if ((mem[tail].hh.b0 == 0)||(mem[cur_list
712 .tail_field].hh.b0 == 1))
717 if (!(q >= hi_mem_min))
718 if (mem[q].hh.b0 == 7)
721 register integer for_end;
723 for_end = mem[q].hh.b1;
726 while(m++ < for_end);
732 } while(!(q == tail));
734 mem[cur_box + 4].cint = 0;
744 scan_eight_bit_int ();
746 if (! scan_keyword("to")) /* to */
748 print_err("Missing `to' inserted");
749 help2("I'm working on `\\vsplit<box number> to <dimen>';",
750 "will look for the <dimen> next.");
753 scan_dimen(false, false, false);
754 cur_box = vsplit(n, cur_val);
760 save_stack[save_ptr + 0].cint = boxcontext;
762 if ((boxcontext < 1073741824L)&& /* 2^30 */
766 else scan_spec(2, true);
779 mode = - (integer) k;
782 cur_list.aux_field.cint = ignore_depth;
783 if (eqtb[(hash_size + 1318)].hh.v.RH != 0)/* everyhbox */
784 begin_token_list(eqtb[(hash_size + 1318)].hh.v.RH, 11);
789 if (eqtb[(hash_size + 1317)].hh.v.RH != 0)/* everyhbox */
790 begin_token_list(eqtb[(hash_size + 1317)].hh.v.RH, 10);
799 void scan_box_(integer boxcontext)
803 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
805 begin_box(boxcontext);
807 else if ((boxcontext >= 1073742337L)&& /* (2^30 + 512 + 1) */
808 ((cur_cmd == 36)||(cur_cmd == 35)))
810 cur_box = scan_rule_spec ();
814 print_err("A <box> was supposed to be here");
815 help3("I was expecting to see \\hbox or \\vbox or \\copy or \\box or",
816 "something like that. So you might find something missing in",
817 "your output. But keep trying; you can fix this later.");
821 /****************************************************************************/
822 void package_ (small_number);
823 /****************************************************************************/
825 small_number norm_min_ (integer h)
827 /* small_number Result; */
828 int Result; /* 95/Jan/7 */
837 void new_graf_(bool indented)
840 if ((mode == 1)||(head != cur_list
843 mem[tail].hh.v.RH = new_param_glue(2);
844 tail = mem[tail].hh.v.RH;
846 /* used to be followingin 3.141 */
847 /* cur_list .lhmfield = norm_min(eqtb[(hash_size + 3214)].cint); */
848 /* cur_list .rhmfield = norm_min(eqtb[(hash_size + 3215)].cint); */
852 /* changes here since 3.141 */
853 if (eqtb[(hash_size + 3213)].cint <= 0)
855 else if (eqtb[(hash_size + 3213)].cint > 255)
857 else cur_lang = eqtb[(hash_size + 3213)].cint;
859 prev_graf =(norm_min(eqtb[(hash_size + 3214)].cint)* 64 +
860 norm_min(eqtb[(hash_size + 3215)].cint)) * 65536L + cur_lang;
861 /* eqtb ??? hash_size ? hash_size + hash_extra ? norm_min etc */
862 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
865 tail = new_null_box ();
866 mem[head].hh.v.RH = tail;
867 mem[tail + 1].cint = eqtb[(hash_size + 3730)].cint;
869 if (eqtb[(hash_size + 1314)].hh.v.RH != 0) /* everypar */
870 begin_token_list(eqtb[(hash_size + 1314)].hh.v.RH, 7);
875 /* procedure indent_in_hmode; l.21058 */
877 void indent_in_hmode (void)
883 mem[p + 1].cint = eqtb[(hash_size + 3730)].cint;
889 mem[q + 1].hh.v.RH = 2;
890 mem[q + 1].hh.v.LH = p;
894 mem[tail].hh.v.RH = p;
895 tail = mem[tail].hh.v.RH;
899 /* only called from tex8.c */
901 void head_for_vmode (void)
908 print_err("You can't use `");
910 print_string("' here except with leaders");
911 help2("To put a horizontal rule in an hbox or an alignment,",
912 "you should use \\leaders or \\hrulefill (see The TeXbook).");
920 cur_input.index_field = 4;
930 else line_break(eqtb[(hash_size + 3169)].cint);
935 /* only called form tex8.c */
937 void begin_insert_or_adjust (void)
943 scan_eight_bit_int ();
946 print_err("You can't ");
949 help1("I'm changing to \\insert0; box 255 is special.");
954 save_stack[save_ptr + 0].cint = cur_val;
961 cur_list.aux_field.cint = ignore_depth;
964 void make_mark (void)
967 p = scan_toks(false, true);
971 mem[p + 1].cint = def_ref;
972 mem[tail].hh.v.RH = p;
976 void append_penalty (void)
980 mem[tail].hh.v.RH = new_penalty(cur_val);
981 tail = mem[tail].hh.v.RH;
987 /* only called from tex8.c */
989 void delete_last (void)
993 if ((mode == 1) && (tail == cur_list.head_field))
995 /* if ((cur_chr != 10)||(last_glue != 262143L)) */
996 if ((cur_chr != 10)||(last_glue != empty_flag))
999 help2("Sorry...I usually can't take things from the current page.",
1000 "Try `I\\vskip-\\lastskip' instead.");
1002 help_line[0] = "Try `I\\kern-\\last_kern' instead.";
1003 else if (cur_chr != 10)
1004 help_line[0] = "Perhaps you can make the output routine do it.";
1010 if (!(tail >= hi_mem_min))
1011 if (mem[tail].hh.b0 == cur_chr)
1016 if (!(q >= hi_mem_min))
1017 if (mem[q].hh.b0 == 7)
1020 register integer for_end;
1022 for_end = mem[q].hh.b1;
1023 if (m <= for_end) do
1025 while(m++ < for_end);
1031 } while(!(q == tail));
1033 flush_node_list(tail);
1038 /* only called from tex8.c */
1039 /* procedure unpackage; l.21256 */
1041 void unpackage (void)
1046 scan_eight_bit_int ();
1047 p = eqtb[(hash_size + 1578) + cur_val].hh.v.RH;
1048 if (p == 0)/* if p=null then return; l.21261 */
1050 if ((abs(mode)== 203)||((abs(mode)
1051 == 1)&&(mem[p].hh.b0 != 1)) ||((abs(mode)==
1052 102)&&(mem[p].hh.b0 != 0)))
1054 print_err("Incompatible list can't be unboxed");
1055 help3("Sorry, Pandora. (You sneaky devil.)",
1056 "I refuse to unbox an \\hbox in vertical mode or vice versa.",
1057 "And I can't open any boxes in math mode.");
1062 mem[tail].hh.v.RH = copy_node_list(mem[p + 5].hh
1066 mem[tail].hh.v.RH = mem[p + 5].hh.v.RH;
1067 eqtb[(hash_size + 1578) + cur_val].hh.v.RH = 0;
1070 while(mem[tail].hh.v.RH != 0)tail = mem
1074 void append_italic_correction (void)
1077 internal_font_number f;
1080 if ((tail >= hi_mem_min))
1082 else if (mem[tail].hh.b0 == 6)
1087 mem[tail].hh.v.RH = new_kern(font_info[italic_base[
1088 f]+(font_info[char_base[f]+ mem[p].hh.b1].qqqq.b2)/ 4]
1090 tail = mem[tail].hh.v.RH;
1092 mem[tail].hh.b1 = 1;
1096 void append_discretionary (void)
1100 mem[tail].hh.v.RH = new_disc ();
1101 tail = mem[tail].hh.v.RH;
1105 c = hyphen_char[eqtb[(hash_size + 1834)].hh.v.RH];
1108 mem[tail + 1].hh.v.LH = new_character(eqtb[(hash_size + 1834)]
1114 save_stack[save_ptr - 1].cint = 0;
1119 space_factor = 1000;
1122 /* only called form tex8.c */
1124 void build_discretionary (void)
1134 if (!(p >= hi_mem_min))
1135 if (mem[p].hh.b0 > 2)
1136 if (mem[p].hh.b0 != 11)
1137 if (mem[p].hh.b0 != 6)
1139 print_err("Improper discretionary list");
1140 help1("Discretionary lists must contain only boxes and kerns.");
1142 begin_diagnostic ();
1143 print_nl("The following discretionary sublist has been deleted:"); /* */
1145 end_diagnostic(true);
1155 p = mem[head].hh.v.RH;
1157 switch(save_stack[save_ptr - 1].cint)
1159 mem[tail + 1].hh.v.LH = p;
1162 mem[tail + 1].hh.v.RH = p;
1166 if ((n > 0)&&(abs(mode)== 203))
1168 print_err("Illegal math ");
1169 print_esc("discretionary");
1170 help2("Sorry: The third part of a discretionary break must be",
1171 "empty, in math formulas. I had to delete your third part.");
1176 else mem[tail].hh.v.RH = p;
1177 /* if n <= max_quarterword then replace_count(tail) <- n; p.1120 */
1178 /* if (n <= 255) */ /* 94/Apr/4 ? */
1179 if (n <= max_quarterword) /* 96/Oct/12 ??? */
1180 mem[tail].hh.b1 = n;
1182 print_err("Discretionary list is too long");
1183 help2("Wow---I never thought anybody would tweak me here.",
1184 "You can't seriously need such a huge discretionary list?");
1194 incr(save_stack[save_ptr - 1].cint);
1199 space_factor = 1000;
1201 /* called only from tex8.c */
1203 void make_accent (void)
1207 internal_font_number f;
1208 scaled a, h, x, w, delta;
1211 f = eqtb[(hash_size + 1834)].hh.v.RH;
1212 p = new_character(f, cur_val);
1215 x = font_info[5 + param_base[f]].cint;
1216 s = font_info[1 + param_base[f]].cint / ((double) 65536.0);
1217 a = font_info[width_base[f]+ font_info[char_base[f]+ mem[p]
1218 .hh.b1].qqqq.b0].cint;
1221 f = eqtb[(hash_size + 1834)].hh.v.RH;
1222 if ((cur_cmd == 11)||(cur_cmd == 12)||(cur_cmd == 68))
1223 q = new_character(f, cur_chr);
1224 else if (cur_cmd == 16)
1227 q = new_character(f, cur_val);
1232 t = font_info[1 + param_base[f]].cint / ((double) 65536.0);
1233 i = font_info[char_base[f]+ mem[q].hh.b1].qqqq;
1234 w = font_info[width_base[f]+ i.b0].cint;
1235 h = font_info[height_base[f]+(i.b1)/ 16].cint;
1239 mem[p + 4].cint = x - h;
1241 delta = round((w - a)/ ((double) 2.0)+ h * t - x * s);
1242 r = new_kern(delta);
1244 mem[tail].hh.v.RH = r;
1246 tail = new_kern(- (integer) a - delta);
1247 mem[tail].hh.b1 = 2;
1248 mem[p].hh.v.RH = tail;
1251 mem[tail].hh.v.RH = p;
1253 space_factor = 1000;
1257 void align_error (void)
1259 if (abs(align_state)> 2){
1260 print_err("Misplaced ");
1261 print_cmd_chr(cur_cmd, cur_chr);
1262 if (cur_tok == 1062) {
1263 help6("I can't figure out why you would want to use a tab mark",
1264 "here. If you just want an ampersand, the remedy is",
1265 "simple: Just type `I\\&' now. But if some right brace",
1266 "up above has ended a previous alignment prematurely,",
1267 "you're probably due for more error messages, and you",
1268 "might try typing `S' now just to see what is salvageable.");
1271 help5("I can't figure out why you would want to use a tab mark",
1272 "or \\cr or \\span just now. If something like a right brace",
1273 "up above has ended a previous alignment prematurely,",
1274 "you're probably due for more error messages, and you",
1275 "might try typing `S' now just to see what is salvageable.");
1281 if (align_state < 0) {
1282 print_err("Missing { inserted");
1284 cur_tok = 379; /* belowdisplayshortskip ? */
1287 print_err("Missing } inserted");
1291 help3("I've put in what seems to be necessary to fix",
1292 "the current column of the current alignment.",
1293 "Try to go on, since this might almost work.");
1298 void noalign_error (void)
1300 print_err("Misplaced ");
1301 print_esc("noalign");
1302 help2("I expect to see \\noalign only after the \\cr of",
1303 "an alignment. Proceed, and I'll ignore this case.");
1306 /* only called from tex8.c */
1308 void omit_error (void)
1310 print_err("Misplaced ");
1312 help2("I expect to see \\omit only after tab marks or the \\cr of",
1313 "an alignment. Proceed, and I'll ignore this case.");
1319 if (cur_group == 6) {
1321 if (fin_col ())fin_row ();
1325 /* only called form tex8.c */
1327 void cs_error (void)
1329 print_err("Extra ");
1330 print_esc("endcsname");
1331 help1("I'm ignoring this, since I wasn't doing a \\csname.");
1335 void push_math_(group_code c)
1339 cur_list.aux_field.cint = 0;
1343 void init_math (void)
1350 internal_font_number f;
1355 if ((cur_cmd == 3)&&(mode > 0))
1360 w = -1073741823L; /* - (2^30 - 1) */
1364 line_break(eqtb[(hash_size + 3170)].cint);
1365 v = mem[just_box + 4].cint + 2 * font_info[6 +
1366 param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint;
1367 w = -1073741823L; /* - (2^30 - 1) */
1368 p = mem[just_box + 5].hh.v.RH;
1371 lab21: if ((p >= hi_mem_min))
1374 d = font_info[width_base[f]+ font_info[char_base[f]+ mem[p
1375 ].hh.b1].qqqq.b0].cint;
1378 switch(mem[p].hh.b0)
1383 d = mem[p + 1].cint;
1389 mem[lig_trick]= mem[p + 1];
1390 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
1397 d = mem[p + 1].cint;
1401 q = mem[p + 1].hh.v.LH;
1402 d = mem[q + 1].cint;
1403 if (mem[just_box + 5].hh.b0 == 1)
1405 if ((mem[just_box + 5].hh.b1 == mem[q].hh.b0)&&(mem
1407 v = 1073741823L; /* - (2^30 - 1) */
1409 else if (mem[just_box + 5].hh.b0 == 2)
1411 if ((mem[just_box + 5].hh.b1 == mem[q].hh.b1)&&(mem
1413 v = 1073741823L; /* - (2^30 - 1) */
1415 if (mem[p].hh.b1 >= 100)
1426 if (v < 1073741823L) /* - (2^30 - 1) */
1429 lab40: if (v < 1073741823L) /* - (2^30 - 1) */
1436 w = 1073741823L; /* - (2^30 - 1) */
1439 lab45: p = mem[p].hh.v.RH;
1443 if (eqtb[(hash_size + 1312)].hh.v.RH == 0)
1444 if ((eqtb[(hash_size + 3747)].cint != 0)&&(((eqtb[(hash_size + 3204)].cint >= 0)&&
1445 (prev_graf + 2 > eqtb[(hash_size + 3204)].cint)) ||(prev_graf +
1446 1 < - (integer) eqtb[(hash_size + 3204)].cint)))
1448 l = eqtb[(hash_size + 3733)].cint - abs(eqtb[(hash_size + 3747)].cint);
1449 if (eqtb[(hash_size + 3747)].cint > 0)
1450 s = eqtb[(hash_size + 3747)].cint;
1455 l = eqtb[(hash_size + 3733)].cint;
1460 n = mem[eqtb[(hash_size + 1312)].hh.v.RH].hh.v.LH;
1461 if (prev_graf + 2 >= n)
1462 p = eqtb[(hash_size + 1312)].hh.v.RH + 2 * n;
1463 else p = eqtb[(hash_size + 1312)].hh.v.RH + 2 *(prev_graf + 2);
1464 s = mem[p - 1].cint;
1469 eq_word_define((hash_size + 3207), -1);
1470 eq_word_define((hash_size + 3743), w);
1471 eq_word_define((hash_size + 3744), l);
1472 eq_word_define((hash_size + 3745), s);
1473 if (eqtb[(hash_size + 1316)].hh.v.RH != 0)/* everydisplay */
1474 begin_token_list(eqtb[(hash_size + 1316)].hh.v.RH, 9);
1484 eq_word_define((hash_size + 3207), -1);
1485 if (eqtb[(hash_size + 1315)].hh.v.RH != 0)/* everymath */
1486 begin_token_list(eqtb[(hash_size + 1315)].hh.v.RH, 8);
1491 void start_eq_no (void)
1493 save_stack[save_ptr + 0].cint = cur_chr;
1497 eq_word_define((hash_size + 3207), -1);
1498 if (eqtb[(hash_size + 1315)].hh.v.RH != 0)/* everymath */
1499 begin_token_list(eqtb[(hash_size + 1315)].hh.v.RH, 8);
1503 void scan_math_(halfword p)
1508 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
1509 lab21: switch(cur_cmd)
1514 c = eqtb[(hash_size + 2907) + cur_chr].hh.v.RH;
1518 cur_cs = cur_chr + 1;
1519 cur_cmd = eqtb[cur_cs].hh.b0;
1520 cur_chr = eqtb[cur_cs].hh.v.RH;
1538 scan_fifteen_bit_int ();
1547 scan_twenty_seven_bit_int ();
1549 /* c = cur_val >> 12; */
1556 save_stack[save_ptr + 0].cint = p;
1564 mem[p].hh.b1 = c % 256;
1565 /* mem[p].hh.b1 = c & 255; */ /* last 8 bits */
1566 if ((c >= 28672)&& /* 32768 - 4096 ??? if (c>=var_code) and ... */
1567 ((eqtb[(hash_size + 3207)].cint >= 0)&&
1568 (eqtb[(hash_size + 3207)].cint < 16)))
1569 mem[p].hh.b0 = eqtb[(hash_size + 3207)].cint;
1570 else mem[p].hh.b0 =(c / 256)% 16;
1571 /* else mem[p].hh.b0 =(c >> 8)& 15; */ /* 4 bits to left */
1574 void set_math_char_(integer c)
1579 cur_cs = cur_chr + 1; /* ??? */
1580 /* cur_cmd = eqtb[eqtbextra + cur_cs].hh.b0; */ /* was wrong ??? */
1581 cur_cmd = eqtb[cur_cs].hh.b0;
1582 /* cur_chr = eqtb[cur_cs].hh.v.RH; */ /* should have been eqtbextra ? */
1583 cur_chr = eqtb[cur_cs].hh.v.RH;
1590 mem[p + 1].hh.v.RH = 1;
1591 mem[p + 1].hh.b1 = c % 256;
1592 /* mem[p + 1].hh.b1 = c & 255; */ /* last 8 bits */
1593 mem[p + 1].hh.b0 =(c / 256)% 16;
1594 /* mem[p + 1].hh.b0 =(c >> 8)& 15; */ /* 4 bits to left */
1595 if (c >= 28672) /* 32768 - 4096 ? */
1597 if (((eqtb[(hash_size + 3207)].cint >= 0)&&(eqtb[(hash_size + 3207)].cint < 16))
1599 mem[p + 1].hh.b0 = eqtb[(hash_size + 3207)].cint;
1602 else mem[p].hh.b0 = 16 +(c / 4096);
1603 /* else mem[p].hh.b0 = 16 +(c >> 12); */
1604 mem[tail].hh.v.RH = p;
1609 void math_limit_switch (void)
1612 if (mem[tail].hh.b0 == 17)
1614 mem[tail].hh.b1 = cur_chr;
1617 print_err("Limit controls must follow a math operator");
1618 help1("I'm ignoring this misplaced \\limits or \\nolimits command.");
1622 void scan_delimiter_(halfword p, bool r)
1625 scan_twenty_seven_bit_int ();
1631 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
1635 cur_val = eqtb[(hash_size + 3474) + cur_chr].cint;
1638 scan_twenty_seven_bit_int ();
1647 print_err("Missing delimiter (. inserted)");
1648 help6("I was expecting to see something like `(' or `\\{' or",
1649 "`\\}' here. If you typed, e.g., `{' instead of `\\{', you",
1650 "should probably delete the `{' by typing `1' now, so that",
1651 "braces don't get unbalanced. Otherwise just proceed.",
1652 "Acceptable delimiters are characters whose \\delcode is",
1653 "nonnegative, or you can use `\\delimiter <delimiter code>'.");
1657 /* attempt to speed up - bkph */ /* is compiler smart enough already ? */
1658 mem[p].qqqq.b0 =(cur_val / 1048576L)% 16; /* 2^20 */
1659 /* mem[p].qqqq.b0 =(cur_val >> 20)& 15; */
1660 mem[p].qqqq.b1 =(cur_val / 4096)% 256;
1661 /* mem[p].qqqq.b1 =(cur_val >> 12)& 255; */
1662 mem[p].qqqq.b2 =(cur_val / 256)% 16;
1663 /* mem[p].qqqq.b2 =(cur_val >> 8)& 15; */
1664 mem[p].qqqq.b3 = cur_val % 256;
1665 /* mem[p].qqqq.b3 = cur_val & 255; */
1668 void math_radical (void)
1671 mem[tail].hh.v.RH = get_node(5);
1672 tail = mem[tail].hh.v.RH;
1674 mem[tail].hh.b0 = 24;
1675 mem[tail].hh.b1 = 0;
1676 mem[tail + 1].hh = empty_field;
1677 mem[tail + 3].hh = empty_field;
1678 mem[tail + 2].hh = empty_field;
1679 scan_delimiter(tail + 4, true);
1680 scan_math(tail + 1);
1687 print_err("Please use ");
1688 print_esc("mathaccent");
1689 print_string(" for accents in math mode");
1690 help2("I'm changing \\accent to \\mathaccent here; wish me luck.",
1691 "(Accents are not the same in formulas as they are in text.)");
1695 mem[tail].hh.v.RH = get_node(5);
1696 tail = mem[tail].hh.v.RH;
1698 mem[tail].hh.b0 = 28;
1699 mem[tail].hh.b1 = 0;
1700 mem[tail + 1].hh = empty_field;
1701 mem[tail + 3].hh = empty_field;
1702 mem[tail + 2].hh = empty_field;
1703 mem[tail + 4].hh.v.RH = 1;
1704 scan_fifteen_bit_int ();
1705 mem[tail + 4].hh.b1 = cur_val % 256;
1706 /* mem[tail + 4].hh.b1 = cur_val & 255; */
1707 if ((cur_val >= 28672)&& /* 32768 - 4096 ? */
1708 ((eqtb[(hash_size + 3207)].cint >= 0)&&
1709 (eqtb[(hash_size + 3207)].cint < 16)))
1710 mem[tail + 4].hh.b0 = eqtb[(hash_size + 3207)].cint;
1711 else mem[tail + 4].hh.b0 =(cur_val / 256)% 16;
1712 /* else mem[tail + 4].hh.b0 =(cur_val >> 8)& 15; */
1713 scan_math(tail + 1);
1716 void append_choices (void)
1719 mem[tail].hh.v.RH = new_choice ();
1720 tail = mem[tail].hh.v.RH;
1723 save_stack[save_ptr - 1].cint = 0;
1728 halfword fin_mlist_(halfword p)
1729 {register halfword Result;
1731 if (cur_list.aux_field.cint != 0)
1733 mem[cur_list.aux_field.cint + 3].hh.v.RH = 3;
1734 mem[cur_list.aux_field.cint + 3].hh.v.LH = mem[head]
1737 q = cur_list.aux_field.cint;
1739 q = mem[cur_list.aux_field.cint + 2].hh.v.LH;
1740 if (mem[q].hh.b0 != 30){
1742 return 0; // abort_flag set
1744 mem[cur_list.aux_field.cint + 2].hh.v.LH = mem[q].hh.v.RH;
1745 mem[q].hh.v.RH = cur_list.aux_field.cint;
1746 mem[cur_list.aux_field.cint].hh.v.RH = p;
1750 mem[tail].hh.v.RH = p;
1751 q = mem[head].hh.v.RH;
1758 void build_choices (void)
1763 switch(save_stack[save_ptr - 1].cint)
1765 mem[tail + 1].hh.v.LH = p;
1768 mem[tail + 1].hh.v.RH = p;
1771 mem[tail + 2].hh.v.LH = p;
1775 mem[tail + 2].hh.v.RH = p;
1781 incr(save_stack[save_ptr - 1].cint);
1788 /* small_number t; */
1789 int t; /* 95/Jan/7 */
1794 if ((mem[tail].hh.b0 >= 16)&&
1795 (mem[tail].hh.b0 < 30))
1797 p = tail + 2 + cur_cmd - 7;
1800 if ((p == 0)||(t != 0))
1803 mem[tail].hh.v.RH = new_noad ();
1804 tail = mem[tail].hh.v.RH;
1806 p = tail + 2 + cur_cmd - 7;
1811 print_err("Double superscript");
1812 help1("I treat `x^1^2' essentially like `x^1{}^2'.");
1815 print_err("Double subscript");
1816 help1("I treat `x_1_2' essentially like `x_1{}_2'.");
1823 /* used to continue here with math_fraction etc in tex7.c */
1824 /*****************************************************************************/
1825 /* moved down here to avoid pragma optimize questions 96/Sep/12 */
1826 /* #pragma optimize("g", off) */ /* for MC VS compiler */
1827 /* #pragma optimize("a", off) */ /* for MC VS compiler */
1829 void package_(small_number c)
1834 d = eqtb[(hash_size + 3737)].cint;
1836 save_ptr = save_ptr - 3;
1838 cur_box = hpack(mem[head].hh.v.RH, save_stack[save_ptr
1839 + 2].cint, save_stack[save_ptr + 1].cint);
1841 cur_box = vpackage(mem[head].hh.v.RH, save_stack[
1842 save_ptr + 2].cint, save_stack[save_ptr + 1].cint, d);
1846 p = mem[cur_box + 5].hh.v.RH;
1848 if (mem[p].hh.b0 <= 2)
1849 h = mem[p + 3].cint;
1850 mem[cur_box + 2].cint = mem[cur_box + 2].cint - h + mem[cur_box +
1852 mem[cur_box + 3].cint = h;
1856 box_end(save_stack[save_ptr + 0].cint);
1858 /* #pragma optimize("g", on) */ /* for MC VS compiler */
1859 /* #pragma optimize("a", on) */ /* for MC VS compiler */
1860 /* #pragma optimize("a",) */ /* 94/Jan/25 */
1861 #pragma optimize ("", on) /* 96/Sep/12 */
1862 /****************************************************************************/