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 /* following bit used to be end of tex1.c */
31 void restore_trace_(halfword p, char * s)
39 end_diagnostic(false);
52 if (save_stack[save_ptr].hh.b0 == 3)
54 p = save_stack[save_ptr].hh.v.RH;
55 if (save_stack[save_ptr].hh.b0 == 2)
63 if (save_stack[save_ptr].hh.b0 == 0)
65 l = save_stack[save_ptr].hh.b1;
68 else save_stack[save_ptr]= eqtb[(hash_size + 781)];
69 /* undefine_control_sequence */
70 if (p < (hash_size + 3163))
71 if (eqtb[p].hh.b1 == 1)
73 eq_destroy(save_stack[save_ptr]);
76 if (eqtb[(hash_size + 3200)].cint > 0)
77 restore_trace(p, "retaining");
82 eqtb[p]= save_stack[save_ptr];
85 if (eqtb[(hash_size + 3200)].cint > 0)
86 restore_trace(p, "restoring");
88 } else if (xeq_level[p]!= 1)
90 eqtb[p]= save_stack[save_ptr];
91 xeq_level[p]= l; /* l may be used without having been ... */
94 if (eqtb[(hash_size + 3200)].cint > 0)
95 restore_trace(p, "restoring");
101 if (eqtb[(hash_size + 3200)].cint > 0)
102 restore_trace(p, "retaining");
107 lab30: cur_group = save_stack[save_ptr].hh.b1;
108 cur_boundary = save_stack[save_ptr].hh.v.RH;
111 confusion("curlevel");
112 return; // abort_flag set
115 /* This is where the old tex2.c used to start */
116 void prepare_mag (void)
118 if ((mag_set > 0)&&(eqtb[(hash_size + 3180)].cint != mag_set))
120 print_err("Incompatible magnification(");
121 print_int(eqtb[(hash_size + 3180)].cint);
123 print_nl(" the previous value will be retained");
124 help2("I can handle only one magnification ratio per job.",
125 "So I've reverted to the magnification you used earlier on this run.");
127 geq_word_define((hash_size + 3180), mag_set);
129 if ((eqtb[(hash_size + 3180)].cint <= 0)||
130 (eqtb[(hash_size + 3180)].cint > 32768L))
132 print_err("Illegal magnification has been changed to 1000");
133 help1("The magnification ratio must be between 1 and 32768.");
134 int_error(eqtb[(hash_size + 3180)].cint);
135 geq_word_define((hash_size + 3180), 1000);
137 mag_set = eqtb[(hash_size + 3180)].cint;
139 void token_show_ (halfword p)
141 /* begin if p<>null then show_token_list(link(p),null,10000000); l.6289 */
143 show_token_list(mem[p].hh.v.RH, 0, 10000000L);
145 void print_meaning (void)
147 print_cmd_chr(cur_cmd, cur_chr);
150 print_char(58); /* : */
154 else if (cur_cmd == 110)
156 print_char(58); /* : */
158 token_show(cur_mark[cur_chr]);
161 void show_cur_cmd_chr (void)
165 if (mode != shown_mode)
171 print_cmd_chr(cur_cmd, cur_chr);
172 print_char(125); /* } */
173 end_diagnostic(false);
175 void show_context (void)
187 base_ptr = input_ptr;
188 input_stack[base_ptr] = cur_input;
192 cur_input = input_stack[base_ptr];
193 if ((cur_input.state_field != 0))
194 if ((cur_input.name_field > 17)||(base_ptr == 0))
196 if ((base_ptr == input_ptr)|| bottomline ||
197 (nn < eqtb[(hash_size + 3217)].cint))
199 /* begin if (base_ptr=input_ptr) or (state<>token_list) or
200 (token_type<>backed_up) or (loc<>null) then
201 {we omit backed-up token lists that have already been read} l.6761 */
202 if ((base_ptr == input_ptr)||(cur_input.state_field != 0)||(
203 cur_input.index_field != 3)||(cur_input.loc_field != 0))
206 old_setting = selector;
207 if (cur_input.state_field != 0)
209 if (cur_input.name_field <= 17)
210 if ((cur_input.name_field == 0))
211 if (base_ptr == 0)print_nl("<*>"); /* <*> */
212 else print_nl("<insert> "); /* */
214 print_nl("<read "); /* <read */
215 if (cur_input.name_field == 17)
216 print_char(42); /* * */
217 else print_int(cur_input.name_field - 1);
218 print_char(62); /* > */
222 /* print_int(line); */
223 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
224 if (c_style_flag) { /* 94/Mar/21 */
225 print_ln(); /* new line */
226 /* show current input file name - ignore if from terminal */
227 if (cur_input.name_field > 17) /* redundant ? */
228 print(cur_input.name_field);
229 print_char(40); /*(*/
230 print_int(line); /* line number */
231 print_char(41); /*)*/
232 print_char(32); /* */
233 print_char(58); /* : */
236 print_nl("l."); /* l. ? 573 ????? 98/Dec/8 check ! */
237 print_int(line); /* line number */
239 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
241 print_char(32); /* */
246 trick_count = 1000000L;
248 if (buffer[cur_input.limit_field]== eqtb[(hash_size + 3211)].cint)
249 j = cur_input.limit_field;
250 else j = cur_input.limit_field + 1;
253 register integer for_end;
254 i = cur_input.start_field;
258 if (i == cur_input.loc_field)
261 trick_count = tally + 1 + error_line - half_error_line;
262 if (trick_count < error_line)
263 trick_count = error_line;
267 while(i++ < for_end);
272 switch(cur_input.index_field)
274 print_nl("<argument> "); /* */
278 print_nl("<template> "); /* */
281 if (cur_input.loc_field == 0)
282 print_nl("<recently read> "); /* */
283 else print_nl("<to be read again> "); /* */
286 print_nl("<inserted text> "); /* */
291 print_cs(cur_input.name_field);
295 print_nl("<output> "); /* */
298 print_nl("<everypar> "); /* */
301 print_nl("<everymath> "); /* */
304 print_nl("<everydisplay> "); /* */
307 print_nl("<everyhbox> "); /* */
310 print_nl("<everyvbox> "); /* */
313 print_nl("<everyjob> "); /* */
316 print_nl("<everycr> "); /* */
319 print_nl("<mark> "); /* */
322 print_nl("<write> "); /* */
325 print_nl("?"); /* ? */
332 trick_count = 1000000L;
334 if (cur_input.index_field < 5)
335 show_token_list(cur_input.start_field, cur_input.loc_field, 100000L
337 else show_token_list(mem[cur_input.start_field].hh.v.RH,
338 cur_input.loc_field, 100000L);
340 selector = old_setting;
341 if (trick_count == 1000000L)
344 trick_count = tally + 1 + error_line - half_error_line;
345 if (trick_count < error_line)
346 trick_count = error_line;
348 if (tally < trick_count)
349 m = tally - first_count;
350 else m = trick_count - first_count;
351 if (l + first_count <= half_error_line){
357 p = l + first_count - half_error_line + 3;
361 register integer for_end;
363 for_end = first_count - 1;
365 print_char(trick_buf[q % error_line]);
366 while(q++ < for_end);
370 register integer for_end;
374 do print_char(32); /* */
375 while(q++ < for_end);
377 if (m + n <= error_line)
379 else p = first_count +(error_line - n - 3);
381 register integer for_end;
385 print_char(trick_buf[q % error_line]);
386 while(q++ < for_end);
388 if (m + n > error_line)
393 else if (nn == eqtb[(hash_size + 3217)].cint)
395 print_nl("..."); /* */
402 lab30: cur_input = input_stack[input_ptr];
404 #pragma optimize("g", off) /* 98/Dec/10 experiment */
405 void begin_token_list_ (halfword p, quarterword t)
408 if (input_ptr > max_in_stack)
410 max_in_stack = input_ptr;
411 #ifdef ALLOCATEINPUTSTACK
412 if (input_ptr == current_stack_size)
413 input_stack = realloc_input_stack (increment_stack_size);
414 if (input_ptr == current_stack_size){ /* check again after allocation */
415 overflow("input stack size", current_stack_size);
416 return; // abort_flag set
419 if (input_ptr == stack_size) { /* input stack - not dynamic */
420 overflow("input stack size", stack_size);
421 return; // abort_flag set
425 input_stack[input_ptr]= cur_input;
428 cur_input.state_field = 0;
429 cur_input.start_field = p;
430 cur_input.index_field = t;
433 incr(mem[p].hh.v.LH);
435 cur_input.limit_field = param_ptr;
438 cur_input.loc_field = mem[p].hh.v.RH;
439 if (eqtb[(hash_size + 3193)].cint > 1)
451 print_cmd_chr(72, t + (hash_size + 1307)); /* H */
456 end_diagnostic(false);
460 else cur_input.loc_field = p;
462 #pragma optimize("", on) /* 98/Dec/10 experiment */
463 void end_token_list (void)
465 if (cur_input.index_field >= 3)
467 if (cur_input.index_field <= 4)
468 flush_list(cur_input.start_field);
470 delete_token_ref(cur_input.start_field);
471 if (cur_input.index_field == 5)
472 while(param_ptr > cur_input.limit_field){
474 flush_list(param_stack[param_ptr]);
478 else if (cur_input.index_field == 1)
479 if (align_state > 500000L)align_state = 0;
481 fatal_error("(interwoven alignment preambles are not allowed)"); /* */
482 return; // abort_flag set
486 cur_input = input_stack[input_ptr];
490 pause_for_instructions();
494 void back_input (void)
497 while((cur_input.state_field == 0)&&(cur_input.loc_field == 0)) {
501 mem[p].hh.v.LH = cur_tok;
505 else incr(align_state);
507 if (input_ptr > max_in_stack)
509 max_in_stack = input_ptr;
510 #ifdef ALLOCATEINPUTSTACK
511 if (input_ptr == current_stack_size)
512 input_stack = realloc_input_stack (increment_stack_size);
513 if (input_ptr == current_stack_size){ /* check again after allocation */
514 overflow("input stack size", current_stack_size);
515 return; // abort_flag set
518 if (input_ptr == stack_size) { /* stack size - not dynamic */
519 overflow("input stack size", stack_size);
520 return; // abort_flag set
524 input_stack[input_ptr]= cur_input;
527 cur_input.state_field = 0;
528 cur_input.start_field = p;
529 cur_input.index_field = 3;
530 cur_input.loc_field = p;
532 void back_error (void)
534 OK_to_interrupt = false;
536 OK_to_interrupt = true;
539 void ins_error (void)
541 OK_to_interrupt = false;
543 cur_input.index_field = 4;
544 OK_to_interrupt = true;
547 void begin_file_reading (void)
549 if (in_open == max_in_open){
550 overflow("text input levels", max_in_open); /* text input levels - NOT DYNAMIC */
551 return; // abort_flag set
553 #ifdef ALLOCATEBUFFER
554 if (first == current_buf_size)
555 buffer = realloc_buffer (increment_buf_size);
556 if (first == current_buf_size) { /* check again after allocation */
557 overflow("buffer size", current_buf_size);
558 return; // abort_flag set
561 if (first == buf_size){
562 overflow("buffer size", buf_size); /* buffer size - not dynamic */
563 return; // abort_flag set
568 if (in_open > high_in_open) /* 1999 Jan 17 */
569 high_in_open = in_open;
571 if (input_ptr > max_in_stack)
573 max_in_stack = input_ptr;
574 #ifdef ALLOCATEINPUTSTACK
575 if (input_ptr == current_stack_size)
576 input_stack = realloc_input_stack (increment_stack_size);
577 if (input_ptr == current_stack_size){
578 overflow("input stack size", current_stack_size); /* check again after allocation */
579 return; // abort_flag set
582 if (input_ptr == stack_size){
583 overflow("input stack size", stack_size); /* input stack - not dynamic */
584 return; // abort_flag set
588 input_stack[input_ptr]= cur_input;
591 cur_input.index_field = in_open;
592 line_stack[cur_input.index_field]= line;
593 cur_input.start_field = first;
594 cur_input.state_field = 1;
595 cur_input.name_field = 0;
597 void end_file_reading (void)
599 first = cur_input.start_field;
600 line = line_stack[cur_input.index_field];
601 if (cur_input.name_field > 17)
602 (void) a_close(input_file[cur_input.index_field]);
605 cur_input = input_stack[input_ptr];
609 /* called only form tex0.c */
610 void clear_for_error_prompt (void)
612 while((cur_input.state_field != 0)&&
613 (cur_input.name_field == 0)&&
615 (cur_input.loc_field > cur_input.limit_field))
619 void check_outer_validity (void)
623 if (scanner_status != 0)
625 deletions_allowed = false;
628 if ((cur_input.state_field == 0)||(cur_input.name_field < 1)||
629 (cur_input.name_field > 17))
631 /* begin p:=get_avail; info(p):=cs_token_flag+cur_cs; */
633 mem[p].hh.v.LH = 4095 + cur_cs;
634 begin_token_list(p, 3);
639 if (scanner_status > 1)
643 print_err("File ended");
646 print_err("Forbidden control sequence found");
648 print_string(" while scanning ");
650 switch(scanner_status)
653 print_string("definition");
654 mem[p].hh.v.LH = 637;
660 mem[p].hh.v.LH = par_token;
666 print_string("preamble");
667 mem[p].hh.v.LH = 637;
671 /* mem[p].hh.v.LH = (hash_size + 4610); */
672 /* mem[p].hh.v.LH = (hash_size + 4095 + 515); */
673 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 515); /*96/Jan/10*/
674 align_state = -1000000L;
679 print_string("text");
680 mem[p].hh.v.LH = 637;
684 begin_token_list(p, 4);
685 print_string(" of ");
686 sprint_cs(warning_index);
687 help4("I suspect you have forgotten a `}', causing me",
688 "to read past where you wanted me to stop.",
689 "I'll try to recover; but if the error is serious,",
690 "you'd better type `E' or `X' now and fix your file.");
694 print_err("Incomplete ");
695 print_cmd_chr(105, cur_if); /* i */
696 print_string("; all text was ignored after line ");
697 print_int(skip_line);
698 help3("A forbidden control sequence occurred in skipped text.",
699 "This kind of error happens when you say `\\if...' and forget",
700 "the matching `\\fi'. I've inserted a `\\fi'; this might work.");
703 else help_line[2]= "The file ended while I was skipping conditional text.";
704 /* cur_tok = (hash_size + 4613); */
705 /* cur_tok = (hash_size + 4095 + 518); */
706 cur_tok = (hash_size + hash_extra + 4095 + 518); /* 96/Jan/10 */
709 deletions_allowed = true;
712 /*****************************************************************************/
713 /* get_next() moved from here to end for pragma optimize reasons 96/Sep/12 */
715 /*****************************************************************************/
716 void firm_up_the_line (void)
719 cur_input.limit_field = last;
720 if (eqtb[(hash_size + 3191)].cint > 0)
721 if (interaction > 1) {
724 if (cur_input.start_field < cur_input.limit_field) {
725 register integer for_end;
726 k = cur_input.start_field;
727 for_end = cur_input.limit_field - 1;
728 if (k <= for_end) do print(buffer[k]);
729 while(k++ < for_end);
731 first = cur_input.limit_field;
739 register integer for_end;
743 buffer[k + cur_input.start_field - first]= buffer[k];
744 while(k++ < for_end);
746 cur_input.limit_field = cur_input.start_field + last - first;
750 void get_token (void)
752 no_new_control_sequence = false;
754 no_new_control_sequence = true;
755 if (cur_cs == 0)cur_tok =(cur_cmd * 256)+ cur_chr;
756 else cur_tok = 4095 + cur_cs;
758 void macro_call (void)
759 {/* 10 22 30 31 40 */
771 small_number savescannerstatus;
772 halfword savewarningindex;
775 savescannerstatus = scanner_status;
776 savewarningindex = warning_index;
777 warning_index = cur_cs;
779 r = mem[refcount].hh.v.RH;
781 if (eqtb[(hash_size + 3193)].cint > 0)
785 print_cs(warning_index);
786 token_show(refcount);
787 end_diagnostic(false);
789 if (mem[r].hh.v.LH != 3584)
793 long_state = eqtb[cur_cs].hh.b0;
794 if (long_state >= 113)
795 long_state = long_state - 2;
797 mem[temp_head].hh.v.RH = 0; /* repeat link(temp_head):=null; */
798 if ((mem[r].hh.v.LH > 3583)||(mem[r].hh.v.LH < 3328))
799 s = 0; /* s:=null l.7984 */
801 matchchr = mem[r].hh.v.LH - 3328;
808 if (cur_tok == mem[r].hh.v.LH)
811 if ((mem[r].hh.v.LH >= 3328)&&(mem[r].hh.v.LH <= 3584
823 print_err("Use of ");
824 sprint_cs(warning_index);
825 print_string(" doesn't match its definition");
826 help4("If you say, e.g., `\\def\\a1{...}', then you must always",
827 "put `1' after `\\a', since control sequence names are",
828 "made up of letters only. The macro here has not been",
829 "followed by the required stuff, so I'm ignoring it.");
839 mem[q].hh.v.LH = mem[t].hh.v.LH;
847 if (cur_tok != mem[v].hh.v.LH)
854 if (mem[u].hh.v.LH != mem[v].hh.v.LH)
859 lab30: t = mem[t].hh.v.RH;
863 if (cur_tok == par_token)
864 if (long_state != 112)
866 if (long_state == 111)
869 print_err("Paragraph ended before ");
870 sprint_cs(warning_index);
871 print_string("was complete");
872 help3("I suspect you've forgotten a `}', causing me to apply this",
873 "control sequence to too much text. How can we recover?",
874 "My plan is to forget the whole thing and hope for the best.");
877 pstack[n]= mem[temp_head].hh.v.RH;
878 align_state = align_state - unbalance;
880 register integer for_end;
884 flush_list(pstack[m]);
885 while(m++ < for_end);
901 avail = mem[q].hh.v.RH;
910 mem[q].hh.v.LH = cur_tok;
914 if (cur_tok == par_token)
915 if (long_state != 112)
917 if (long_state == 111)
920 print_err("Paragraph ended before ");
921 sprint_cs(warning_index);
922 print_string(" was complete");
923 help3("I suspect you've forgotten a `}', causing me to apply this",
924 "control sequence to too much text. How can we recover?",
925 "My plan is to forget the whole thing and hope for the best.");
928 pstack[n]= mem[temp_head].hh.v.RH;
929 align_state = align_state - unbalance;
931 register integer for_end;
935 flush_list(pstack[m]);
936 while(m++ < for_end);
950 lab31: rbraceptr = p;
954 mem[q].hh.v.LH = cur_tok;
960 print_err("Argument of ");
961 sprint_cs(warning_index);
962 print_string(" has an extra }");
963 help6("I've run across a `}' that doesn't seem to match anything.",
964 "For example, `\\def\\a#1{...}' and `\\a}' would produce",
965 "this error. If you simply proceed now, the `\\par' that",
966 "I've just inserted will cause me to report a runaway",
967 "argument that might be the root of the problem. But if",
968 "your `}' was spurious, just type `2' and it will go away.");
972 /* 420 in tex82.bug */
978 if (mem[r].hh.v.LH <= 3584)
979 if (mem[r].hh.v.LH >= 3328)
983 mem[p].hh.v.RH = q; /* p may be used without having ... */
984 mem[q].hh.v.LH = cur_tok;
988 incr(m); /* m may be used without having been ... */
989 if (mem[r].hh.v.LH > 3584)
991 if (mem[r].hh.v.LH < 3328)
995 if ((m == 1)&&(mem[p].hh.v.LH < 768)&&(p != temp_head
998 mem[rbraceptr].hh.v.RH = 0; /* rbraceptr may be used without ... */
1000 mem[p].hh.v.RH = avail;
1007 p = mem[temp_head].hh.v.RH;
1008 pstack[n]= mem[p].hh.v.RH;
1010 mem[p].hh.v.RH = avail;
1018 else pstack[n]= mem[temp_head].hh.v.RH;
1020 if (eqtb[(hash_size + 3193)].cint > 0)
1023 print_nl(matchchr); /* matchchar may be used without ... */
1026 show_token_list(pstack[n - 1], 0, 1000);
1027 end_diagnostic(false);
1030 } while(!(mem[r].hh.v.LH == 3584));
1032 /* while (state=token_list)and(loc=null) do end_token_list; l.7956 */
1033 while((cur_input.state_field == 0)&&(cur_input.loc_field == 0))
1035 begin_token_list(refcount, 5);
1036 cur_input.name_field = warning_index;
1037 cur_input.loc_field = mem[r].hh.v.RH;
1040 if (param_ptr + n > max_param_stack)
1042 max_param_stack = param_ptr + n;
1043 #ifdef ALLOCATEPARAMSTACK
1044 if (max_param_stack > current_param_size)
1045 param_stack = realloc_param_stack (increment_param_size);
1046 if (max_param_stack > current_param_size){ /* check again after allocation */
1047 overflow("parameter stack size", current_param_size);
1048 return; // abort_flag set
1051 if (max_param_stack > param_size){
1052 overflow("parameter stack size", param_size); /* parameter stack - not dynamic */
1053 return; // abort_flag set
1058 register integer for_end;
1062 do param_stack[param_ptr + m]= pstack[m];
1063 while(m++ < for_end);
1065 param_ptr = param_ptr + n;
1067 lab10: scanner_status = savescannerstatus;
1068 warning_index = savewarningindex;
1070 void insert_relax (void)
1072 /* begin cur_tok:=cs_token_flag+cur_cs; back_input; */
1073 cur_tok = 4095 + cur_cs;
1075 /* cur_tok:=cs_token_flag+frozen_relax; back_input; token_type:=inserted; */
1076 /* cur_tok = (hash_size + 4616); */
1077 /* cur_tok = (hash_size + 4095 + 521); */
1078 cur_tok = (hash_size + hash_extra + 4095 + 521); /* 96/Jan/10 */
1080 cur_input.index_field = 4;
1088 small_number cvlbackup, radixbackup, cobackup;
1089 halfword backupbackup;
1090 small_number savescannerstatus;
1093 cvlbackup = cur_val_level;
1094 radixbackup = radix;
1095 cobackup = cur_order;
1096 backupbackup = mem[mem_top - 13].hh.v.RH;
1099 if (eqtb[(hash_size + 3199)].cint > 1)
1104 /* begin if cur_mark[cur_chr]<>null then l.7881 */
1105 if (cur_mark[cur_chr]!= 0)
1106 begin_token_list(cur_mark[cur_chr], 14);
1124 savescannerstatus = scanner_status;
1127 scanner_status = savescannerstatus;
1130 if (t >= 4095) /* if t>=cs_token_flag then */
1132 /* begin p:=get_avail; info(p):=cs_token_flag+frozen_dont_expand; */
1134 /* mem[p].hh.v.LH = (hash_size + 4618); */
1135 /* mem[p].hh.v.LH = (hash_size + 4095 + 523); */
1136 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 523); /*96/Jan/10*/
1137 mem[p].hh.v.RH = cur_input.loc_field;
1138 cur_input.start_field = p;
1139 cur_input.loc_field = p;
1152 mem[q].hh.v.LH = cur_tok;
1155 } while(!(cur_cs != 0));
1158 print_err("Missing ");
1159 print_esc("endcsname");
1160 print_string(" inserted");
1161 help2("The control sequence marked <to be read again> should",
1162 "not appear between \\csname and \\endcsname.");
1167 while(p != 0){ /* while p<>null do l.7742 */
1169 if (j >= max_buf_stack)
1171 max_buf_stack = j + 1;
1172 #ifdef ALLOCATEBUFFER
1173 if (max_buf_stack == current_buf_size)
1174 buffer = realloc_buffer (increment_buf_size);
1175 if (max_buf_stack == current_buf_size){ /* check again after allocation */
1176 overflow("buffer size", current_buf_size);
1177 return; // abort_flag set
1180 if (max_buf_stack == buf_size){
1181 overflow("buffer size", buf_size); /* buffer size - not dynamic */
1182 return; // abort_flag set
1186 buffer[j]= mem[p].hh.v.LH % 256;
1187 /* buffer[j]= mem[p].hh.v.LH & 255; */ /* last 8 bits */
1193 no_new_control_sequence = false;
1194 cur_cs = id_lookup(first, j - first);
1195 no_new_control_sequence = true;
1197 else if (j == first)
1199 /* else cur_cs:=single_base+buffer[first] {the list has length one} */
1200 else cur_cs = 257 + buffer[first];
1202 if (eqtb[cur_cs].hh.b0 == 101)
1204 eq_define(cur_cs, 0, 256);
1206 cur_tok = cur_cs + 4095;
1220 if (cur_chr > if_limit)
1224 print_err("Extra ");
1225 print_cmd_chr(106, cur_chr); /* j */
1226 help1("I'm ignoring this; it doesn't match any \\if.");
1231 while(cur_chr != 2)pass_text();
1234 if_line = mem[p + 1].cint;
1235 cur_if = mem[p].hh.b1;
1236 if_limit = mem[p].hh.b0;
1237 cond_ptr = mem[p].hh.v.RH;
1243 if (cur_chr > 0)force_eof = true;
1244 else if (name_in_progress)insert_relax();
1249 print_err("Undefined control sequence");
1250 help5("The control sequence at the end of the top line",
1251 "of your error message was never \\def'ed. If you have",
1252 "misspelled it (e.g., `\\hobx'), type `I' and the correct",
1253 "spelling (e.g., `I\\hbox'). Otherwise just continue,",
1254 "and I'll forget about whatever was undefined.");
1260 else if (cur_cmd < 115){
1265 /* cur_tok = (hash_size + 4615); */
1266 /* cur_tok = (hash_size + 4095 + 520); */
1267 cur_tok = (hash_size + hash_extra + 4095 + 520); /* 96/Jan/10 */
1271 cur_val_level = cvlbackup;
1272 radix = radixbackup;
1273 cur_order = cobackup;
1274 mem[mem_top - 13].hh.v.RH = backupbackup;
1276 void get_x_token (void)
1281 if (cur_cmd <= 100) goto lab30;
1287 /* cur_cs = (hash_size + 520); */
1288 cur_cs = (hash_size + hash_extra + 520); /* 96/Jan/10 */
1296 lab30: if (cur_cs == 0)
1297 cur_tok =(cur_cmd * 256)+ cur_chr;
1298 else cur_tok = 4095 + cur_cs;
1302 while(cur_cmd > 100){
1307 cur_tok =(cur_cmd * 256)+ cur_chr;
1308 else cur_tok = 4095 + cur_cs;
1310 void scan_left_brace (void)
1314 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
1317 print_err("Missing { inserted");
1318 help4("A left brace was mandatory here, so I've put one in.",
1319 "You might want to delete and/or insert some corrections",
1320 "so that I will find a matching right brace soon.",
1321 "(If you're confused by all this, try typing `I}' now.)");
1329 void scan_optional_equals (void)
1333 } while(!(cur_cmd != 10));
1334 if (cur_tok != 3133)back_input();
1336 bool scan_keyword_(char * s)
1337 {/* 10 */ register bool Result;
1346 if ((cur_cs == 0) && ((cur_chr == (*k))||(cur_chr == (*k)- 32))) {
1350 mem[q].hh.v.LH = cur_tok;
1355 else if ((cur_cmd != 10)||(p != mem_top - 13))
1358 if (p != mem_top - 13)
1359 begin_token_list(mem[mem_top - 13].hh.v.RH, 3);
1364 flush_list(mem[mem_top - 13].hh.v.RH);
1368 void mu_error (void)
1370 print_err("Incompatible glue units");
1371 help1("I'm going to assume that 1mu=1pt when they're mixed.");
1374 void scan_eight_bit_int (void)
1377 if ((cur_val < 0)||(cur_val > 255))
1379 print_err("Bad register code");
1380 help2("A register number must be between 0 and 255.",
1381 "I changed this one to zero.");
1386 void scan_char_num (void)
1389 if ((cur_val < 0)||(cur_val > 255))
1391 print_err("Bad character code");
1392 help2("A character number must be between 0 and 255.",
1393 "I changed this one to zero.");
1398 void scan_four_bit_int (void)
1401 if ((cur_val < 0)||(cur_val > 15))
1403 print_err("Bad number");
1404 help2("Since I expected to read a number between 0 and 15,",
1405 "I changed this one to zero.");
1410 void scan_fifteen_bit_int (void)
1413 if ((cur_val < 0)||(cur_val > 32767))
1415 print_err("Bad mathchar");
1416 help2("A mathchar number must be between 0 and 32767.",
1417 "I changed this one to zero.");
1422 void scan_twenty_seven_bit_int (void)
1425 if ((cur_val < 0)||(cur_val > 134217727L)) /* 2^27 - 1 */
1427 print_err("Bad delimiter code");
1428 help2("A numeric delimiter code must be between 0 and 2^{27}-1.",
1429 "I changed this one to zero.");
1434 void scan_font_ident (void)
1436 internal_font_number f;
1440 } while(!(cur_cmd != 10));
1442 f = eqtb[(hash_size + 1834)].hh.v.RH;
1443 else if (cur_cmd == 87)
1445 else if (cur_cmd == 86)
1448 scan_four_bit_int();
1449 f = eqtb[m + cur_val].hh.v.RH;
1452 print_err("Missing font identifier");
1453 help2("I was looking for a control sequence whose",
1454 "current meaning has been defined by \\font.");
1460 void find_font_dimen_(bool writing)
1462 internal_font_number f;
1468 /* if (n <= 0)*/ /* change 98/Oct/5 */
1469 if (n < 0 || (n == 0 && font_dimen_zero == 0))
1472 /* else begin if writing and(n<=space_shrink_code)and@|
1473 (n>=space_code)and(font_glue[f]<>null) then
1474 begin delete_glue_ref(font_glue[f]); l.11225 */
1475 if (writing &&(n <= 4)&&(n >= 2)&&(font_glue[f]!= 0))
1477 delete_glue_ref(font_glue[f]);
1478 font_glue[f]= 0; /* font_glue[f]:=null */
1480 if (n > font_params[f])
1485 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1487 if (fmem_ptr == current_font_mem_size) { /* 93/Nov/28 ??? */
1488 font_info = realloc_font_info(increment_font_mem_size);
1490 if (fmem_ptr == current_font_mem_size){ /* 94/Jan/24 */
1491 overflow("font memory", current_font_mem_size); /* font memory */
1492 return; // abort_flag set
1495 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1496 if (fmem_ptr == font_mem_size){
1497 overflow("font memory", font_mem_size); /* font memory */
1498 return; // abort_flag set
1501 font_info[fmem_ptr].cint = 0;
1503 incr(font_params[f]);
1504 } while(!(n == font_params[f]));
1505 cur_val = fmem_ptr - 1;
1507 /* else cur_val = n + param_base[f]; */ /* 98/Oct/5 */
1508 else if (n > 0) cur_val = n + param_base[f]; /* 98/Oct/5 */
1509 else cur_val = &font_check[f] - &font_info[0]; /* 98/Oct/5 */
1510 /* checksum = (((font_check[f].b0) << 8 | font_check[f].b1) << 8 |
1511 font_check[f].b2) << 8 | font_check[f].b3; */
1513 /* compiler error: '-' : incompatible types - from 'union fmemoryword *' to 'struct fourunsignedchars *' */
1514 if (cur_val == fmem_ptr){
1516 /* print_esc(hash[(hash_size + 524) + f].v.RH); */
1517 //print_esc(hash[(hash_size + hash_extra + 524) + f].v.RH); /*96/Jan/10*/
1518 print_esc("");print(hash[(hash_size + hash_extra + 524) + f].v.RH);
1519 print_string(" has only ");
1520 print_int(font_params[f]);
1521 print_string(" fontdimen parameters");
1522 help2("To increase the number of font parameters, you must",
1523 "use \\fontdimen immediately after the \\font is loaded.");
1528 /* NOTE: the above use of /fontdimen0 to access the checksum is a kludge */
1529 /* In future would be better to do this by allocating one more slot for */
1530 /* for parameters when a font is read rather than carry checksum separately */
1531 /* The above gets the value byte order reversed ... 98/Oct/5 */
1533 void scan_something_internal_(small_number level, bool negative)
1542 if (m == (hash_size + 2907))
1544 cur_val = eqtb[(hash_size + 2907) + cur_val].hh.v.RH;
1547 else if (m < (hash_size + 2907))
1549 cur_val = eqtb[m + cur_val].hh.v.RH;
1554 cur_val = eqtb[m + cur_val].cint;
1566 print_err("Missing number, treated as zero");
1567 help3("A number should have been here; I inserted `0'.",
1568 "(If you can't figure out why I needed to see a number,",
1569 "look up `weird error' in the index to The TeXbook.)");
1576 else if (cur_cmd <= 72)
1580 scan_eight_bit_int();
1581 m = (hash_size + 1322) + cur_val;
1584 cur_val = eqtb[m].hh.v.RH;
1593 /* cur_val = (hash_size + 524) + cur_val; */
1594 cur_val = (hash_size + hash_extra + 524) + cur_val; /* 96/Jan/10 */
1601 cur_val = eqtb[m].cint;
1607 cur_val = eqtb[m].cint;
1613 cur_val = eqtb[m].hh.v.RH;
1619 cur_val = eqtb[m].hh.v.RH;
1626 print_err("Improper ");
1627 print_cmd_chr(79, m); /* O */
1628 help4("You can refer to \\spacefactor only in horizontal mode;",
1629 "you can refer to \\prevdepth only in vertical mode; and",
1630 "neither of these is meaningful inside \\write. So",
1631 "I'm forgetting what you said and using zero instead.");
1645 cur_val = cur_list.aux_field.cint;
1650 cur_val = space_factor;
1662 nest[nest_ptr]= cur_list;
1664 while(abs(nest[p].mode_field)!= 1)decr(p);
1666 cur_val = nest[p].pg_field;
1674 cur_val = dead_cycles;
1675 else cur_val = insert_penalties;
1681 if ((page_contents == 0)&&(! output_active))
1683 cur_val = 1073741823L; /* 2^30 - 1 */
1685 else cur_val = page_so_far[m];
1691 if (eqtb[(hash_size + 1312)].hh.v.RH == 0)
1693 else cur_val = mem[eqtb[(hash_size + 1312)].hh.v.RH].hh.v.LH;
1699 scan_eight_bit_int();
1700 if (eqtb[(hash_size + 1578) + cur_val].hh.v.RH == 0)
1702 else cur_val = mem[eqtb[(hash_size + 1578) + cur_val].hh.v.RH + m].cint;
1715 find_font_dimen(false);
1716 font_info[fmem_ptr].cint = 0;
1718 cur_val = font_info[cur_val].cint;
1727 cur_val = hyphen_char[cur_val];
1732 cur_val = skew_char[cur_val];
1739 scan_eight_bit_int();
1742 cur_val = eqtb[(hash_size + 3218) + cur_val].cint;
1745 cur_val = eqtb[(hash_size + 3751) + cur_val].cint;
1748 cur_val = eqtb[(hash_size + 800) + cur_val].hh.v.RH;
1751 cur_val = eqtb[(hash_size + 1056) + cur_val].hh.v.RH;
1762 else cur_val = last_badness;
1770 cur_val_level = cur_chr;
1771 if (!(tail >= hi_mem_min)&&(mode != 0)
1775 if (mem[tail].hh.b0 == 12)
1776 cur_val = mem[tail + 1].cint;
1779 if (mem[tail].hh.b0 == 11)
1780 cur_val = mem[tail + 1].cint;
1783 if (mem[tail].hh.b0 == 10)
1785 cur_val = mem[tail + 1].hh.v.LH;
1786 if (mem[tail].hh.b1 == 99)
1791 else if ((mode == 1)&&(tail == cur_list
1795 cur_val = last_penalty;
1798 cur_val = last_kern;
1801 /* if (last_glue != 262143L) */ /* NO! */
1802 if (last_glue != empty_flag)
1803 cur_val = last_glue;
1810 print_err("You can't use `");
1811 print_cmd_chr(cur_cmd, cur_chr);
1812 print_string("' after ");
1814 help1("I'm forgetting what you said and using zero instead.");
1827 while(cur_val_level > level){
1829 if (cur_val_level == 2)
1830 cur_val = mem[cur_val + 1].cint;
1831 else if (cur_val_level == 3){
1834 decr(cur_val_level);
1837 if (cur_val_level >= 2)
1839 cur_val = new_spec(cur_val);
1841 mem[cur_val + 1].cint = - (integer) mem[cur_val + 1].cint;
1842 mem[cur_val + 2].cint = - (integer) mem[cur_val + 2].cint;
1843 mem[cur_val + 3].cint = - (integer) mem[cur_val + 3].cint;
1846 else cur_val = - (integer) cur_val;
1847 else if ((cur_val_level >= 2)&&(cur_val_level <= 3))
1848 incr(mem[cur_val].hh.v.RH);
1851 /*****************************************************************************/
1853 /* Moved here to avoid question about pragma optimize 96/Sep/12 */
1855 /* #pragma optimize ("a", off) */
1857 void get_next (void)
1858 {/* 20 25 21 26 40 10 */
1861 /* char cat; */ /* make this an int ? */
1862 int cat; /* make this an int ? 95/Jan/7 */
1868 if (cur_input.state_field != 0) {
1869 lab25: if (cur_input.loc_field <= cur_input.limit_field) {
1870 cur_chr = buffer[cur_input.loc_field];
1871 incr(cur_input.loc_field);
1872 lab21: cur_cmd = eqtb[(hash_size + 1883) + cur_chr].hh.v.RH;
1873 switch(cur_input.state_field + cur_cmd)
1885 if (cur_input.loc_field > cur_input.limit_field)
1889 lab26: k = cur_input.loc_field;
1890 cur_chr = buffer[k];
1891 cat = eqtb[(hash_size + 1883) + cur_chr].hh.v.RH;
1894 cur_input.state_field = 17;
1896 cur_input.state_field = 17;
1897 else cur_input.state_field = 1;
1898 if ((cat == 11)&&(k <= cur_input.limit_field))
1901 cur_chr = buffer[k];
1902 cat = eqtb[(hash_size + 1883) + cur_chr].hh.v.RH;
1904 } while(!((cat != 11)||(k > cur_input.limit_field)))
1907 if (buffer[k]== cur_chr)
1909 if (k < cur_input.limit_field)
1915 if ((((c >= 48)&&(c <= 57)) ||((c >= 97)&&
1917 if (k + 2 <= cur_input.limit_field)
1920 if ((((cc >= 48)&&(cc <= 57)) ||((cc >= 97
1928 else cur_chr = c - 87;
1930 cur_chr = 16 * cur_chr + cc - 48;
1931 else cur_chr = 16 * cur_chr + cc - 87;
1932 buffer[k - 1]= cur_chr;
1935 buffer[k - 1]= c + 64;
1936 else buffer[k - 1]= c - 64;
1937 cur_input.limit_field = cur_input.limit_field - d;
1939 while(k <= cur_input.limit_field){
1941 buffer[k]= buffer[k + d];
1950 if (k > cur_input.loc_field + 1)
1952 cur_cs = id_lookup(cur_input.loc_field, k - cur_input.loc_field
1954 cur_input.loc_field = k;
1960 if (buffer[k]== cur_chr)
1962 if (k < cur_input.limit_field)
1965 if (c < 128) /* ? */
1968 if ((((c >= 48)&&(c <= 57)) ||((c >= 97)&&(
1970 if (k + 2 <= cur_input.limit_field)
1973 if ((((cc >= 48)&&(cc <= 57)) ||((cc >= 97)
1981 else cur_chr = c - 87;
1982 if (cc <= 57) /* cc may be used without ... */
1983 cur_chr = 16 * cur_chr + cc - 48;
1984 else cur_chr = 16 * cur_chr + cc - 87;
1985 buffer[k - 1]= cur_chr;
1988 buffer[k - 1]= c + 64;
1989 else buffer[k - 1]= c - 64;
1990 cur_input.limit_field = cur_input.limit_field - d;
1992 while(k <= cur_input.limit_field){
1993 buffer[k]= buffer[k + d];
2000 /* cur_cs:=single_base+buffer[loc]; incr(loc); */
2001 cur_cs = 257 + buffer[cur_input.loc_field];
2002 incr(cur_input.loc_field);
2004 lab40: cur_cmd = eqtb[cur_cs].hh.b0;
2005 cur_chr = eqtb[cur_cs].hh.v.RH;
2006 if (cur_cmd >= 113){
2007 check_outer_validity();
2015 cur_cs = cur_chr + 1;
2016 cur_cmd = eqtb[cur_cs].hh.b0;
2017 cur_chr = eqtb[cur_cs].hh.v.RH;
2018 cur_input.state_field = 1;
2019 if (cur_cmd >= 113){
2020 check_outer_validity();
2028 if (cur_chr == buffer[cur_input.loc_field])
2029 if (cur_input.loc_field < cur_input.limit_field)
2031 c = buffer[cur_input.loc_field + 1];
2034 cur_input.loc_field = cur_input.loc_field + 2;
2035 if ((((c >= 48)&&(c <= 57)) ||((c >= 97)&&(c <=
2037 if (cur_input.loc_field <= cur_input.limit_field)
2039 cc = buffer[cur_input.loc_field];
2040 if ((((cc >= 48)&&(cc <= 57)) ||((cc >= 97)&&(
2043 incr(cur_input.loc_field);
2046 else cur_chr = c - 87;
2048 cur_chr = 16 * cur_chr + cc - 48;
2049 else cur_chr = 16 * cur_chr + cc - 87;
2055 else cur_chr = c - 64;
2059 cur_input.state_field = 1;
2066 print_err("Text line contains an invalid character");
2067 help2("A funny symbol that I can't read has just been input.",
2068 "Continue, and I'll forget that it ever happened.");
2069 deletions_allowed = false;
2071 deletions_allowed = true;
2077 cur_input.state_field = 17;
2083 cur_input.loc_field = cur_input.limit_field + 1;
2093 cur_input.loc_field = cur_input.limit_field + 1;
2099 cur_input.loc_field = cur_input.limit_field + 1;
2101 cur_cmd = eqtb[cur_cs].hh.b0;
2102 cur_chr = eqtb[cur_cs].hh.v.RH;
2103 if (cur_cmd >= 113){
2104 check_outer_validity();
2114 cur_input.state_field = 1;
2124 cur_input.state_field = 1;
2140 cur_input.state_field = 1;
2148 cur_input.state_field = 33;
2149 if (cur_input.name_field > 17) {
2151 first = cur_input.start_field;
2153 if (input_ln(input_file[cur_input.index_field], true)) {
2156 else force_eof = true;
2159 print_char(41); /*)*/
2166 check_outer_validity();
2169 if ((eqtb[(hash_size + 3211)].cint < 0)||
2170 (eqtb[(hash_size + 3211)].cint > 255))
2171 decr(cur_input.limit_field);
2172 /* long to unsigned char ... */
2173 else buffer[cur_input.limit_field]= eqtb[(hash_size + 3211)].cint;
2174 first = cur_input.limit_field + 1;
2175 cur_input.loc_field = cur_input.start_field;
2178 if (!(cur_input.name_field == 0)) {
2187 if (selector < 18) open_log_file();
2188 if (interaction > 1){
2189 if ((eqtb[(hash_size + 3211)].cint < 0)||
2190 (eqtb[(hash_size + 3211)].cint > 255)
2192 incr(cur_input.limit_field);
2193 if (cur_input.limit_field == cur_input.start_field)
2194 print_nl("(Please type a command or say `\\end')"); /* */
2196 first = cur_input.start_field;
2199 print_string("*"); /* * */
2202 cur_input.limit_field = last;
2203 if ((eqtb[(hash_size + 3211)].cint < 0)||
2204 (eqtb[(hash_size + 3211)].cint > 255)
2206 decr(cur_input.limit_field);
2207 /* long to unsigned char ... */
2208 else buffer[cur_input.limit_field]= eqtb[(hash_size + 3211)].cint;
2209 first = cur_input.limit_field + 1;
2210 cur_input.loc_field = cur_input.start_field;
2213 fatal_error("*** (job aborted, no legal \\end found)"); /* */
2214 return; // abort_flag set
2218 if (interrupt != 0){
2219 pause_for_instructions();
2225 else if (cur_input.loc_field != 0)
2227 t = mem[cur_input.loc_field].hh.v.LH;
2228 cur_input.loc_field = mem[cur_input.loc_field].hh.v.RH;
2232 cur_cmd = eqtb[cur_cs].hh.b0;
2233 cur_chr = eqtb[cur_cs].hh.v.RH;
2237 cur_cs = mem[cur_input.loc_field].hh.v.LH - 4095;
2238 cur_input.loc_field = 0;
2239 cur_cmd = eqtb[cur_cs].hh.b0;
2240 cur_chr = eqtb[cur_cs].hh.v.RH;
2248 check_outer_validity();
2254 /* cur_cmd = t >> 8; */ /* top 8 bits */
2256 /* cur_chr = t & 255; */ /* last 8 bits */
2266 begin_token_list(param_stack[cur_input.limit_field + cur_chr - 1],
2283 if (align_state == 0)
2285 if (scanner_status == 4){
2286 fatal_error("(interwoven alignment preambles are not allowed)"); /* */
2287 return; // abort_flag set
2290 cur_cmd = mem[cur_align + 5].hh.v.LH;
2291 mem[cur_align + 5].hh.v.LH = cur_chr;
2293 begin_token_list(omit_template, 2);
2294 else begin_token_list(mem[cur_align + 2].cint, 2);
2295 align_state = 1000000L;
2300 #pragma optimize ("", on) /* 96/Sep/12 */
2302 /*****************************************************************************/