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, str_number s)
34 print_char(123); /* { */
38 print_char(125); /* } */
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)
64 if(save_stack[save_ptr].hh.b0 == 0)
66 l = save_stack[save_ptr].hh.b1;
69 else save_stack[save_ptr]= eqtb[(hash_size + 781)];
70 /* undefine_control_sequence */
71 if(p < (hash_size + 3163))
72 if(eqtb[p].hh.b1 == 1)
74 eq_destroy(save_stack[save_ptr]);
77 if(eqtb[(hash_size + 3200)].cint > 0)
78 restore_trace(p, 541); /* retaining */
84 eqtb[p]= save_stack[save_ptr];
87 if(eqtb[(hash_size + 3200)].cint > 0)
88 restore_trace(p, 542); /* restoring */
91 else if(xeq_level[p]!= 1)
93 eqtb[p]= save_stack[save_ptr];
94 xeq_level[p]= l; /* l may be used without having been ... */
97 if(eqtb[(hash_size + 3200)].cint > 0)
98 restore_trace(p, 542); /* restoring */
105 if(eqtb[(hash_size + 3200)].cint > 0)
106 restore_trace(p, 541); /* retaining */
111 lab30: cur_group = save_stack[save_ptr].hh.b1;
112 cur_boundary = save_stack[save_ptr].hh.v.RH;
115 confusion(540); /* cur_level */
116 return; // abort_flag set
119 /* This is where the old tex2.c used to start */
120 void prepare_mag (void)
122 if((mag_set > 0)&&(eqtb[(hash_size + 3180)].cint != mag_set))
124 print_err("Incompatible magnification(");
125 print_int(eqtb[(hash_size + 3180)].cint);
127 print_nl(" the previous value will be retained");
128 help2("I can handle only one magnification ratio per job.",
129 "So I've reverted to the magnification you used earlier on this run.");
131 geq_word_define((hash_size + 3180), mag_set);
133 if((eqtb[(hash_size + 3180)].cint <= 0)||
134 (eqtb[(hash_size + 3180)].cint > 32768L))
136 print_err("Illegal magnification has been changed to 1000");
137 help1("The magnification ratio must be between 1 and 32768.");
138 int_error(eqtb[(hash_size + 3180)].cint);
139 geq_word_define((hash_size + 3180), 1000);
141 mag_set = eqtb[(hash_size + 3180)].cint;
143 void token_show_ (halfword p)
145 /* begin if p<>null then show_token_list(link(p),null,10000000); l.6289 */
147 show_token_list(mem[p].hh.v.RH, 0, 10000000L);
149 void print_meaning (void)
151 print_cmd_chr(cur_cmd, cur_chr);
154 print_char(58); /* : */
158 else if(cur_cmd == 110)
160 print_char(58); /* : */
162 token_show(cur_mark[cur_chr]);
165 void show_cur_cmd_chr (void)
169 if(mode != shown_mode)
175 print_cmd_chr(cur_cmd, cur_chr);
176 print_char(125); /* } */
177 end_diagnostic(false);
179 void show_context (void)
191 base_ptr = input_ptr;
192 input_stack[base_ptr] = cur_input;
196 cur_input = input_stack[base_ptr];
197 if((cur_input.state_field != 0))
198 if((cur_input.name_field > 17)||(base_ptr == 0))
200 if((base_ptr == input_ptr)|| bottomline ||
201 (nn < eqtb[(hash_size + 3217)].cint))
203 /* begin if (base_ptr=input_ptr) or (state<>token_list) or
204 (token_type<>backed_up) or (loc<>null) then
205 {we omit backed-up token lists that have already been read} l.6761 */
206 if((base_ptr == input_ptr)||(cur_input.state_field != 0)||(
207 cur_input.index_field != 3)||(cur_input.loc_field != 0))
210 old_setting = selector;
211 if(cur_input.state_field != 0)
213 if(cur_input.name_field <= 17)
214 if((cur_input.name_field == 0))
215 if(base_ptr == 0)print_nl("<*>"); /* <*> */
216 else print_nl("<insert> "); /* */
218 print_nl("<read "); /* <read */
219 if(cur_input.name_field == 17)
220 print_char(42); /* * */
221 else print_int(cur_input.name_field - 1);
222 print_char(62); /* > */
226 /* print_int(line); */
227 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
228 if (c_style_flag) { /* 94/Mar/21 */
229 print_ln(); /* new line */
230 /* show current input file name - ignore if from terminal */
231 if (cur_input.name_field > 17) /* redundant ? */
232 print(cur_input.name_field);
233 print_char(40); /*(*/
234 print_int(line); /* line number */
235 print_char(41); /*)*/
236 print_char(32); /* */
237 print_char(58); /* : */
240 print_nl("l."); /* l. ? 573 ????? 98/Dec/8 check ! */
241 print_int(line); /* line number */
243 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
245 print_char(32); /* */
250 trick_count = 1000000L;
252 if(buffer[cur_input.limit_field]== eqtb[(hash_size + 3211)].cint)
253 j = cur_input.limit_field;
254 else j = cur_input.limit_field + 1;
257 register integer for_end;
258 i = cur_input.start_field;
262 if(i == cur_input.loc_field)
265 trick_count = tally + 1 + error_line - half_error_line;
266 if(trick_count < error_line)
267 trick_count = error_line;
271 while(i++ < for_end);
276 switch(cur_input.index_field)
278 print_nl("<argument> "); /* */
282 print_nl("<template> "); /* */
285 if(cur_input.loc_field == 0)
286 print_nl("<recently read> "); /* */
287 else print_nl("<to be read again> "); /* */
290 print_nl("<inserted text> "); /* */
295 print_cs(cur_input.name_field);
299 print_nl("<output> "); /* */
302 print_nl("<everypar> "); /* */
305 print_nl("<everymath> "); /* */
308 print_nl("<everydisplay> "); /* */
311 print_nl("<everyhbox> "); /* */
314 print_nl("<everyvbox> "); /* */
317 print_nl("<everyjob> "); /* */
320 print_nl("<everycr> "); /* */
323 print_nl("<mark> "); /* */
326 print_nl("<write> "); /* */
329 print_nl("?"); /* ? */
336 trick_count = 1000000L;
338 if(cur_input.index_field < 5)
339 show_token_list(cur_input.start_field, cur_input.loc_field, 100000L
341 else show_token_list(mem[cur_input.start_field].hh.v.RH,
342 cur_input.loc_field, 100000L);
344 selector = old_setting;
345 if(trick_count == 1000000L)
348 trick_count = tally + 1 + error_line - half_error_line;
349 if(trick_count < error_line)
350 trick_count = error_line;
352 if(tally < trick_count)
353 m = tally - first_count;
354 else m = trick_count - first_count;
355 if(l + first_count <= half_error_line){
361 p = l + first_count - half_error_line + 3;
365 register integer for_end;
367 for_end = first_count - 1;
369 print_char(trick_buf[q % error_line]);
370 while(q++ < for_end);
374 register integer for_end;
378 do print_char(32); /* */
379 while(q++ < for_end);
381 if(m + n <= error_line)
383 else p = first_count +(error_line - n - 3);
385 register integer for_end;
389 print_char(trick_buf[q % error_line]);
390 while(q++ < for_end);
392 if(m + n > error_line)
397 else if(nn == eqtb[(hash_size + 3217)].cint)
399 print_nl("..."); /* */
406 lab30: cur_input = input_stack[input_ptr];
408 #pragma optimize("g", off) /* 98/Dec/10 experiment */
409 void begin_token_list_ (halfword p, quarterword t)
412 if(input_ptr > max_in_stack)
414 max_in_stack = input_ptr;
415 #ifdef ALLOCATEINPUTSTACK
416 if(input_ptr == current_stack_size)
417 input_stack = realloc_input_stack (increment_stack_size);
418 if(input_ptr == current_stack_size){ /* check again after allocation */
419 overflow("input stack size", current_stack_size);
420 return; // abort_flag set
423 if(input_ptr == stack_size) { /* input stack - not dynamic */
424 overflow("input stack size", stack_size);
425 return; // abort_flag set
429 input_stack[input_ptr]= cur_input;
432 cur_input.state_field = 0;
433 cur_input.start_field = p;
434 cur_input.index_field = t;
437 incr(mem[p].hh.v.LH);
439 cur_input.limit_field = param_ptr;
442 cur_input.loc_field = mem[p].hh.v.RH;
443 if(eqtb[(hash_size + 3193)].cint > 1)
455 print_cmd_chr(72, t + (hash_size + 1307)); /* H */
460 end_diagnostic(false);
464 else cur_input.loc_field = p;
466 #pragma optimize("", on) /* 98/Dec/10 experiment */
467 void end_token_list (void)
469 if(cur_input.index_field >= 3)
471 if(cur_input.index_field <= 4)
472 flush_list(cur_input.start_field);
474 delete_token_ref(cur_input.start_field);
475 if(cur_input.index_field == 5)
476 while(param_ptr > cur_input.limit_field){
478 flush_list(param_stack[param_ptr]);
482 else if(cur_input.index_field == 1)
483 if(align_state > 500000L)align_state = 0;
485 fatal_error("(interwoven alignment preambles are not allowed)"); /* */
486 return; // abort_flag set
490 cur_input = input_stack[input_ptr];
494 pause_for_instructions ();
498 void back_input (void)
501 while((cur_input.state_field == 0)&&(cur_input.loc_field == 0)) {
505 mem[p].hh.v.LH = cur_tok;
509 else incr(align_state);
511 if(input_ptr > max_in_stack)
513 max_in_stack = input_ptr;
514 #ifdef ALLOCATEINPUTSTACK
515 if(input_ptr == current_stack_size)
516 input_stack = realloc_input_stack (increment_stack_size);
517 if(input_ptr == current_stack_size){ /* check again after allocation */
518 overflow("input stack size", current_stack_size);
519 return; // abort_flag set
522 if(input_ptr == stack_size) { /* stack size - not dynamic */
523 overflow("input stack size", stack_size);
524 return; // abort_flag set
528 input_stack[input_ptr]= cur_input;
531 cur_input.state_field = 0;
532 cur_input.start_field = p;
533 cur_input.index_field = 3;
534 cur_input.loc_field = p;
536 void back_error (void)
538 OK_to_interrupt = false;
540 OK_to_interrupt = true;
543 void ins_error (void)
545 OK_to_interrupt = false;
547 cur_input.index_field = 4;
548 OK_to_interrupt = true;
551 void begin_file_reading (void)
553 if(in_open == max_in_open){
554 overflow("text input levels", max_in_open); /* text input levels - NOT DYNAMIC */
555 return; // abort_flag set
557 #ifdef ALLOCATEBUFFER
558 if(first == current_buf_size)
559 buffer = realloc_buffer (increment_buf_size);
560 if(first == current_buf_size) { /* check again after allocation */
561 overflow("buffer size", current_buf_size);
562 return; // abort_flag set
565 if(first == buf_size){
566 overflow("buffer size", buf_size); /* buffer size - not dynamic */
567 return; // abort_flag set
572 if (in_open > high_in_open) /* 1999 Jan 17 */
573 high_in_open = in_open;
575 if(input_ptr > max_in_stack)
577 max_in_stack = input_ptr;
578 #ifdef ALLOCATEINPUTSTACK
579 if(input_ptr == current_stack_size)
580 input_stack = realloc_input_stack (increment_stack_size);
581 if(input_ptr == current_stack_size){
582 overflow("input stack size", current_stack_size); /* check again after allocation */
583 return; // abort_flag set
586 if(input_ptr == stack_size){
587 overflow("input stack size", stack_size); /* input stack - not dynamic */
588 return; // abort_flag set
592 input_stack[input_ptr]= cur_input;
595 cur_input.index_field = in_open;
596 line_stack[cur_input.index_field]= line;
597 cur_input.start_field = first;
598 cur_input.state_field = 1;
599 cur_input.name_field = 0;
601 void end_file_reading (void)
603 first = cur_input.start_field;
604 line = line_stack[cur_input.index_field];
605 if(cur_input.name_field > 17)
606 (void) a_close(input_file[cur_input.index_field]);
609 cur_input = input_stack[input_ptr];
613 /* called only form tex0.c */
614 void clear_for_error_prompt (void)
616 while((cur_input.state_field != 0)&&
617 (cur_input.name_field == 0)&&
619 (cur_input.loc_field > cur_input.limit_field))
623 void check_outer_validity (void)
627 if(scanner_status != 0)
629 deletions_allowed = false;
632 if((cur_input.state_field == 0)||(cur_input.name_field < 1)||
633 (cur_input.name_field > 17))
635 /* begin p:=get_avail; info(p):=cs_token_flag+cur_cs; */
637 mem[p].hh.v.LH = 4095 + cur_cs;
638 begin_token_list(p, 3);
643 if(scanner_status > 1)
647 print_err("File ended");
650 print_err("Forbidden control sequence found");
652 print_string(" while scanning ");
654 switch(scanner_status)
657 print_string("definition");
658 mem[p].hh.v.LH = 637;
664 mem[p].hh.v.LH = par_token;
670 print_string("preamble");
671 mem[p].hh.v.LH = 637;
675 /* mem[p].hh.v.LH = (hash_size + 4610); */
676 /* mem[p].hh.v.LH = (hash_size + 4095 + 515); */
677 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 515); /*96/Jan/10*/
678 align_state = -1000000L;
683 print_string("text");
684 mem[p].hh.v.LH = 637;
688 begin_token_list(p, 4);
689 print_string(" of ");
690 sprint_cs(warning_index);
691 help4("I suspect you have forgotten a `}', causing me",
692 "to read past where you wanted me to stop.",
693 "I'll try to recover; but if the error is serious,",
694 "you'd better type `E' or `X' now and fix your file.");
698 print_err("Incomplete ");
699 print_cmd_chr(105, cur_if); /* i */
700 print_string("; all text was ignored after line ");
701 print_int(skip_line);
702 help3("A forbidden control sequence occurred in skipped text.",
703 "This kind of error happens when you say `\\if...' and forget",
704 "the matching `\\fi'. I've inserted a `\\fi'; this might work.");
707 else help_line[2]= "The file ended while I was skipping conditional text.";
708 /* cur_tok = (hash_size + 4613); */
709 /* cur_tok = (hash_size + 4095 + 518); */
710 cur_tok = (hash_size + hash_extra + 4095 + 518); /* 96/Jan/10 */
713 deletions_allowed = true;
716 /*****************************************************************************/
717 /* get_next() moved from here to end for pragma optimize reasons 96/Sep/12 */
719 /*****************************************************************************/
720 void firm_up_the_line (void)
723 cur_input.limit_field = last;
724 if(eqtb[(hash_size + 3191)].cint > 0)
725 if(interaction > 1) {
728 if(cur_input.start_field < cur_input.limit_field) {
729 register integer for_end;
730 k = cur_input.start_field;
731 for_end = cur_input.limit_field - 1;
732 if(k <= for_end) do print(buffer[k]);
733 while(k++ < for_end);
735 first = cur_input.limit_field;
743 register integer for_end;
747 buffer[k + cur_input.start_field - first]= buffer[k];
748 while(k++ < for_end);
750 cur_input.limit_field = cur_input.start_field + last - first;
754 void get_token (void)
756 no_new_control_sequence = false;
758 no_new_control_sequence = true;
759 if(cur_cs == 0)cur_tok =(cur_cmd * 256)+ cur_chr;
760 else cur_tok = 4095 + cur_cs;
762 void macro_call (void)
763 {/* 10 22 30 31 40 */
775 small_number savescannerstatus;
776 halfword savewarningindex;
779 savescannerstatus = scanner_status;
780 savewarningindex = warning_index;
781 warning_index = cur_cs;
783 r = mem[refcount].hh.v.RH;
785 if(eqtb[(hash_size + 3193)].cint > 0)
789 print_cs(warning_index);
790 token_show(refcount);
791 end_diagnostic(false);
793 if(mem[r].hh.v.LH != 3584)
797 long_state = eqtb[cur_cs].hh.b0;
798 if(long_state >= 113)
799 long_state = long_state - 2;
801 mem[mem_top - 3].hh.v.RH = 0; /* repeat link(temp_head):=null; */
802 if((mem[r].hh.v.LH > 3583)||(mem[r].hh.v.LH < 3328))
803 s = 0; /* s:=null l.7984 */
805 matchchr = mem[r].hh.v.LH - 3328;
812 if(cur_tok == mem[r].hh.v.LH)
815 if((mem[r].hh.v.LH >= 3328)&&(mem[r].hh.v.LH <= 3584
827 print_err("Use of ");
828 sprint_cs(warning_index);
829 print_string(" doesn't match its definition");
830 help4("If you say, e.g., `\\def\\a1{...}', then you must always",
831 "put `1' after `\\a', since control sequence names are",
832 "made up of letters only. The macro here has not been",
833 "followed by the required stuff, so I'm ignoring it.");
843 mem[q].hh.v.LH = mem[t].hh.v.LH;
851 if(cur_tok != mem[v].hh.v.LH)
858 if(mem[u].hh.v.LH != mem[v].hh.v.LH)
863 lab30: t = mem[t].hh.v.RH;
867 if(cur_tok == par_token)
868 if(long_state != 112)
870 if(long_state == 111)
873 print_err("Paragraph ended before ");
874 sprint_cs(warning_index);
875 print_string("was complete");
876 help3("I suspect you've forgotten a `}', causing me to apply this",
877 "control sequence to too much text. How can we recover?",
878 "My plan is to forget the whole thing and hope for the best.");
881 pstack[n]= mem[mem_top - 3].hh.v.RH;
882 align_state = align_state - unbalance;
884 register integer for_end;
888 flush_list(pstack[m]);
889 while(m++ < for_end);
905 avail = mem[q].hh.v.RH;
914 mem[q].hh.v.LH = cur_tok;
918 if(cur_tok == par_token)
919 if(long_state != 112)
921 if(long_state == 111)
924 print_err("Paragraph ended before ");
925 sprint_cs(warning_index);
926 print_string(" was complete");
927 help3("I suspect you've forgotten a `}', causing me to apply this",
928 "control sequence to too much text. How can we recover?",
929 "My plan is to forget the whole thing and hope for the best.");
932 pstack[n]= mem[mem_top - 3].hh.v.RH;
933 align_state = align_state - unbalance;
935 register integer for_end;
939 flush_list(pstack[m]);
940 while(m++ < for_end);
954 lab31: rbraceptr = p;
958 mem[q].hh.v.LH = cur_tok;
964 print_err("Argument of ");
965 sprint_cs(warning_index);
966 print_string(" has an extra }");
967 help6("I've run across a `}' that doesn't seem to match anything.",
968 "For example, `\\def\\a#1{...}' and `\\a}' would produce",
969 "this error. If you simply proceed now, the `\\par' that",
970 "I've just inserted will cause me to report a runaway",
971 "argument that might be the root of the problem. But if",
972 "your `}' was spurious, just type `2' and it will go away.");
976 /* 420 in tex82.bug */
982 if(mem[r].hh.v.LH <= 3584)
983 if(mem[r].hh.v.LH >= 3328)
987 mem[p].hh.v.RH = q; /* p may be used without having ... */
988 mem[q].hh.v.LH = cur_tok;
992 incr(m); /* m may be used without having been ... */
993 if(mem[r].hh.v.LH > 3584)
995 if(mem[r].hh.v.LH < 3328)
999 if((m == 1)&&(mem[p].hh.v.LH < 768)&&(p != mem_top - 3
1002 mem[rbraceptr].hh.v.RH = 0; /* rbraceptr may be used without ... */
1004 mem[p].hh.v.RH = avail;
1011 p = mem[mem_top - 3].hh.v.RH;
1012 pstack[n]= mem[p].hh.v.RH;
1014 mem[p].hh.v.RH = avail;
1022 else pstack[n]= mem[mem_top - 3].hh.v.RH;
1024 if(eqtb[(hash_size + 3193)].cint > 0)
1026 begin_diagnostic ();
1027 print_nl(matchchr); /* matchchar may be used without ... */
1030 show_token_list(pstack[n - 1], 0, 1000);
1031 end_diagnostic(false);
1034 } while(!(mem[r].hh.v.LH == 3584));
1036 /* while (state=token_list)and(loc=null) do end_token_list; l.7956 */
1037 while((cur_input.state_field == 0)&&(cur_input.loc_field == 0))
1039 begin_token_list(refcount, 5);
1040 cur_input.name_field = warning_index;
1041 cur_input.loc_field = mem[r].hh.v.RH;
1044 if(param_ptr + n > max_param_stack)
1046 max_param_stack = param_ptr + n;
1047 #ifdef ALLOCATEPARAMSTACK
1048 if(max_param_stack > current_param_size)
1049 param_stack = realloc_param_stack (increment_param_size);
1050 if(max_param_stack > current_param_size){ /* check again after allocation */
1051 overflow("parameter stack size", current_param_size);
1052 return; // abort_flag set
1055 if(max_param_stack > param_size){
1056 overflow("parameter stack size", param_size); /* parameter stack - not dynamic */
1057 return; // abort_flag set
1062 register integer for_end;
1066 do param_stack[param_ptr + m]= pstack[m];
1067 while(m++ < for_end);
1069 param_ptr = param_ptr + n;
1071 lab10: scanner_status = savescannerstatus;
1072 warning_index = savewarningindex;
1074 void insert_relax (void)
1076 /* begin cur_tok:=cs_token_flag+cur_cs; back_input; */
1077 cur_tok = 4095 + cur_cs;
1079 /* cur_tok:=cs_token_flag+frozen_relax; back_input; token_type:=inserted; */
1080 /* cur_tok = (hash_size + 4616); */
1081 /* cur_tok = (hash_size + 4095 + 521); */
1082 cur_tok = (hash_size + hash_extra + 4095 + 521); /* 96/Jan/10 */
1084 cur_input.index_field = 4;
1092 small_number cvlbackup, radixbackup, cobackup;
1093 halfword backupbackup;
1094 small_number savescannerstatus;
1097 cvlbackup = cur_val_level;
1098 radixbackup = radix;
1099 cobackup = cur_order;
1100 backupbackup = mem[mem_top - 13].hh.v.RH;
1103 if(eqtb[(hash_size + 3199)].cint > 1)
1104 show_cur_cmd_chr ();
1108 /* begin if cur_mark[cur_chr]<>null then l.7881 */
1109 if(cur_mark[cur_chr]!= 0)
1110 begin_token_list(cur_mark[cur_chr], 14);
1128 savescannerstatus = scanner_status;
1131 scanner_status = savescannerstatus;
1134 if(t >= 4095) /* if t>=cs_token_flag then */
1136 /* begin p:=get_avail; info(p):=cs_token_flag+frozen_dont_expand; */
1138 /* mem[p].hh.v.LH = (hash_size + 4618); */
1139 /* mem[p].hh.v.LH = (hash_size + 4095 + 523); */
1140 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 523); /*96/Jan/10*/
1141 mem[p].hh.v.RH = cur_input.loc_field;
1142 cur_input.start_field = p;
1143 cur_input.loc_field = p;
1156 mem[q].hh.v.LH = cur_tok;
1159 } while(!(cur_cs != 0));
1162 print_err("Missing ");
1163 print_esc("endcsname");
1164 print_string(" inserted");
1165 help2("The control sequence marked <to be read again> should",
1166 "not appear between \\csname and \\endcsname.");
1171 while(p != 0){ /* while p<>null do l.7742 */
1173 if(j >= max_buf_stack)
1175 max_buf_stack = j + 1;
1176 #ifdef ALLOCATEBUFFER
1177 if(max_buf_stack == current_buf_size)
1178 buffer = realloc_buffer (increment_buf_size);
1179 if(max_buf_stack == current_buf_size){ /* check again after allocation */
1180 overflow("buffer size", current_buf_size);
1181 return; // abort_flag set
1184 if(max_buf_stack == buf_size){
1185 overflow("buffer size", buf_size); /* buffer size - not dynamic */
1186 return; // abort_flag set
1190 buffer[j]= mem[p].hh.v.LH % 256;
1191 /* buffer[j]= mem[p].hh.v.LH & 255; */ /* last 8 bits */
1197 no_new_control_sequence = false;
1198 cur_cs = id_lookup(first, j - first);
1199 no_new_control_sequence = true;
1203 /* else cur_cs:=single_base+buffer[first] {the list has length one} */
1204 else cur_cs = 257 + buffer[first];
1206 if(eqtb[cur_cs].hh.b0 == 101)
1208 eq_define(cur_cs, 0, 256);
1210 cur_tok = cur_cs + 4095;
1224 if(cur_chr > if_limit)
1228 print_err("Extra ");
1229 print_cmd_chr(106, cur_chr); /* j */
1230 help1("I'm ignoring this; it doesn't match any \\if.");
1235 while(cur_chr != 2)pass_text ();
1238 if_line = mem[p + 1].cint;
1239 cur_if = mem[p].hh.b1;
1240 if_limit = mem[p].hh.b0;
1241 cond_ptr = mem[p].hh.v.RH;
1247 if(cur_chr > 0)force_eof = true;
1248 else if(name_in_progress)insert_relax ();
1249 else start_input ();
1253 print_err("Undefined control sequence");
1254 help5("The control sequence at the end of the top line",
1255 "of your error message was never \\def'ed. If you have",
1256 "misspelled it (e.g., `\\hobx'), type `I' and the correct",
1257 "spelling (e.g., `I\\hbox'). Otherwise just continue,",
1258 "and I'll forget about whatever was undefined.");
1264 else if(cur_cmd < 115){
1269 /* cur_tok = (hash_size + 4615); */
1270 /* cur_tok = (hash_size + 4095 + 520); */
1271 cur_tok = (hash_size + hash_extra + 4095 + 520); /* 96/Jan/10 */
1275 cur_val_level = cvlbackup;
1276 radix = radixbackup;
1277 cur_order = cobackup;
1278 mem[mem_top - 13].hh.v.RH = backupbackup;
1280 void get_x_token (void)
1285 if(cur_cmd <= 100) goto lab30;
1291 /* cur_cs = (hash_size + 520); */
1292 cur_cs = (hash_size + hash_extra + 520); /* 96/Jan/10 */
1300 lab30: if(cur_cs == 0)
1301 cur_tok =(cur_cmd * 256)+ cur_chr;
1302 else cur_tok = 4095 + cur_cs;
1306 while(cur_cmd > 100){
1311 cur_tok =(cur_cmd * 256)+ cur_chr;
1312 else cur_tok = 4095 + cur_cs;
1314 void scan_left_brace (void)
1318 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
1321 print_err("Missing { inserted");
1322 help4("A left brace was mandatory here, so I've put one in.",
1323 "You might want to delete and/or insert some corrections",
1324 "so that I will find a matching right brace soon.",
1325 "(If you're confused by all this, try typing `I}' now.)");
1333 void scan_optional_equals (void)
1337 } while(!(cur_cmd != 10));
1338 if(cur_tok != 3133)back_input ();
1340 bool scan_keyword_(str_number s)
1341 {/* 10 */ register bool Result;
1348 while(k < str_start[s + 1]){
1350 if((cur_cs == 0)&&((cur_chr == str_pool[k])||(cur_chr ==
1351 str_pool[k]- 32))) {
1355 mem[q].hh.v.LH = cur_tok;
1360 else if((cur_cmd != 10)||(p != mem_top - 13))
1363 if(p != mem_top - 13)
1364 begin_token_list(mem[mem_top - 13].hh.v.RH, 3);
1369 flush_list(mem[mem_top - 13].hh.v.RH);
1373 void mu_error (void)
1375 print_err("Incompatible glue units");
1376 help1("I'm going to assume that 1mu=1pt when they're mixed.");
1379 void scan_eight_bit_int (void)
1382 if((cur_val < 0)||(cur_val > 255))
1384 print_err("Bad register code");
1385 help2("A register number must be between 0 and 255.",
1386 "I changed this one to zero.");
1391 void scan_char_num (void)
1394 if((cur_val < 0)||(cur_val > 255))
1396 print_err("Bad character code");
1397 help2("A character number must be between 0 and 255.",
1398 "I changed this one to zero.");
1403 void scan_four_bit_int (void)
1406 if((cur_val < 0)||(cur_val > 15))
1408 print_err("Bad number");
1409 help2("Since I expected to read a number between 0 and 15,",
1410 "I changed this one to zero.");
1415 void scan_fifteen_bit_int (void)
1418 if((cur_val < 0)||(cur_val > 32767))
1420 print_err("Bad mathchar");
1421 help2("A mathchar number must be between 0 and 32767.",
1422 "I changed this one to zero.");
1427 void scan_twenty_seven_bit_int (void)
1430 if((cur_val < 0)||(cur_val > 134217727L)) /* 2^27 - 1 */
1432 print_err("Bad delimiter code");
1433 help2("A numeric delimiter code must be between 0 and 2^{27}-1.",
1434 "I changed this one to zero.");
1439 void scan_font_ident (void)
1441 internal_font_number f;
1445 } while(!(cur_cmd != 10));
1447 f = eqtb[(hash_size + 1834)].hh.v.RH;
1448 else if(cur_cmd == 87)
1450 else if(cur_cmd == 86)
1453 scan_four_bit_int ();
1454 f = eqtb[m + cur_val].hh.v.RH;
1457 print_err("Missing font identifier");
1458 help2("I was looking for a control sequence whose",
1459 "current meaning has been defined by \\font.");
1465 void find_font_dimen_(bool writing)
1467 internal_font_number f;
1473 /* if(n <= 0)*/ /* change 98/Oct/5 */
1474 if(n < 0 || (n == 0 && font_dimen_zero == 0))
1477 /* else begin if writing and(n<=space_shrink_code)and@|
1478 (n>=space_code)and(font_glue[f]<>null) then
1479 begin delete_glue_ref(font_glue[f]); l.11225 */
1480 if(writing &&(n <= 4)&&(n >= 2)&&(font_glue[f]!= 0))
1482 delete_glue_ref(font_glue[f]);
1483 font_glue[f]= 0; /* font_glue[f]:=null */
1485 if(n > font_params[f])
1490 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1492 if(fmem_ptr == current_font_mem_size) { /* 93/Nov/28 ??? */
1493 font_info = realloc_font_info(increment_font_mem_size);
1495 if(fmem_ptr == current_font_mem_size){ /* 94/Jan/24 */
1496 overflow("font memory", current_font_mem_size); /* font memory */
1497 return; // abort_flag set
1500 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1501 if(fmem_ptr == font_mem_size){
1502 overflow("font memory", font_mem_size); /* font memory */
1503 return; // abort_flag set
1506 font_info[fmem_ptr].cint = 0;
1508 incr(font_params[f]);
1509 } while(!(n == font_params[f]));
1510 cur_val = fmem_ptr - 1;
1512 /* else cur_val = n + param_base[f]; */ /* 98/Oct/5 */
1513 else if (n > 0) cur_val = n + param_base[f]; /* 98/Oct/5 */
1514 else cur_val = &font_check[f] - &font_info[0]; /* 98/Oct/5 */
1515 /* checksum = (((font_check[f].b0) << 8 | font_check[f].b1) << 8 |
1516 font_check[f].b2) << 8 | font_check[f].b3; */
1518 /* compiler error: '-' : incompatible types - from 'union fmemoryword *' to 'struct fourunsignedchars *' */
1519 if(cur_val == fmem_ptr){
1521 /* print_esc(hash[(hash_size + 524) + f].v.RH); */
1522 //print_esc(hash[(hash_size + hash_extra + 524) + f].v.RH); /*96/Jan/10*/
1523 print_esc("");print(hash[(hash_size + hash_extra + 524) + f].v.RH);
1524 print_string(" has only ");
1525 print_int(font_params[f]);
1526 print_string(" fontdimen parameters");
1527 help2("To increase the number of font parameters, you must",
1528 "use \\fontdimen immediately after the \\font is loaded.");
1533 /* NOTE: the above use of /fontdimen0 to access the checksum is a kludge */
1534 /* In future would be better to do this by allocating one more slot for */
1535 /* for parameters when a font is read rather than carry checksum separately */
1536 /* The above gets the value byte order reversed ... 98/Oct/5 */
1538 void scan_something_internal_(small_number level, bool negative)
1547 if(m == (hash_size + 2907))
1549 cur_val = eqtb[(hash_size + 2907) + cur_val].hh.v.RH;
1552 else if(m < (hash_size + 2907))
1554 cur_val = eqtb[m + cur_val].hh.v.RH;
1559 cur_val = eqtb[m + cur_val].cint;
1571 print_err("Missing number, treated as zero");
1572 help3("A number should have been here; I inserted `0'.",
1573 "(If you can't figure out why I needed to see a number,",
1574 "look up `weird error' in the index to The TeXbook.)");
1581 else if(cur_cmd <= 72)
1585 scan_eight_bit_int ();
1586 m = (hash_size + 1322) + cur_val;
1589 cur_val = eqtb[m].hh.v.RH;
1598 /* cur_val = (hash_size + 524) + cur_val; */
1599 cur_val = (hash_size + hash_extra + 524) + cur_val; /* 96/Jan/10 */
1606 cur_val = eqtb[m].cint;
1612 cur_val = eqtb[m].cint;
1618 cur_val = eqtb[m].hh.v.RH;
1624 cur_val = eqtb[m].hh.v.RH;
1631 print_err("Improper ");
1632 print_cmd_chr(79, m); /* O */
1633 help4("You can refer to \\spacefactor only in horizontal mode;",
1634 "you can refer to \\prevdepth only in vertical mode; and",
1635 "neither of these is meaningful inside \\write. So",
1636 "I'm forgetting what you said and using zero instead.");
1650 cur_val = cur_list.aux_field.cint;
1655 cur_val = space_factor;
1667 nest[nest_ptr]= cur_list;
1669 while(abs(nest[p].mode_field)!= 1)decr(p);
1671 cur_val = nest[p].pg_field;
1679 cur_val = dead_cycles;
1680 else cur_val = insert_penalties;
1686 if((page_contents == 0)&&(! output_active))
1688 cur_val = 1073741823L; /* 2^30 - 1 */
1690 else cur_val = page_so_far[m];
1696 if(eqtb[(hash_size + 1312)].hh.v.RH == 0)
1698 else cur_val = mem[eqtb[(hash_size + 1312)].hh.v.RH].hh.v.LH;
1704 scan_eight_bit_int ();
1705 if(eqtb[(hash_size + 1578) + cur_val].hh.v.RH == 0)
1707 else cur_val = mem[eqtb[(hash_size + 1578) + cur_val].hh.v.RH + m].cint;
1720 find_font_dimen(false);
1721 font_info[fmem_ptr].cint = 0;
1723 cur_val = font_info[cur_val].cint;
1732 cur_val = hyphen_char[cur_val];
1737 cur_val = skew_char[cur_val];
1744 scan_eight_bit_int ();
1747 cur_val = eqtb[(hash_size + 3218) + cur_val].cint;
1750 cur_val = eqtb[(hash_size + 3751) + cur_val].cint;
1753 cur_val = eqtb[(hash_size + 800) + cur_val].hh.v.RH;
1756 cur_val = eqtb[(hash_size + 1056) + cur_val].hh.v.RH;
1767 else cur_val = last_badness;
1775 cur_val_level = cur_chr;
1776 if(!(tail >= hi_mem_min)&&(mode != 0)
1780 if(mem[tail].hh.b0 == 12)
1781 cur_val = mem[tail + 1].cint;
1784 if(mem[tail].hh.b0 == 11)
1785 cur_val = mem[tail + 1].cint;
1788 if(mem[tail].hh.b0 == 10)
1790 cur_val = mem[tail + 1].hh.v.LH;
1791 if(mem[tail].hh.b1 == 99)
1796 else if((mode == 1)&&(tail == cur_list
1800 cur_val = last_penalty;
1803 cur_val = last_kern;
1806 /* if(last_glue != 262143L) */ /* NO! */
1807 if(last_glue != empty_flag)
1808 cur_val = last_glue;
1815 print_err("You can't use `");
1816 print_cmd_chr(cur_cmd, cur_chr);
1817 print_string("' after ");
1819 help1("I'm forgetting what you said and using zero instead.");
1832 while(cur_val_level > level){
1834 if(cur_val_level == 2)
1835 cur_val = mem[cur_val + 1].cint;
1836 else if(cur_val_level == 3){
1839 decr(cur_val_level);
1842 if(cur_val_level >= 2)
1844 cur_val = new_spec(cur_val);
1846 mem[cur_val + 1].cint = - (integer) mem[cur_val + 1].cint;
1847 mem[cur_val + 2].cint = - (integer) mem[cur_val + 2].cint;
1848 mem[cur_val + 3].cint = - (integer) mem[cur_val + 3].cint;
1851 else cur_val = - (integer) cur_val;
1852 else if((cur_val_level >= 2)&&(cur_val_level <= 3))
1853 incr(mem[cur_val].hh.v.RH);
1856 /*****************************************************************************/
1858 /* Moved here to avoid question about pragma optimize 96/Sep/12 */
1860 /* #pragma optimize ("a", off) */
1862 void get_next (void)
1863 {/* 20 25 21 26 40 10 */
1866 /* char cat; */ /* make this an int ? */
1867 int cat; /* make this an int ? 95/Jan/7 */
1873 if(cur_input.state_field != 0) {
1874 lab25: if(cur_input.loc_field <= cur_input.limit_field) {
1875 cur_chr = buffer[cur_input.loc_field];
1876 incr(cur_input.loc_field);
1877 lab21: cur_cmd = eqtb[(hash_size + 1883) + cur_chr].hh.v.RH;
1878 switch(cur_input.state_field + cur_cmd)
1890 if(cur_input.loc_field > cur_input.limit_field)
1894 lab26: k = cur_input.loc_field;
1895 cur_chr = buffer[k];
1896 cat = eqtb[(hash_size + 1883) + cur_chr].hh.v.RH;
1899 cur_input.state_field = 17;
1901 cur_input.state_field = 17;
1902 else cur_input.state_field = 1;
1903 if((cat == 11)&&(k <= cur_input.limit_field))
1906 cur_chr = buffer[k];
1907 cat = eqtb[(hash_size + 1883) + cur_chr].hh.v.RH;
1909 } while(!((cat != 11)||(k > cur_input.limit_field)))
1912 if(buffer[k]== cur_chr)
1914 if(k < cur_input.limit_field)
1920 if((((c >= 48)&&(c <= 57)) ||((c >= 97)&&
1922 if(k + 2 <= cur_input.limit_field)
1925 if((((cc >= 48)&&(cc <= 57)) ||((cc >= 97
1933 else cur_chr = c - 87;
1935 cur_chr = 16 * cur_chr + cc - 48;
1936 else cur_chr = 16 * cur_chr + cc - 87;
1937 buffer[k - 1]= cur_chr;
1940 buffer[k - 1]= c + 64;
1941 else buffer[k - 1]= c - 64;
1942 cur_input.limit_field = cur_input.limit_field - d;
1944 while(k <= cur_input.limit_field){
1946 buffer[k]= buffer[k + d];
1955 if(k > cur_input.loc_field + 1)
1957 cur_cs = id_lookup(cur_input.loc_field, k - cur_input.loc_field
1959 cur_input.loc_field = k;
1965 if(buffer[k]== cur_chr)
1967 if(k < cur_input.limit_field)
1973 if((((c >= 48)&&(c <= 57)) ||((c >= 97)&&(
1975 if(k + 2 <= cur_input.limit_field)
1978 if((((cc >= 48)&&(cc <= 57)) ||((cc >= 97)
1986 else cur_chr = c - 87;
1987 if(cc <= 57) /* cc may be used without ... */
1988 cur_chr = 16 * cur_chr + cc - 48;
1989 else cur_chr = 16 * cur_chr + cc - 87;
1990 buffer[k - 1]= cur_chr;
1993 buffer[k - 1]= c + 64;
1994 else buffer[k - 1]= c - 64;
1995 cur_input.limit_field = cur_input.limit_field - d;
1997 while(k <= cur_input.limit_field){
1998 buffer[k]= buffer[k + d];
2005 /* cur_cs:=single_base+buffer[loc]; incr(loc); */
2006 cur_cs = 257 + buffer[cur_input.loc_field];
2007 incr(cur_input.loc_field);
2009 lab40: cur_cmd = eqtb[cur_cs].hh.b0;
2010 cur_chr = eqtb[cur_cs].hh.v.RH;
2012 check_outer_validity ();
2020 cur_cs = cur_chr + 1;
2021 cur_cmd = eqtb[cur_cs].hh.b0;
2022 cur_chr = eqtb[cur_cs].hh.v.RH;
2023 cur_input.state_field = 1;
2025 check_outer_validity ();
2033 if(cur_chr == buffer[cur_input.loc_field])
2034 if(cur_input.loc_field < cur_input.limit_field)
2036 c = buffer[cur_input.loc_field + 1];
2039 cur_input.loc_field = cur_input.loc_field + 2;
2040 if((((c >= 48)&&(c <= 57)) ||((c >= 97)&&(c <=
2042 if(cur_input.loc_field <= cur_input.limit_field)
2044 cc = buffer[cur_input.loc_field];
2045 if((((cc >= 48)&&(cc <= 57)) ||((cc >= 97)&&(
2048 incr(cur_input.loc_field);
2051 else cur_chr = c - 87;
2053 cur_chr = 16 * cur_chr + cc - 48;
2054 else cur_chr = 16 * cur_chr + cc - 87;
2060 else cur_chr = c - 64;
2064 cur_input.state_field = 1;
2071 print_err("Text line contains an invalid character");
2072 help2("A funny symbol that I can't read has just been input.",
2073 "Continue, and I'll forget that it ever happened.");
2074 deletions_allowed = false;
2076 deletions_allowed = true;
2082 cur_input.state_field = 17;
2088 cur_input.loc_field = cur_input.limit_field + 1;
2098 cur_input.loc_field = cur_input.limit_field + 1;
2104 cur_input.loc_field = cur_input.limit_field + 1;
2106 cur_cmd = eqtb[cur_cs].hh.b0;
2107 cur_chr = eqtb[cur_cs].hh.v.RH;
2109 check_outer_validity ();
2119 cur_input.state_field = 1;
2129 cur_input.state_field = 1;
2145 cur_input.state_field = 1;
2153 cur_input.state_field = 33;
2154 if(cur_input.name_field > 17) {
2156 first = cur_input.start_field;
2158 if(input_ln(input_file[cur_input.index_field], true)) {
2159 firm_up_the_line ();
2161 else force_eof = true;
2164 print_char(41); /*)*/
2170 end_file_reading ();
2171 check_outer_validity ();
2174 if((eqtb[(hash_size + 3211)].cint < 0)||
2175 (eqtb[(hash_size + 3211)].cint > 255))
2176 decr(cur_input.limit_field);
2177 /* long to unsigned char ... */
2178 else buffer[cur_input.limit_field]= eqtb[(hash_size + 3211)].cint;
2179 first = cur_input.limit_field + 1;
2180 cur_input.loc_field = cur_input.start_field;
2183 if(!(cur_input.name_field == 0)) {
2189 end_file_reading ();
2192 if(selector < 18) open_log_file ();
2193 if(interaction > 1){
2194 if((eqtb[(hash_size + 3211)].cint < 0)||
2195 (eqtb[(hash_size + 3211)].cint > 255)
2197 incr(cur_input.limit_field);
2198 if(cur_input.limit_field == cur_input.start_field)
2199 print_nl("(Please type a command or say `\\end')"); /* */
2201 first = cur_input.start_field;
2204 print_string("*"); /* * */
2207 cur_input.limit_field = last;
2208 if((eqtb[(hash_size + 3211)].cint < 0)||
2209 (eqtb[(hash_size + 3211)].cint > 255)
2211 decr(cur_input.limit_field);
2212 /* long to unsigned char ... */
2213 else buffer[cur_input.limit_field]= eqtb[(hash_size + 3211)].cint;
2214 first = cur_input.limit_field + 1;
2215 cur_input.loc_field = cur_input.start_field;
2218 fatal_error("*** (job aborted, no legal \\end found)"); /* */
2219 return; // abort_flag set
2224 pause_for_instructions ();
2230 else if(cur_input.loc_field != 0)
2232 t = mem[cur_input.loc_field].hh.v.LH;
2233 cur_input.loc_field = mem[cur_input.loc_field].hh.v.RH;
2237 cur_cmd = eqtb[cur_cs].hh.b0;
2238 cur_chr = eqtb[cur_cs].hh.v.RH;
2242 cur_cs = mem[cur_input.loc_field].hh.v.LH - 4095;
2243 cur_input.loc_field = 0;
2244 cur_cmd = eqtb[cur_cs].hh.b0;
2245 cur_chr = eqtb[cur_cs].hh.v.RH;
2253 check_outer_validity ();
2259 /* cur_cmd = t >> 8; */ /* top 8 bits */
2261 /* cur_chr = t & 255; */ /* last 8 bits */
2271 begin_token_list(param_stack[cur_input.limit_field + cur_chr - 1],
2288 if(align_state == 0)
2290 if(scanner_status == 4){
2291 fatal_error("(interwoven alignment preambles are not allowed)"); /* */
2292 return; // abort_flag set
2295 cur_cmd = mem[cur_align + 5].hh.v.LH;
2296 mem[cur_align + 5].hh.v.LH = cur_chr;
2298 begin_token_list(mem_top - 10, 2);
2299 else begin_token_list(mem[cur_align + 2].cint, 2);
2300 align_state = 1000000L;
2305 #pragma optimize ("", on) /* 96/Sep/12 */
2307 /*****************************************************************************/