6 #pragma warning(disable:4115) // kill rpcasync.h complaint
8 #define MYLIBAPI __declspec(dllexport)
13 #pragma warning(disable:4996)
14 #pragma warning(disable:4131) // old style declarator
15 #pragma warning(disable:4135) // conversion between different integral types
16 #pragma warning(disable:4127) // conditional expression is constant
24 #pragma warning(disable:4244) /* 96/Jan/10 */
26 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
28 /* math_fraction etc used to be in tex7.c */
30 void math_fraction (void)
34 if (cur_list.aux_field.cint != 0)
38 scan_delimiter(lig_trick, false);
39 scan_delimiter(lig_trick, false);
42 scan_dimen(false, false, false);
43 print_err("Ambiguous; you need another { and }");
44 help3("I'm ignoring this fraction specification, since I don't",
45 "know whether a construction like `x \\over y \\over z'",
46 "means `{x \\over y} \\over z' or `x \\over {y \\over z}'.");
51 cur_list.aux_field.cint = get_node(6);
52 mem[cur_list.aux_field.cint].hh.b0 = 25;
53 mem[cur_list.aux_field.cint].hh.b1 = 0;
54 mem[cur_list.aux_field.cint + 2].hh.v.RH = 3;
55 mem[cur_list.aux_field.cint + 2].hh.v.LH = mem[head]
57 mem[cur_list.aux_field.cint + 3].hh = empty_field;
58 mem[cur_list.aux_field.cint + 4].qqqq = null_delimiter;
59 mem[cur_list.aux_field.cint + 5].qqqq = null_delimiter;
60 mem[head].hh.v.RH = 0;
64 scan_delimiter(cur_list.aux_field.cint + 4, false);
65 scan_delimiter(cur_list.aux_field.cint + 5, false);
70 scan_dimen(false, false, false);
71 mem[cur_list.aux_field.cint + 1].cint = cur_val;
75 mem[cur_list.aux_field.cint + 1].cint = 1073741824L; /* 2^30 */
78 mem[cur_list.aux_field.cint + 1].cint = 0;
84 void math_left_right (void)
89 if ((t == 31)&&(cur_group != 16))
93 scan_delimiter(lig_trick, false);
96 help1("I'm ignoring a \\right that had no matching \\left.");
107 scan_delimiter(p + 1, false);
111 mem[head].hh.v.RH = p;
119 mem[tail].hh.v.RH = new_noad();
120 tail = mem[tail].hh.v.RH;
122 mem[tail].hh.b0 = 23;
123 mem[tail + 1].hh.v.RH = 3;
124 mem[tail + 1].hh.v.LH = p;
129 void after_math (void)
147 if ((font_params[eqtb[(hash_size + 1837)].hh.v.RH]< 22)||
148 (font_params[eqtb[(hash_size + 1853)].hh.v.RH]< 22)||
149 (font_params[eqtb[(hash_size + 1869)].hh.v.RH]< 22))
151 print_err("Math formula deleted: Insufficient symbol fonts");
152 help3("Sorry, but I can't typeset math unless \\textfont Sorry, but I can't typeset math unless \\textfont 2",
153 "and \\scriptfont 2 and \\scriptscriptfont 2 have and \\scriptfont 2 and \\scriptscriptfont 2 have all",
154 "the \\fontdimen values needed in math symbol the \\fontdimen values needed in math symbol fonts..");
159 else if ((font_params[eqtb[(hash_size + 1838)].hh.v.RH]< 13)||
160 (font_params[eqtb[(hash_size + 1854)].hh.v.RH]< 13)||
161 (font_params[eqtb[(hash_size + 1870)].hh.v.RH]< 13))
163 print_err("Math formula deleted: Insufficient extension fonts");
164 help3("Sorry, but I can't typeset math unless \\textfont 3",
165 "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
166 "the \\fontdimen values needed in math extension fonts.");
174 if (mode == - (integer) m)
180 print_err("Display math should end with $$");
181 help2("The `$' that I just saw supposedly matches a previous `$$'.",
182 "So I shall assume that you typed `$$' both times.");
188 mlist_penalties = false;
190 a = hpack(mem[temp_head].hh.v.RH, 0, 1);
193 if (save_stack[save_ptr + 0].cint == 1)
196 if ((font_params[eqtb[(hash_size + 1837)].hh.v.RH]< 22)||
197 (font_params[eqtb[(hash_size + 1853)].hh.v.RH]< 22)||
198 (font_params[eqtb[(hash_size + 1869)].hh.v.RH]< 22))
200 print_err("Math formula deleted: Insufficient symbol fonts");
201 help3("Sorry, but I can't typeset math unless \\textfont 2",
202 "and \\scriptfont 2 and \\scriptscriptfont 2 have all",
203 "the \\fontdimen values needed in math symbol fonts.");
208 else if ((font_params[eqtb[(hash_size + 1838)].hh.v.RH]< 13)||
209 (font_params[eqtb[(hash_size + 1854)].hh.v.RH]< 13)||
210 (font_params[eqtb[(hash_size + 1870)].hh.v.RH]< 13))
212 print_err("Math formula deleted: Insufficient extension fonts");
213 help3("Sorry, but I can't typeset math unless \\textfont 3",
214 "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
215 "the \\fontdimen values needed in math extension fonts.");
227 mem[tail].hh.v.RH = new_math(math_surround, 0);
228 tail = mem[tail].hh.v.RH;
232 mlist_penalties =(mode > 0);
234 mem[tail].hh.v.RH = mem[temp_head].hh.v.RH;
235 while(mem[tail].hh.v.RH != 0)tail =
238 mem[tail].hh.v.RH = new_math(math_surround, 1);
239 tail = mem[tail].hh.v.RH;
250 print_err("Display math should end with $$");
251 help2("The `$' that I just saw supposedly matches a previous `$$'.",
252 "So I shall assume that you typed `$$' both times.");
258 mlist_penalties = false;
260 p = mem[temp_head].hh.v.RH;
261 adjust_tail = adjust_head;
263 p = mem[b + 5].hh.v.RH;
269 if ((a == 0)|| danger)
277 q = e + font_info[6 + param_base[eqtb[(hash_size + 1837)].hh.v.RH]].cint;
281 if ((e != 0)&&((w - totalshrink[0]+ q <= z)||(totalshrink
282 [1]!= 0)||(totalshrink[2]!= 0)||(totalshrink[3]!= 0)
286 b = hpack(p, z - q, 0);
300 if ((e > 0)&&(d < 2 * e))
304 if (!(p >= hi_mem_min))
305 if (mem[p].hh.b0 == 10)
309 mem[tail].hh.v.RH = new_penalty(pre_display_penalty);
310 tail = mem[tail].hh.v.RH;
312 if ((d + s <= pre_display_size)|| l)
327 mem[tail].hh.v.RH = new_penalty(10000);
328 tail = mem[tail].hh.v.RH;
333 mem[tail].hh.v.RH = new_param_glue(g1);
334 tail = mem[tail].hh.v.RH;
338 r = new_kern(z - w - e - d);
353 mem[b + 4].cint = s + d;
355 if ((a != 0)&&(e == 0)&& ! l)
358 mem[tail].hh.v.RH = new_penalty(10000);
359 tail = mem[tail].hh.v.RH;
361 mem[a + 4].cint = s + z - mem[a + 1].cint;
365 if (t != adjust_head)
367 mem[tail].hh.v.RH = mem[adjust_head].hh.v.RH;
371 mem[tail].hh.v.RH = new_penalty(post_display_penalty);
372 tail = mem[tail].hh.v.RH;
376 mem[tail].hh.v.RH = new_param_glue(g2);
377 tail = mem[tail].hh.v.RH;
379 resume_after_display();
383 void resume_after_display (void)
386 if (cur_group != 15){
387 confusion("display");
388 return; // abort_flag set
391 prev_graf = prev_graf + 3;
395 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
396 /* was clang = 0; etc in 3.141 new stuff follows */
399 else if (language > 255)
401 else cur_lang = language;
403 prev_graf =(norm_min(left_hyphen_min) * 64 +
404 norm_min(right_hyphen_min)) * 65536L + cur_lang;
405 /* eqtb ??? hash_size ? hash_size + hash_extra ? norm_min etc */
406 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
409 if (cur_cmd != 10) back_input();
416 void get_r_token (void)
421 } while(!(cur_tok != 2592));
422 /* if ((cur_cs == 0)||(cur_cs > (hash_size + 514))) */ /* 95/Jan/10 */
423 if ((cur_cs == 0)||(cur_cs > (hash_size + hash_extra + 514))) {
424 print_err("Missing control sequence inserted");
425 help5("Please don't say `\\def cs{...}', say `\\def\\cs{...}'.",
426 "I've inserted an inaccessible control sequence so that your",
427 "definition will be completed without mixing me up too badly.",
428 "You can recover graciously from this error, if you're",
429 "careful; see exercise 27.2 in The TeXbook.");
432 /* cur_tok = (hash_size + 4609); */
433 /* cur_tok = (hash_size + 4095 + 514); */
434 cur_tok = (hash_size + hash_extra + 4095 + 514); /* 96/Jan/10 */
440 void trap_zero_glue (void)
442 if ((mem[cur_val + 1].cint == 0)&&(mem[cur_val + 2].cint == 0)
443 &&(mem[cur_val + 3].cint == 0))
445 incr(mem[0].hh.v.RH); /* mem[mem_bot]? */ /* mem[null]? */
446 delete_glue_ref(cur_val);
451 void do_register_command_ (small_number a)
460 if ((cur_cmd >= 73)&&(cur_cmd <= 76))
468 print_err("You can't use `");
469 print_cmd_chr(cur_cmd, cur_chr);
470 print_string("' after ");
472 help1("I'm forgetting what you said and not changing anything.");
478 scan_eight_bit_int();
481 l = cur_val + (hash_size + 3218);
484 l = cur_val + (hash_size + 3751);
487 l = cur_val + (hash_size + 800);
490 l = cur_val + (hash_size + 1056);
496 scan_optional_equals();
497 else if (scan_keyword("by")) /* by */
507 scan_dimen(false, false, false);
510 cur_val = cur_val + eqtb[l].cint;
516 q = new_spec(cur_val);
518 delete_glue_ref(cur_val);
519 mem[q + 1].cint = mem[q + 1].cint + mem[r + 1].cint;
520 if (mem[q + 2].cint == 0)
522 if (mem[q].hh.b0 == mem[r].hh.b0)
523 mem[q + 2].cint = mem[q + 2].cint + mem[r + 2].cint;
524 else if ((mem[q].hh.b0 < mem[r].hh.b0)&&(mem[r + 2]
527 mem[q + 2].cint = mem[r + 2].cint;
528 mem[q].hh.b0 = mem[r].hh.b0;
530 if (mem[q + 3].cint == 0)
532 if (mem[q].hh.b1 == mem[r].hh.b1)
533 mem[q + 3].cint = mem[q + 3].cint + mem[r + 3].cint;
534 else if ((mem[q].hh.b1 < mem[r].hh.b1)&&(mem[r + 3]
537 mem[q + 3].cint = mem[r + 3].cint;
538 mem[q].hh.b1 = mem[r].hh.b1;
548 cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 2147483647L);
550 else cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 1073741823L);
552 else cur_val = x_over_n(eqtb[l].cint, cur_val);
554 s = eqtb[l].hh.v.RH; /* l may be used ... */
558 mem[r + 1].cint = mult_and_add(mem[s + 1].cint, cur_val, 0,
559 1073741823L); /* 2^30 - 1 */
560 mem[r + 2].cint = mult_and_add(mem[s + 2].cint, cur_val, 0,
561 1073741823L); /* 2^30 - 1 */
562 mem[r + 3].cint = mult_and_add(mem[s + 3].cint, cur_val, 0,
563 1073741823L); /* 2^30 - 1 */
566 mem[r + 1].cint = x_over_n(mem[s + 1].cint, cur_val);
567 mem[r + 2].cint = x_over_n(mem[s + 2].cint, cur_val);
568 mem[r + 3].cint = x_over_n(mem[s + 3].cint, cur_val);
574 print_err("Arithmetic overflow");
575 help2("I can't carry out that multiplication or division,",
576 "since the result is out of range.");
577 /* 423 in tex82.bug */
578 if (p >= 2) delete_glue_ref(cur_val);
584 geq_word_define(l, cur_val);
585 else eq_word_define(l, cur_val);
590 geq_define(l, 117, cur_val);
591 else eq_define(l, 117, cur_val);
594 /* called only from itex.c */
596 void alter_aux (void)
599 if (cur_chr != abs(mode)) {
600 report_illegal_case();
604 scan_optional_equals();
607 scan_dimen(false, false, false);
608 cur_list.aux_field.cint = cur_val;
612 if ((cur_val <= 0)||(cur_val > 32767))
614 print_err("Bad space factor");
615 help1("I allow only values in the range 1..32767 here.");
618 else space_factor = cur_val;
623 void alter_prev_graf (void)
626 nest[nest_ptr]= cur_list;
628 while(abs(nest[p].mode_field)!= 1)decr(p);
629 scan_optional_equals();
634 print_esc("prevgraf");
635 help1("I allow only nonnegative values here.");
640 nest[p].pg_field = cur_val;
641 cur_list = nest[nest_ptr];
645 void alter_page_so_far (void)
649 scan_optional_equals();
650 scan_dimen(false, false, false);
651 page_so_far[c]= cur_val;
654 void alter_integer (void)
658 scan_optional_equals();
660 if (c == 0)dead_cycles = cur_val;
661 else insert_penalties = cur_val;
664 void alter_box_dimen (void)
669 scan_eight_bit_int();
671 scan_optional_equals();
672 scan_dimen(false, false, false);
673 if (eqtb[(hash_size + 1578) + b].hh.v.RH != 0)
674 mem[eqtb[(hash_size + 1578) + b].hh.v.RH + c].cint = cur_val;
677 void new_font_(small_number a)
681 internal_font_number f;
684 str_number flushablestring;
685 if (job_name == 0) open_log_file();
688 if (u >= hash_base) /* if u >= hash_base then t <- text(u); p.1257 */
690 else if (u >= single_base) /* if u >= single_base then ... */
691 /* if u=null_cs then t:="FONT"@+else t:=u-single_base */
694 else t = u - single_base; /* else t <- u - single_base */
696 old_setting = selector;
698 print_string("FONT");
699 print(u - active_base);
700 selector = old_setting;
702 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
703 #ifdef ALLOCATESTRING
704 if (pool_ptr + 1 > current_pool_size)
705 str_pool = realloc_str_pool (increment_pool_size);
706 if (pool_ptr + 1 > current_pool_size) { /* 94/Jan/24 */
707 overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/9 */
708 return; // abort_flag set
711 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
712 if (pool_ptr + 1 > pool_size) {
713 overflow("pool size", pool_size - init_pool_ptr); /* pool size */
714 return; // abort_flag set
720 if ((a >= 4)) geq_define(u, 87, 0);
721 else eq_define(u, 87, 0);
722 scan_optional_equals();
726 name_in_progress = true;
727 if (scan_keyword("at")) /* at */
729 scan_dimen(false, false, false);
731 if ((s <= 0)||(s >= 134217728L)) /* 2^27 */
733 print_err("Improper `at' size(");
735 print_string("pt), replaced by 10pt");
736 help2("I can only handle fonts at positive sizes that are",
737 "less than 2048pt, so I've changed what you said to 10pt.");
739 s = 10 * 65536L; /* 10pt */
742 else if (scan_keyword("scaled")) /* scaled */
745 s = - (integer) cur_val;
746 if ((cur_val <= 0)||(cur_val > 32768L)) {
747 print_err("Illegal magnification has been changed to 1000");
748 help1("The magnification ratio must be between 1 and 32768.");
754 name_in_progress = false;
756 flushablestring = str_ptr - 1;
757 if (trace_flag) { /* debugging stuff only 98/Oct/5 */
758 int i, k1, k2, l1, l2;
760 k1 = str_start[cur_area];
761 k2 = str_start[cur_name];
762 l1 = str_start[cur_area + 1] - str_start[cur_area];
763 l2 = str_start[cur_name + 1] - str_start[cur_name];
765 show_line("FONT ", 0);
766 for (i = 0; i < l1; i++) {
767 *sch++ = str_pool[i+k1];
769 for (i = 0; i < l2; i++) {
770 *sch++ = str_pool[i+k2];
774 show_line(log_line, 0);
776 /* if (ignore_frozen) goto lab69; */ /* 98/Oct/5 */
778 /* paragraph 1260 for f <- fontbase+1 to font_ptr do */
780 register integer for_end;
785 /* if str_eq_str(font_name[f],cur_name) ^ str_eq_str(font_area[f],cur_area) */
786 if (str_eq_str(font_name[f], cur_name)&&
787 str_eq_str(font_area[f], cur_area)) {
788 if (cur_name == flushablestring){
791 pool_ptr = str_start[str_ptr];
793 cur_name = font_name[f];
795 /* if (ignore_frozen) continue; */ /* 98/Oct/5 */
796 if (s > 0) { /* if pt size was specified */
797 if (s == font_size[f]){
798 /* if (ignore_frozen == 0) */
799 if (ignore_frozen == 0 || f > frozenfontptr) { /* 99/Mar/26 */
801 sprintf(log_line, "SKIPPING %ld ", s);
802 show_line(log_line, 0);
808 /* else if font_size[f] = xn_over_d(font_dsize[f],-s,1000) then goto common_ending */
809 else if (font_size[f]== xn_over_d(font_dsize[f],
810 - (integer) s, 1000)) { /* if using design size */
811 /* if (ignore_frozen == 0) */
812 if (ignore_frozen == 0 || f > frozenfontptr) { /* 99/Mar/26 */
814 sprintf(log_line, "SKIPPING %ld ", s);
815 show_line(log_line, 0);
821 while(f++ < for_end);
824 /* lab69: */ /* 98/Oct/5 */
825 /* end of paragraph 1257 */
826 if (trace_flag) show_line("READING ", 0); /* debugging only */
827 f = read_font_info(u, cur_name, cur_area, s);
829 /* common_ending: equiv[u] <- f; */ /* use existing font info */
832 sprintf(log_line, "NEW FONT %d ", f); /* debugging only */
833 show_line(log_line, 0);
836 /* eqtb[(hash_size + 524) + f]= eqtb[u];*/ /* eqtb[frozen_null+font+f] */
837 eqtb[(hash_size + hash_extra + 524) + f]= eqtb[u]; /* 96/Jan/10 */
838 #ifdef SHORTHASH /* debugging only 1996/Jan/20 */
840 sprintf(log_line, "ERROR: %s too large %d\n", "hash_used", t);
841 show_line(log_line, 1);
844 /* hash[(hash_size + 524) + f].v.RH = t; */
845 hash[(hash_size + hash_extra + 524) + f].v.RH = t; /* 96/Jan/10 */
848 void new_interaction (void)
851 interaction = cur_chr;
852 if (interaction == 0) selector = 16;
854 if (log_opened) selector = selector + 2;
857 void do_assignments (void)
862 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
865 set_box_allowed = false;
867 set_box_allowed = true;
871 void open_or_close_in (void)
878 if (read_open[n]!= 2)
880 (void) a_close(read_file[n]);
885 scan_optional_equals();
887 pack_file_name(cur_name, cur_area, cur_ext);
888 /* *** some changes in following in 3.14159 *** */
889 /* if current extension is *not* empty, try to open using name as is */
890 /* string 335 is "" the empty string */
891 if ((cur_ext != 335)&& a_open_in(read_file[n], TEXINPUTPATH))
893 /* we get here if extension is "", or file with extension failed to open */
894 /* if current extension is not `tex,' and `tex' is not irrelevant, try it */
895 /* string 785 is .tex */
896 else if ((cur_ext != 785)&&(name_length + 5 < PATHMAX)&&
897 /* *** some changes in above file name handling *** */
898 /* (! extensionirrelevantp(name_of_file, "tex"))) */
899 (! extensionirrelevantp(name_of_file, name_length, "tex")))
901 name_of_file[name_length + 1]= 46; /* .tex */
902 name_of_file[name_length + 2]= 116;
903 name_of_file[name_length + 3]= 101;
904 name_of_file[name_length + 4]= 120;
905 name_of_file[name_length + 5]= 32;
906 name_length = name_length + 4;
907 if (a_open_in(read_file[n], TEXINPUTPATH))
910 /* more changes here in 3.14159 *** */
911 name_length = name_length - 4; /* remove ".tex" again */
912 name_of_file[name_length + 1]= 32; /* ' ' */
913 /* string 335 is "" the empty string */
914 if ((cur_ext == 335)&& a_open_in(read_file[n], TEXINPUTPATH))
916 else if (maketextex () && a_open_in(read_file[n], TEXINPUTPATH))
923 void issue_message (void)
929 mem[lig_trick].hh.v.RH = scan_toks(false, true);
930 old_setting = selector;
933 selector = old_setting;
936 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
937 #ifdef ALLOCATESTRING
938 if (pool_ptr + 1 > current_pool_size)
939 str_pool = realloc_str_pool (increment_pool_size);
940 if (pool_ptr + 1 > current_pool_size){ /* in case it failed 94/Jan/24 */
941 overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
942 return; // abort_flag set
945 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
946 if (pool_ptr + 1 > pool_size){
947 overflow("pool size", pool_size - init_pool_ptr); /* pool size */
948 return; // abort_flag set
955 if (term_offset +(str_start[s + 1]- str_start[s])> max_print_line -
958 else if ((term_offset > 0)||(file_offset > 0))
968 if (eqtb[(hash_size + 1321)].hh.v.RH != 0)
970 else if (long_help_seen)
971 help1("(That was another \\errmessage.)");
975 long_help_seen = true;
976 help4("This error message was generated by an \\errmessage",
977 "command, so I can't give any explicit help.",
978 "Pretend that you're Hercule Poirot: Examine all clues,",
979 "and deduce the truth by order and method.");
982 use_err_help = false;
986 pool_ptr = str_start[str_ptr];
990 void shift_case (void)
997 p = scan_toks(false, false);
998 p = mem[def_ref].hh.v.RH;
999 while (p != 0) { /* while p <> null ... p.1288 */
1000 t = info(p); /* t <- info(p) p.1289 */
1002 if (t < 4095 + single_base) /* 4095 + 257 = cs_tokenflag + single_base */
1005 if (eqtb[b + c].hh.v.RH != 0)
1006 mem[p].hh.v.LH = t - c + eqtb[b + c].hh.v.RH;
1010 begin_token_list(mem[def_ref].hh.v.RH, 3);
1012 mem[def_ref].hh.v.RH = avail;
1021 void show_whatever (void)
1034 scan_eight_bit_int();
1039 if (eqtb[(hash_size + 1578) + cur_val].hh.v.RH == 0)
1040 print_string("void");
1042 show_box(eqtb[(hash_size + 1578) + cur_val].hh.v.RH);
1048 if (interaction == 3)
1063 if (interaction == 3)
1066 token_show(temp_head);
1067 flush_list(mem[temp_head].hh.v.RH);
1072 end_diagnostic(true);
1075 if (tracing_online <= 0)
1078 print_string(" (see the transcript file)");
1082 if (interaction < 3) {
1085 } else if (tracing_online > 0) {
1086 help3("This isn't an error message; I'm just \\showing something.",
1087 "Type `I\\show...' to show more (e.g., \\show\\cs,",
1088 "\\showthe\\count10, \\showbox255, \\showlists).");
1090 help5("This isn't an error message; I'm just \\showing something.",
1091 "Type `I\\show...' to show more (e.g., \\show\\cs,",
1092 "\\showthe\\count10, \\showbox255, \\showlists).",
1093 "And type `I\\tracingonline=1\\show...' to show boxes and",
1094 "lists on your terminal as well as in the transcript file.");
1099 void new_whatsit_(small_number s, small_number w)
1105 mem[tail].hh.v.RH = p;
1109 void new_write_whatsit_(small_number w)
1111 new_whatsit(cur_chr, w);
1113 scan_four_bit_int();
1118 else if (cur_val > 15)
1121 mem[tail + 1].hh.v.LH = cur_val;
1124 void do_extension (void)
1126 /* integer i, j, k; */
1128 /* halfword p, q, r; */
1133 new_write_whatsit(3);
1134 scan_optional_equals();
1136 mem[tail + 1].hh.v.RH = cur_name;
1137 mem[tail + 2].hh.v.LH = cur_area;
1138 mem[tail + 2].hh.v.RH = cur_ext;
1144 new_write_whatsit(2);
1146 p = scan_toks(false, false);
1147 mem[tail + 1].hh.v.RH = def_ref;
1152 new_write_whatsit(2);
1153 mem[tail + 1].hh.v.RH = 0;
1159 mem[tail + 1].hh.v.LH = 0;
1160 p = scan_toks(false, true);
1161 mem[tail + 1].hh.v.RH = def_ref;
1167 if ((cur_cmd == 59)&&(cur_chr <= 2))
1172 flush_node_list(tail);
1180 if (abs(mode)!= 102){
1181 report_illegal_case();
1186 if (cur_val <= 0) clang = 0;
1187 else if (cur_val > 255)
1189 else clang = cur_val;
1190 mem[tail + 1].hh.v.RH = clang;
1191 mem[tail + 1].hh.b0 = norm_min(left_hyphen_min);
1192 mem[tail + 1].hh.b1 = norm_min(right_hyphen_min);
1197 confusion("display");
1198 return; // abort_flag set
1204 void fix_language (void)
1207 int l; /* 95/Jan/7 */
1210 else if (language > 255)
1215 mem[tail + 1].hh.v.RH = l;
1217 mem[tail + 1].hh.b0 = norm_min(left_hyphen_min);
1218 mem[tail + 1].hh.b1 = norm_min(right_hyphen_min);
1222 void handle_right_brace (void)
1234 print_err("Too many }'s");
1235 help2("You've closed more groups than you opened.",
1236 "Such booboos are generally harmless, so keep going.");
1243 extra_right_brace();
1250 adjust_tail = adjust_head;
1269 q = eqtb[(hash_size + 792)].hh.v.RH;
1270 incr(mem[q].hh.v.RH);
1271 d = split_max_depth;
1272 f = floating_penalty;
1275 p = vpackage(mem[head].hh.v.RH, 0, 1, 1073741823L); /* 2^30 - 1 */
1277 if (save_stack[save_ptr + 0].cint < 255) {
1279 mem[tail].hh.v.RH = get_node(5);
1280 tail = mem[tail].hh.v.RH;
1282 mem[tail].hh.b0 = 3;
1283 mem[tail].hh.b1 = save_stack[save_ptr + 0].cint;
1284 mem[tail + 3].cint = mem[p + 3].cint + mem[p + 2].cint;
1285 mem[tail + 4].hh.v.LH = mem[p + 5].hh.v.RH;
1286 mem[tail + 4].hh.v.RH = q;
1287 mem[tail + 2].cint = d;
1288 mem[tail + 1].cint = f;
1291 mem[tail].hh.v.RH = get_node(2);
1292 tail = mem[tail].hh.v.RH;
1294 mem[tail].hh.b0 = 5;
1295 mem[tail].hh.b1 = 0;
1296 mem[tail + 1].cint = mem[p + 5].hh.v.RH;
1300 if (nest_ptr == 0) {
1307 if ((cur_input.loc_field != 0)||((cur_input.index_field != 6)&&(
1308 cur_input.index_field != 3)))
1310 print_err("Unbalanced output routine");
1311 help2("Your sneaky output routine has problematic {'s and/or }'s.",
1312 "I can't handle that very well; good luck.");
1316 } while(!(cur_input.loc_field == 0));
1321 output_active = false;
1322 insert_penalties = 0;
1323 if (eqtb[(hash_size + 1833)].hh.v.RH != 0)
1325 print_err("Output routine didn't use all of ");
1328 help3("Your \\output commands should empty \\box255,",
1329 "e.g., by saying `\\ship_out\\box255'.",
1330 "Proceed; I'll discard its present contents.");
1335 mem[page_tail].hh.v.RH = mem[head].hh.v.RH;
1338 if (mem[page_head].hh.v.RH != 0)
1340 if (mem[contrib_head].hh.v.RH == 0)
1341 nest[0].tail_field = page_tail;
1342 mem[page_tail].hh.v.RH = mem[contrib_head].hh.v.RH;
1343 mem[contrib_head].hh.v.RH = mem[page_head].hh.v.RH;
1344 mem[page_head].hh.v.RH = 0;
1345 page_tail = page_head;
1352 build_discretionary();
1355 /* align_group: begin back_input; cur_tok:=cs_token_flag+frozen_cr; */
1358 /* cur_tok = (hash_size + 4610); */
1359 /* cur_tok = (hash_size + 4095 + 515); */
1360 cur_tok = (hash_size + hash_extra + 4095 + 515);
1361 print_err("Missing ");
1363 print_string("inserted");
1364 help1("I'm guessing that you meant to end an alignment here.");
1379 save_ptr = save_ptr - 2;
1380 p = vpackage(mem[head].hh.v.RH, save_stack[
1381 save_ptr + 1].cint, save_stack[save_ptr + 0].cint,
1382 1073741823L); /* 2^30 - 1 */
1385 mem[tail].hh.v.RH = new_noad();
1386 tail = mem[tail].hh.v.RH;
1388 mem[tail].hh.b0 = 29;
1389 mem[tail + 1].hh.v.RH = 2;
1390 mem[tail + 1].hh.v.LH = p;
1400 mem[save_stack[save_ptr + 0].cint].hh.v.RH = 3;
1402 mem[save_stack[save_ptr + 0].cint].hh.v.LH = p;
1404 if (mem[p].hh.v.RH == 0)
1405 if (mem[p].hh.b0 == 16)
1407 if (mem[p + 3].hh.v.RH == 0)
1408 if (mem[p + 2].hh.v.RH == 0)
1410 mem[save_stack[save_ptr + 0].cint].hh = mem[p + 1].hh;
1414 else if (mem[p].hh.b0 == 28)
1415 if (save_stack[save_ptr + 0].cint == tail + 1)
1416 if (mem[tail].hh.b0 == 16)
1419 while(mem[q].hh.v.RH != tail)q = mem[q].hh
1429 confusion("rightbrace");
1430 return; // abort_flag set
1436 /* main control loop */
1437 void main_control (void)
1438 {/* 60 21 70 80 90 91 92 95 100 101 110 111 112 120 10 */
1440 integer bSuppress; /* 199/Jan/5 */
1442 if (eqtb[(hash_size + 1319)].hh.v.RH != 0)/* everyjob */
1443 begin_token_list(eqtb[(hash_size + 1319)].hh.v.RH, 12);
1446 get_x_token(); /* big_switch */
1449 if (OK_to_interrupt){
1452 if (interrupt != 0){
1453 pause_for_instructions();
1460 if (panicking)check_mem(false);
1462 if (tracing_commands > 0)
1465 /* the big switch --- don't bother to test abort_flag ??? */
1466 switch(abs(mode)+ cur_cmd){
1482 if ((cur_cmd == 11)||(cur_cmd == 12)||(cur_cmd == 68)||(
1484 cancel_boundary = true;
1489 if (space_factor == 1000)goto lab120;
1512 } while(!(cur_cmd != 10));
1517 if (its_all_over ())return;
1532 report_illegal_case();
1575 insert_dollar_sign();
1582 mem[tail].hh.v.RH = scan_rule_spec();
1583 tail = mem[tail].hh.v.RH;
1586 cur_list.aux_field.cint = ignore_depth;
1587 else if (abs(mode)== 102)
1588 space_factor = 1000;
1615 if (cur_group == 14) unsave();
1621 handle_right_brace();
1628 scan_dimen(false, false, false);
1629 if (t == 0)scan_box(cur_val);
1630 else scan_box(- (integer) cur_val);
1636 /* scan_box(leader_flag-a_leaders+cur_chr); */
1637 scan_box(1073742237L + cur_chr); /* 2^30 + 513 - 100 ? */
1645 new_graf(cur_chr > 0);
1679 if (align_state < 0){
1700 begin_insert_or_adjust();
1723 append_italic_correction();
1727 mem[tail].hh.v.RH = new_kern(0);
1728 tail = mem[tail].hh.v.RH;
1733 append_discretionary();
1762 if (cur_group == 15)init_align();
1780 if (cur_group == 15) start_eq_no();
1786 mem[tail].hh.v.RH = new_noad();
1787 tail = mem[tail].hh.v.RH;
1790 scan_math(tail + 1);
1796 set_math_char(eqtb[(hash_size + 2907) + cur_chr].hh.v.RH);
1802 set_math_char(eqtb[(hash_size + 2907) + cur_chr].hh.v.RH);
1807 scan_fifteen_bit_int();
1808 set_math_char(cur_val);
1812 set_math_char(cur_chr);
1816 scan_twenty_seven_bit_int();
1817 set_math_char(cur_val / 4096);
1818 /* set_math_char(cur_val >> 12); */
1824 mem[tail].hh.v.RH = new_noad();
1825 tail = mem[tail].hh.v.RH;
1827 mem[tail].hh.b0 = cur_chr;
1828 scan_math(tail + 1);
1832 math_limit_switch();
1843 scan_spec(12, false);
1847 cur_list.aux_field.cint = ignore_depth;
1848 if (eqtb[(hash_size + 1318)].hh.v.RH != 0)/* everyvbox */
1849 begin_token_list(eqtb[(hash_size + 1318)].hh.v.RH, 11);
1854 mem[tail].hh.v.RH = new_style(cur_chr);
1855 tail = mem[tail].hh.v.RH;
1861 mem[tail].hh.v.RH = new_glue(0);
1862 tail = mem[tail].hh.v.RH;
1864 mem[tail].hh.b1 = 98;
1881 if (cur_group == 15)after_math();
1981 after_token = cur_tok;
1989 save_for_after(cur_tok);
2017 } /* end of big switch */
2018 goto lab60; /* main_loop */
2021 main_s = eqtb[(hash_size + 2651) + cur_chr].hh.v.RH;
2023 space_factor = 1000;
2024 else if (main_s < 1000)
2027 space_factor = main_s;
2029 else if (space_factor < 1000)
2030 space_factor = 1000;
2031 else space_factor = main_s;
2032 main_f = eqtb[(hash_size + 1834)].hh.v.RH;
2033 bchar = font_bchar[main_f];
2034 false_bchar = font_false_bchar[main_f];
2036 if (language != clang)
2041 lig_stack = get_avail();
2043 avail = mem[lig_stack].hh.v.RH;
2044 mem[lig_stack].hh.v.RH = 0;
2051 mem[lig_stack].hh.b0 = main_f;
2053 mem[lig_stack].hh.b1 = cur_l;
2055 if (cancel_boundary)
2057 /* begin cancel_boundary:=false; main_k:=non_address; l.20093 */
2058 cancel_boundary = false;
2059 /* main_k:=non_address 3.14159 */
2060 /* main_k = font_mem_size; */ /* OK ? 1993/Nov/29 */
2061 main_k = non_address; /* i.e. --- 1995/Jan/15 3.14159 */
2063 else main_k = bchar_label[main_f];
2064 /* if main_k=non_address then goto main_loop_move+2; l.20096 */
2065 /* if (main_k == font_mem_size) */
2066 if (main_k == non_address) /* i.e. 0 --- 1995/Jan/15 */
2067 /* cur_r:=cur_l; cur_l:=non_char; */
2070 cur_l = 256; /* cur_l:=non_char; */
2071 /* goto main_lig_loop+1; l.20071 */
2074 /* main_loop_wrapup:@<Make a ligature node, if |ligature_present|;
2075 insert a null discretionary, if appropriate@>; */
2076 /* @d wrapup(#)==if cur_l<non_char then */
2077 /* main_loop_wrapup */
2078 lab80: if (cur_l < 256)
2080 /* begin if character(tail)=qi(hyphen_char[main_f]) then
2081 if link(cur_q)>null then ... l.20107 */
2082 if (mem[tail].hh.b1 == hyphen_char[main_f])
2083 /* if (mem[cur_q].hh.v.RH > 0) */ /* NO! */
2084 if (mem[cur_q].hh.v.RH != 0) /* BUG FIX l.20107 */
2086 if (ligature_present)
2088 main_p = new_ligature(main_f, cur_l, mem[cur_q].hh.v.RH);
2091 mem[main_p].hh.b1 = 2;
2097 incr(mem[main_p].hh.b1);
2100 mem[cur_q].hh.v.RH = main_p;
2102 ligature_present = false;
2104 /* if ins_disc then l.20110 */
2108 /* if mode>0 then tail_append(new_disc); l.20112 */
2111 mem[tail].hh.v.RH = new_disc();
2112 tail = mem[tail].hh.v.RH;
2117 /* main_loop_move */
2119 if (lig_stack == 0) goto lab21;
2121 cur_l = mem[lig_stack].hh.b1;
2124 if (!(lig_stack >= hi_mem_min)) goto lab95;
2126 lab92: if ((cur_chr < font_bc[main_f])||(cur_chr > font_ec[main_f]))
2128 char_warning(main_f, cur_chr);
2130 mem[lig_stack].hh.v.RH = avail;
2139 main_i = font_info[char_base[main_f]+ cur_l].qqqq;
2140 if (!(main_i.b0 > 0))
2142 char_warning(main_f, cur_chr);
2144 mem[lig_stack].hh.v.RH = avail;
2154 link(tail) = lig_stack;
2158 /* main_loop_lookahead */
2161 if (cur_cmd == 11) goto lab101;
2162 if (cur_cmd == 12) goto lab101;
2163 if (cur_cmd == 68) goto lab101;
2165 if (cur_cmd == 11) goto lab101;
2166 if (cur_cmd == 12) goto lab101;
2167 if (cur_cmd == 68) goto lab101;
2168 if (cur_cmd == 16) {
2173 if (cur_cmd == 65) bchar = 256;
2178 lab101: main_s = eqtb[(hash_size + 2651) + cur_chr].hh.v.RH;
2180 space_factor = 1000;
2181 else if (main_s < 1000)
2184 space_factor = main_s;
2186 else if (space_factor < 1000)
2187 space_factor = 1000;
2188 else space_factor = main_s;
2192 lig_stack = get_avail();
2194 avail = mem[lig_stack].hh.v.RH;
2195 mem[lig_stack].hh.v.RH = 0;
2202 mem[lig_stack].hh.b0 = main_f;
2204 mem[lig_stack].hh.b1 = cur_r;
2205 if (cur_r == false_bchar)
2208 // main_lig_loop:@<If there's a ligature/kern command relevant to |cur_l| and
2209 // |cur_r|, adjust the text appropriately; exit to |main_loop_wrapup|@>;
2211 /* if char_tag(main_i)<>lig_tag then goto main_loop_wrapup; */
2212 if (((main_i.b2) % 4)!= 1)
2214 /* 425 in tex82.bug */
2217 /* main_k:=lig_kern_start(main_f)(main_i); */
2218 main_k = lig_kern_base[main_f]+ main_i.b3;
2219 /* main_j:=font_info[main_k].qqqq; */
2220 main_j = font_info[main_k].qqqq;
2221 /* if skip_byte(main_j)<=stop_flag then goto main_lig_loop+2; */
2222 if (main_j.b0 <= 128)goto lab112;
2223 /* main_k:=lig_kern_restart(main_f)(main_j); */
2224 main_k = lig_kern_base[main_f]+ 256 * main_j.b2 + main_j.b3 + 32768L - 256 *
2227 /* main_lig_loop+1:main_j:=font_info[main_k].qqqq; */
2228 lab111: main_j = font_info[main_k].qqqq;
2230 /* main_lig_loop+2:if next_char(main_j)=cur_r then l.20184 */
2232 /* provide for suppression of f-ligatures 99/Jan/5 */
2234 if (suppress_f_ligs && main_j.b1 == cur_r && main_j.b2 == 0) {
2239 /* if (main_j.b1 == cur_r)*/
2240 if (main_j.b1 == cur_r && bSuppress == 0) /* 99/Jan/5 */
2241 /* if skip_byte(main_j)<=stop_flag then l.20185 */
2242 // @<Do ligature or kern command, returning to |main_lig_loop|
2243 // or |main_loop_wrapup| or |main_loop_move|@>;
2244 if (main_j.b0 <= 128)
2246 /* begin if op_byte(main_j)>=kern_flag then l.20225 */
2247 if (main_j.b2 >= 128)
2249 /* @d wrapup(#)==if cur_l<non_char then */
2252 /* if character(tail)=qi(hyphen_char[main_f]) then if link(cur_q)>null */
2253 if (mem[tail].hh.b1 == hyphen_char[main_f])
2254 /* if (mem[cur_q].hh.v.RH > 0) */ /* 94/Mar/22 ?????????????? */
2255 if (mem[cur_q].hh.v.RH != 0) /* BUG FIX l.20107l.20186 */
2257 /* if ligature_present then pack_lig(#); */
2258 if (ligature_present)
2260 main_p = new_ligature(main_f, cur_l, mem[cur_q].hh.v.RH);
2263 mem[main_p].hh.b1 = 2;
2269 incr(mem[main_p].hh.b1);
2272 mem[cur_q].hh.v.RH = main_p;
2274 ligature_present = false;
2281 mem[tail].hh.v.RH = new_disc();
2282 tail = mem[tail].hh.v.RH;
2287 mem[tail].hh.v.RH = new_kern(font_info[kern_base[
2288 main_f]+ 256 * main_j.b2 + main_j.b3].cint);
2289 tail = mem[tail].hh.v.RH;
2293 /* begin if cur_l=non_char then lft_hit:=true; */
2296 else if (lig_stack == 0)
2299 if (interrupt != 0){
2300 pause_for_instructions();
2308 main_i = font_info[char_base[main_f]+ cur_l].qqqq;
2309 ligature_present = true;
2318 lig_stack = new_lig_item(cur_r);
2321 else if ((lig_stack >= hi_mem_min))
2324 lig_stack = new_lig_item(cur_r);
2325 mem[lig_stack + 1].hh.v.RH = main_p;
2327 else mem[lig_stack].hh.b1 = cur_r;
2334 lig_stack = new_lig_item(cur_r);
2335 mem[lig_stack].hh.v.RH = main_p;
2341 if (cur_l < 256) /* if cur_l<non_char then */
2342 /* begin if character(tail)=qi(hyphen_char[main_f]) then if link(cur_q)>null
2345 if (mem[tail].hh.b1 == hyphen_char[main_f])
2346 /* if (mem[cur_q].hh.v.RH > 0) */ /* 94/Mar/22 */
2347 if (mem[cur_q].hh.v.RH != 0) /* BUG FIX ???????????? */
2349 if (ligature_present)
2351 main_p = new_ligature(main_f, cur_l, mem[cur_q].hh.v.RH);
2354 mem[main_p].hh.b1 = 2;
2358 if (lig_stack == 0){
2359 incr(mem[main_p].hh.b1);
2361 } */ /* removed 99/Jan/6 */
2362 mem[cur_q].hh.v.RH = main_p;
2364 ligature_present = false;
2371 mem[tail].hh.v.RH = new_disc();
2372 tail = mem[tail].hh.v.RH;
2378 main_i = font_info[char_base[main_f]+ cur_l].qqqq;
2379 ligature_present = true;
2385 ligature_present = true;
2397 main_k = bchar_label[main_f];
2403 if (main_j.b0 >= 128)
2405 main_k = main_k + main_j.b0 + 1;
2410 lab95: main_p = mem[lig_stack + 1].hh.v.RH;
2411 /* if main_p>null then tail_append(main_p); l.20137 */
2412 /* if (main_p > 0) */ /* 92/Mar/22 */
2413 if (main_p != 0) /* BUG FIX */
2415 mem[tail].hh.v.RH = main_p;
2416 tail = mem[tail].hh.v.RH;
2418 temp_ptr = lig_stack;
2419 lig_stack = mem[temp_ptr].hh.v.RH;
2420 free_node(temp_ptr, 2);
2421 main_i = font_info[char_base[main_f]+ cur_l].qqqq;
2422 ligature_present = true;
2424 /* if main_p>null then goto main_loop_lookahead l.20142 */
2425 /* if (main_p > 0) */ /* 94/Mar/2 */
2426 if (main_p != 0) /* BUG FIX */
2429 else cur_r = mem[lig_stack].hh.b1;
2432 /* append_normal_space */
2433 lab120: if (eqtb[(hash_size + 794)].hh.v.RH == 0)
2436 main_p = font_glue[eqtb[(hash_size + 1834)].hh.v.RH];
2439 main_p = new_spec(0);
2440 main_k = param_base[eqtb[(hash_size + 1834)].hh.v.RH]+ 2;
2441 mem[main_p + 1].cint = font_info[main_k].cint;
2442 mem[main_p + 2].cint = font_info[main_k + 1].cint;
2443 mem[main_p + 3].cint = font_info[main_k + 2].cint;
2444 font_glue[eqtb[(hash_size + 1834)].hh.v.RH]= main_p;
2447 temp_ptr = new_glue(main_p);
2449 else temp_ptr = new_param_glue(12);
2450 mem[tail].hh.v.RH = temp_ptr;
2453 } /* end of main_control */
2454 /* give_err_help etc followed here in the old tex8.c */