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)
168 print_nl("{"); /* { */
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){
360 print(275); /* ... */
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)
393 print(275); /* ... */
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(590, current_stack_size);
420 return; // abort_flag set
423 if(input_ptr == stack_size) { /* input stack - not dynamic */
424 overflow(590, 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)
449 print_esc(348); /* mark */
452 print_esc(591); /* write */
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(590, current_stack_size);
519 return; // abort_flag set
522 if(input_ptr == stack_size) { /* stack size - not dynamic */
523 overflow(590, 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(593, 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(256, current_buf_size);
562 return; // abort_flag set
565 if(first == buf_size){
566 overflow(256, 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(590, current_stack_size); /* check again after allocation */
583 return; // abort_flag set
586 if(input_ptr == stack_size){
587 overflow(590, 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");
651 print_err("Forbidden control sequence found");
653 print(603); /* while scanning */
655 switch(scanner_status)
658 print(567); /* definition */
659 mem[p].hh.v.LH = 637;
664 print(609); /* use */
665 mem[p].hh.v.LH = par_token;
671 print(569); /* preamble */
672 mem[p].hh.v.LH = 637;
676 /* mem[p].hh.v.LH = (hash_size + 4610); */
677 /* mem[p].hh.v.LH = (hash_size + 4095 + 515); */
678 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 515); /*96/Jan/10*/
679 align_state = -1000000L;
684 print(570); /* text */
685 mem[p].hh.v.LH = 637;
689 begin_token_list(p, 4);
691 sprint_cs(warning_index);
692 help4("I suspect you have forgotten a `}', causing me",
693 "to read past where you wanted me to stop.",
694 "I'll try to recover; but if the error is serious,",
695 "you'd better type `E' or `X' now and fix your file.");
699 print_err("Incomplete ");
700 print_cmd_chr(105, cur_if); /* i */
701 print(596); /*; all text was ignored after line */
702 print_int(skip_line);
703 help3("A forbidden control sequence occurred in skipped text.",
704 "This kind of error happens when you say `\\if...' and forget",
705 "the matching `\\fi'. I've inserted a `\\fi'; this might work.");
708 else help_line[2]= 600; /* The file ended while I was skipping conditional text. */
709 /* cur_tok = (hash_size + 4613); */
710 /* cur_tok = (hash_size + 4095 + 518); */
711 cur_tok = (hash_size + hash_extra + 4095 + 518); /* 96/Jan/10 */
714 deletions_allowed = true;
717 /*****************************************************************************/
718 /* get_next() moved from here to end for pragma optimize reasons 96/Sep/12 */
720 /*****************************************************************************/
721 void firm_up_the_line (void)
724 cur_input.limit_field = last;
725 if(eqtb[(hash_size + 3191)].cint > 0)
726 if(interaction > 1) {
729 if(cur_input.start_field < cur_input.limit_field) {
730 register integer for_end;
731 k = cur_input.start_field;
732 for_end = cur_input.limit_field - 1;
733 if(k <= for_end) do print(buffer[k]);
734 while(k++ < for_end);
736 first = cur_input.limit_field;
744 register integer for_end;
748 buffer[k + cur_input.start_field - first]= buffer[k];
749 while(k++ < for_end);
751 cur_input.limit_field = cur_input.start_field + last - first;
755 void get_token (void)
757 no_new_control_sequence = false;
759 no_new_control_sequence = true;
760 if(cur_cs == 0)cur_tok =(cur_cmd * 256)+ cur_chr;
761 else cur_tok = 4095 + cur_cs;
763 void macro_call (void)
764 {/* 10 22 30 31 40 */
776 small_number savescannerstatus;
777 halfword savewarningindex;
780 savescannerstatus = scanner_status;
781 savewarningindex = warning_index;
782 warning_index = cur_cs;
784 r = mem[refcount].hh.v.RH;
786 if(eqtb[(hash_size + 3193)].cint > 0)
790 print_cs(warning_index);
791 token_show(refcount);
792 end_diagnostic(false);
794 if(mem[r].hh.v.LH != 3584)
798 long_state = eqtb[cur_cs].hh.b0;
799 if(long_state >= 113)
800 long_state = long_state - 2;
802 mem[mem_top - 3].hh.v.RH = 0; /* repeat link(temp_head):=null; */
803 if((mem[r].hh.v.LH > 3583)||(mem[r].hh.v.LH < 3328))
804 s = 0; /* s:=null l.7984 */
807 matchchr = mem[r].hh.v.LH - 3328;
814 if(cur_tok == mem[r].hh.v.LH)
817 if((mem[r].hh.v.LH >= 3328)&&(mem[r].hh.v.LH <= 3584
829 print_err("Use of ");
830 sprint_cs(warning_index);
831 print(648); /* doesn't match its definition */
832 help4("If you say, e.g., `\\def\\a1{...}', then you must always",
833 "put `1' after `\\a', since control sequence names are",
834 "made up of letters only. The macro here has not been",
835 "followed by the required stuff, so I'm ignoring it.");
846 mem[q].hh.v.LH = mem[t].hh.v.LH;
854 if(cur_tok != mem[v].hh.v.LH)
861 if(mem[u].hh.v.LH != mem[v].hh.v.LH)
866 lab30: t = mem[t].hh.v.RH;
870 if(cur_tok == par_token)
871 if(long_state != 112)
873 if(long_state == 111)
876 print_err("Paragraph ended before ");
877 sprint_cs(warning_index);
878 print(643); /* was complete */
879 help3("I suspect you've forgotten a `}', causing me to apply this",
880 "control sequence to too much text. How can we recover?",
881 "My plan is to forget the whole thing and hope for the best.");
884 pstack[n]= mem[mem_top - 3].hh.v.RH;
885 align_state = align_state - unbalance;
887 register integer for_end;
891 flush_list(pstack[m]);
892 while(m++ < for_end);
908 avail = mem[q].hh.v.RH;
917 mem[q].hh.v.LH = cur_tok;
921 if(cur_tok == par_token)
922 if(long_state != 112)
924 if(long_state == 111)
927 print_err("Paragraph ended before ");
928 sprint_cs(warning_index);
929 print(643); /* was complete */
930 help3("I suspect you've forgotten a `}', causing me to apply this",
931 "control sequence to too much text. How can we recover?",
932 "My plan is to forget the whole thing and hope for the best.");
935 pstack[n]= mem[mem_top - 3].hh.v.RH;
936 align_state = align_state - unbalance;
938 register integer for_end;
942 flush_list(pstack[m]);
943 while(m++ < for_end);
957 lab31: rbraceptr = p;
961 mem[q].hh.v.LH = cur_tok;
968 print_err("Argument of ");
969 sprint_cs(warning_index);
970 print(635); /* has an extra } */
971 help6("I've run across a `}' that doesn't seem to match anything.",
972 "For example, `\\def\\a#1{...}' and `\\a}' would produce",
973 "this error. If you simply proceed now, the `\\par' that",
974 "I've just inserted will cause me to report a runaway",
975 "argument that might be the root of the problem. But if",
976 "your `}' was spurious, just type `2' and it will go away.");
985 if(mem[r].hh.v.LH <= 3584)
986 if(mem[r].hh.v.LH >= 3328)
990 mem[p].hh.v.RH = q; /* p may be used without having ... */
991 mem[q].hh.v.LH = cur_tok;
995 incr(m); /* m may be used without having been ... */
996 if(mem[r].hh.v.LH > 3584)
998 if(mem[r].hh.v.LH < 3328)
1002 if((m == 1)&&(mem[p].hh.v.LH < 768)&&(p != mem_top - 3
1005 mem[rbraceptr].hh.v.RH = 0; /* rbraceptr may be used without ... */
1007 mem[p].hh.v.RH = avail;
1014 p = mem[mem_top - 3].hh.v.RH;
1015 pstack[n]= mem[p].hh.v.RH;
1017 mem[p].hh.v.RH = avail;
1025 else pstack[n]= mem[mem_top - 3].hh.v.RH;
1027 if(eqtb[(hash_size + 3193)].cint > 0)
1029 begin_diagnostic ();
1030 print_nl(matchchr); /* matchchar may be used without ... */
1032 print(653); /* <- */
1033 show_token_list(pstack[n - 1], 0, 1000);
1034 end_diagnostic(false);
1037 } while(!(mem[r].hh.v.LH == 3584));
1039 /* while (state=token_list)and(loc=null) do end_token_list; l.7956 */
1040 while((cur_input.state_field == 0)&&(cur_input.loc_field == 0))
1042 begin_token_list(refcount, 5);
1043 cur_input.name_field = warning_index;
1044 cur_input.loc_field = mem[r].hh.v.RH;
1047 if(param_ptr + n > max_param_stack)
1049 max_param_stack = param_ptr + n;
1050 #ifdef ALLOCATEPARAMSTACK
1051 if(max_param_stack > current_param_size)
1052 param_stack = realloc_param_stack (increment_param_size);
1053 if(max_param_stack > current_param_size){ /* check again after allocation */
1054 overflow(633, current_param_size);
1055 return; // abort_flag set
1058 if(max_param_stack > param_size){
1059 overflow(633, param_size); /* parameter stack - not dynamic */
1060 return; // abort_flag set
1065 register integer for_end;
1069 do param_stack[param_ptr + m]= pstack[m];
1070 while(m++ < for_end);
1072 param_ptr = param_ptr + n;
1074 lab10: scanner_status = savescannerstatus;
1075 warning_index = savewarningindex;
1077 void insert_relax (void)
1079 /* begin cur_tok:=cs_token_flag+cur_cs; back_input; */
1080 cur_tok = 4095 + cur_cs;
1082 /* cur_tok:=cs_token_flag+frozen_relax; back_input; token_type:=inserted; */
1083 /* cur_tok = (hash_size + 4616); */
1084 /* cur_tok = (hash_size + 4095 + 521); */
1085 cur_tok = (hash_size + hash_extra + 4095 + 521); /* 96/Jan/10 */
1087 cur_input.index_field = 4;
1095 small_number cvlbackup, radixbackup, cobackup;
1096 halfword backupbackup;
1097 small_number savescannerstatus;
1100 cvlbackup = cur_val_level;
1101 radixbackup = radix;
1102 cobackup = cur_order;
1103 backupbackup = mem[mem_top - 13].hh.v.RH;
1106 if(eqtb[(hash_size + 3199)].cint > 1)
1107 show_cur_cmd_chr ();
1111 /* begin if cur_mark[cur_chr]<>null then l.7881 */
1112 if(cur_mark[cur_chr]!= 0)
1113 begin_token_list(cur_mark[cur_chr], 14);
1131 savescannerstatus = scanner_status;
1134 scanner_status = savescannerstatus;
1137 if(t >= 4095) /* if t>=cs_token_flag then */
1139 /* begin p:=get_avail; info(p):=cs_token_flag+frozen_dont_expand; */
1141 /* mem[p].hh.v.LH = (hash_size + 4618); */
1142 /* mem[p].hh.v.LH = (hash_size + 4095 + 523); */
1143 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 523); /*96/Jan/10*/
1144 mem[p].hh.v.RH = cur_input.loc_field;
1145 cur_input.start_field = p;
1146 cur_input.loc_field = p;
1159 mem[q].hh.v.LH = cur_tok;
1162 } while(!(cur_cs != 0));
1165 print_err("Missing ");
1166 print_esc(502); /* endcsname */
1167 print(623); /* inserted */
1168 help2("The control sequence marked <to be read again> should",
1169 "not appear between \\csname and \\endcsname.");
1174 while(p != 0){ /* while p<>null do l.7742 */
1176 if(j >= max_buf_stack)
1178 max_buf_stack = j + 1;
1179 #ifdef ALLOCATEBUFFER
1180 if(max_buf_stack == current_buf_size)
1181 buffer = realloc_buffer (increment_buf_size);
1182 if(max_buf_stack == current_buf_size){ /* check again after allocation */
1183 overflow(256, current_buf_size);
1184 return; // abort_flag set
1187 if(max_buf_stack == buf_size){
1188 overflow(256, buf_size); /* buffer size - not dynamic */
1189 return; // abort_flag set
1193 buffer[j]= mem[p].hh.v.LH % 256;
1194 /* buffer[j]= mem[p].hh.v.LH & 255; */ /* last 8 bits */
1200 no_new_control_sequence = false;
1201 cur_cs = id_lookup(first, j - first);
1202 no_new_control_sequence = true;
1206 /* else cur_cs:=single_base+buffer[first] {the list has length one} */
1207 else cur_cs = 257 + buffer[first];
1209 if(eqtb[cur_cs].hh.b0 == 101)
1211 eq_define(cur_cs, 0, 256);
1213 cur_tok = cur_cs + 4095;
1227 if(cur_chr > if_limit)
1231 print_err("Extra ");
1232 print_cmd_chr(106, cur_chr); /* j */
1233 help1("I'm ignoring this; it doesn't match any \\if.");
1238 while(cur_chr != 2)pass_text ();
1241 if_line = mem[p + 1].cint;
1242 cur_if = mem[p].hh.b1;
1243 if_limit = mem[p].hh.b0;
1244 cond_ptr = mem[p].hh.v.RH;
1250 if(cur_chr > 0)force_eof = true;
1251 else if(name_in_progress)insert_relax ();
1252 else start_input ();
1256 print_err("Undefined control sequence");
1257 help5("The control sequence at the end of the top line",
1258 "of your error message was never \\def'ed. If you have",
1259 "misspelled it (e.g., `\\hobx'), type `I' and the correct",
1260 "spelling (e.g., `I\\hbox'). Otherwise just continue,",
1261 "and I'll forget about whatever was undefined.");
1267 else if(cur_cmd < 115){
1272 /* cur_tok = (hash_size + 4615); */
1273 /* cur_tok = (hash_size + 4095 + 520); */
1274 cur_tok = (hash_size + hash_extra + 4095 + 520); /* 96/Jan/10 */
1278 cur_val_level = cvlbackup;
1279 radix = radixbackup;
1280 cur_order = cobackup;
1281 mem[mem_top - 13].hh.v.RH = backupbackup;
1283 void get_x_token (void)
1288 if(cur_cmd <= 100) goto lab30;
1294 /* cur_cs = (hash_size + 520); */
1295 cur_cs = (hash_size + hash_extra + 520); /* 96/Jan/10 */
1303 lab30: if(cur_cs == 0)
1304 cur_tok =(cur_cmd * 256)+ cur_chr;
1305 else cur_tok = 4095 + cur_cs;
1309 while(cur_cmd > 100){
1314 cur_tok =(cur_cmd * 256)+ cur_chr;
1315 else cur_tok = 4095 + cur_cs;
1317 void scan_left_brace (void)
1321 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
1324 print_err("Missing { inserted");
1325 help4("A left brace was mandatory here, so I've put one in.",
1326 "You might want to delete and/or insert some corrections",
1327 "so that I will find a matching right brace soon.",
1328 "(If you're confused by all this, try typing `I}' now.)");
1336 void scan_optional_equals (void)
1340 } while(!(cur_cmd != 10));
1341 if(cur_tok != 3133)back_input ();
1343 bool scan_keyword_(str_number s)
1344 {/* 10 */ register bool Result;
1351 while(k < str_start[s + 1]){
1353 if((cur_cs == 0)&&((cur_chr == str_pool[k])||(cur_chr ==
1354 str_pool[k]- 32))) {
1358 mem[q].hh.v.LH = cur_tok;
1363 else if((cur_cmd != 10)||(p != mem_top - 13))
1366 if(p != mem_top - 13)
1367 begin_token_list(mem[mem_top - 13].hh.v.RH, 3);
1372 flush_list(mem[mem_top - 13].hh.v.RH);
1376 void mu_error (void)
1378 print_err("Incompatible glue units");
1379 help1("I'm going to assume that 1mu=1pt when they're mixed.");
1382 void scan_eight_bit_int (void)
1385 if((cur_val < 0)||(cur_val > 255))
1387 print_err("Bad register code");
1388 help2("A register number must be between 0 and 255.",
1389 "I changed this one to zero.");
1394 void scan_char_num (void)
1397 if((cur_val < 0)||(cur_val > 255))
1399 print_err("Bad character code");
1400 help2("A character number must be between 0 and 255.",
1401 "I changed this one to zero.");
1406 void scan_four_bit_int (void)
1409 if((cur_val < 0)||(cur_val > 15))
1411 print_err("Bad number");
1412 help2("Since I expected to read a number between 0 and 15,",
1413 "I changed this one to zero.");
1418 void scan_fifteen_bit_int (void)
1421 if((cur_val < 0)||(cur_val > 32767))
1423 print_err("Bad mathchar");
1424 help2("A mathchar number must be between 0 and 32767.",
1425 "I changed this one to zero.");
1430 void scan_twenty_seven_bit_int (void)
1433 if((cur_val < 0)||(cur_val > 134217727L)) /* 2^27 - 1 */
1435 print_err("Bad delimiter code");
1436 help2("A numeric delimiter code must be between 0 and 2^{27}-1.",
1437 "I changed this one to zero.");
1442 void scan_font_ident (void)
1444 internal_font_number f;
1448 } while(!(cur_cmd != 10));
1450 f = eqtb[(hash_size + 1834)].hh.v.RH;
1451 else if(cur_cmd == 87)
1453 else if(cur_cmd == 86)
1456 scan_four_bit_int ();
1457 f = eqtb[m + cur_val].hh.v.RH;
1460 print_err("Missing font identifier");
1461 help2("I was looking for a control sequence whose",
1462 "current meaning has been defined by \\font.");
1468 void find_font_dimen_(bool writing)
1470 internal_font_number f;
1476 /* if(n <= 0)*/ /* change 98/Oct/5 */
1477 if(n < 0 || (n == 0 && font_dimen_zero == 0))
1480 /* else begin if writing and(n<=space_shrink_code)and@|
1481 (n>=space_code)and(font_glue[f]<>null) then
1482 begin delete_glue_ref(font_glue[f]); l.11225 */
1483 if(writing &&(n <= 4)&&(n >= 2)&&(font_glue[f]!= 0))
1485 delete_glue_ref(font_glue[f]);
1486 font_glue[f]= 0; /* font_glue[f]:=null */
1488 if(n > font_params[f])
1493 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1495 if(fmem_ptr == current_font_mem_size) { /* 93/Nov/28 ??? */
1496 font_info = realloc_font_info(increment_font_mem_size);
1498 if(fmem_ptr == current_font_mem_size){ /* 94/Jan/24 */
1499 overflow(818, current_font_mem_size); /* font memory */
1500 return; // abort_flag set
1503 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1504 if(fmem_ptr == font_mem_size){
1505 overflow(818, font_mem_size); /* font memory */
1506 return; // abort_flag set
1509 font_info[fmem_ptr].cint = 0;
1511 incr(font_params[f]);
1512 } while(!(n == font_params[f]));
1513 cur_val = fmem_ptr - 1;
1515 /* else cur_val = n + param_base[f]; */ /* 98/Oct/5 */
1516 else if (n > 0) cur_val = n + param_base[f]; /* 98/Oct/5 */
1517 else cur_val = &font_check[f] - &font_info[0]; /* 98/Oct/5 */
1518 /* checksum = (((font_check[f].b0) << 8 | font_check[f].b1) << 8 |
1519 font_check[f].b2) << 8 | font_check[f].b3; */
1521 /* compiler error: '-' : incompatible types - from 'union fmemoryword *' to 'struct fourunsignedchars *' */
1522 if(cur_val == fmem_ptr){
1524 /* print_esc(hash[(hash_size + 524) + f].v.RH); */
1525 print_esc(hash[(hash_size + hash_extra + 524) + f].v.RH); /*96/Jan/10*/
1526 print(814); /* has only */
1527 print_int(font_params[f]);
1528 print(815); /* fontdimen parameters */
1529 help2("To increase the number of font parameters, you must",
1530 "use \\fontdimen immediately after the \\font is loaded.");
1535 /* NOTE: the above use of /fontdimen0 to access the checksum is a kludge */
1536 /* In future would be better to do this by allocating one more slot for */
1537 /* for parameters when a font is read rather than carry checksum separately */
1538 /* The above gets the value byte order reversed ... 98/Oct/5 */
1540 void scan_something_internal_(small_number level, bool negative)
1549 if(m == (hash_size + 2907))
1551 cur_val = eqtb[(hash_size + 2907) + cur_val].hh.v.RH;
1554 else if(m < (hash_size + 2907))
1556 cur_val = eqtb[m + cur_val].hh.v.RH;
1561 cur_val = eqtb[m + cur_val].cint;
1573 print_err("Missing number, treated as zero");
1574 help3("A number should have been here; I inserted `0'.",
1575 "(If you can't figure out why I needed to see a number,",
1576 "look up `weird error' in the index to The TeXbook.)");
1583 else if(cur_cmd <= 72)
1587 scan_eight_bit_int ();
1588 m = (hash_size + 1322) + cur_val;
1591 cur_val = eqtb[m].hh.v.RH;
1600 /* cur_val = (hash_size + 524) + cur_val; */
1601 cur_val = (hash_size + hash_extra + 524) + cur_val; /* 96/Jan/10 */
1608 cur_val = eqtb[m].cint;
1614 cur_val = eqtb[m].cint;
1620 cur_val = eqtb[m].hh.v.RH;
1626 cur_val = eqtb[m].hh.v.RH;
1633 print_err("Improper ");
1634 print_cmd_chr(79, m); /* O */
1635 help4("You can refer to \\spacefactor only in horizontal mode;",
1636 "you can refer to \\prevdepth only in vertical mode; and",
1637 "neither of these is meaningful inside \\write. So",
1638 "I'm forgetting what you said and using zero instead.");
1652 cur_val = cur_list.aux_field.cint;
1657 cur_val = space_factor;
1669 nest[nest_ptr]= cur_list;
1671 while(abs(nest[p].mode_field)!= 1)decr(p);
1673 cur_val = nest[p].pg_field;
1681 cur_val = dead_cycles;
1682 else cur_val = insert_penalties;
1688 if((page_contents == 0)&&(! output_active))
1690 cur_val = 1073741823L; /* 2^30 - 1 */
1692 else cur_val = page_so_far[m];
1698 if(eqtb[(hash_size + 1312)].hh.v.RH == 0)
1700 else cur_val = mem[eqtb[(hash_size + 1312)].hh.v.RH].hh.v.LH;
1706 scan_eight_bit_int ();
1707 if(eqtb[(hash_size + 1578) + cur_val].hh.v.RH == 0)
1709 else cur_val = mem[eqtb[(hash_size + 1578) + cur_val].hh.v.RH + m].cint;
1722 find_font_dimen(false);
1723 font_info[fmem_ptr].cint = 0;
1725 cur_val = font_info[cur_val].cint;
1734 cur_val = hyphen_char[cur_val];
1739 cur_val = skew_char[cur_val];
1746 scan_eight_bit_int ();
1749 cur_val = eqtb[(hash_size + 3218) + cur_val].cint;
1752 cur_val = eqtb[(hash_size + 3751) + cur_val].cint;
1755 cur_val = eqtb[(hash_size + 800) + cur_val].hh.v.RH;
1758 cur_val = eqtb[(hash_size + 1056) + cur_val].hh.v.RH;
1769 else cur_val = last_badness;
1777 cur_val_level = cur_chr;
1778 if(!(tail >= hi_mem_min)&&(mode != 0)
1782 if(mem[tail].hh.b0 == 12)
1783 cur_val = mem[tail + 1].cint;
1786 if(mem[tail].hh.b0 == 11)
1787 cur_val = mem[tail + 1].cint;
1790 if(mem[tail].hh.b0 == 10)
1792 cur_val = mem[tail + 1].hh.v.LH;
1793 if(mem[tail].hh.b1 == 99)
1798 else if((mode == 1)&&(tail == cur_list
1802 cur_val = last_penalty;
1805 cur_val = last_kern;
1808 /* if(last_glue != 262143L) */ /* NO! */
1809 if(last_glue != empty_flag)
1810 cur_val = last_glue;
1817 print_err("You can't use `");
1818 print_cmd_chr(cur_cmd, cur_chr);
1819 print(683); /* ' after */
1820 print_esc(534); /* the */
1821 help1("I'm forgetting what you said and using zero instead.");
1834 while(cur_val_level > level){
1836 if(cur_val_level == 2)
1837 cur_val = mem[cur_val + 1].cint;
1838 else if(cur_val_level == 3){
1841 decr(cur_val_level);
1844 if(cur_val_level >= 2)
1846 cur_val = new_spec(cur_val);
1848 mem[cur_val + 1].cint = - (integer) mem[cur_val + 1].cint;
1849 mem[cur_val + 2].cint = - (integer) mem[cur_val + 2].cint;
1850 mem[cur_val + 3].cint = - (integer) mem[cur_val + 3].cint;
1853 else cur_val = - (integer) cur_val;
1854 else if((cur_val_level >= 2)&&(cur_val_level <= 3))
1855 incr(mem[cur_val].hh.v.RH);
1858 /*****************************************************************************/
1860 /* Moved here to avoid question about pragma optimize 96/Sep/12 */
1862 /* #pragma optimize ("a", off) */
1864 void get_next (void)
1865 {/* 20 25 21 26 40 10 */
1868 /* char cat; */ /* make this an int ? */
1869 int cat; /* make this an int ? 95/Jan/7 */
1875 if(cur_input.state_field != 0) {
1876 lab25: if(cur_input.loc_field <= cur_input.limit_field) {
1877 cur_chr = buffer[cur_input.loc_field];
1878 incr(cur_input.loc_field);
1879 lab21: cur_cmd = eqtb[(hash_size + 1883) + cur_chr].hh.v.RH;
1880 switch(cur_input.state_field + cur_cmd)
1892 if(cur_input.loc_field > cur_input.limit_field)
1896 lab26: k = cur_input.loc_field;
1897 cur_chr = buffer[k];
1898 cat = eqtb[(hash_size + 1883) + cur_chr].hh.v.RH;
1901 cur_input.state_field = 17;
1903 cur_input.state_field = 17;
1904 else cur_input.state_field = 1;
1905 if((cat == 11)&&(k <= cur_input.limit_field))
1908 cur_chr = buffer[k];
1909 cat = eqtb[(hash_size + 1883) + cur_chr].hh.v.RH;
1911 } while(!((cat != 11)||(k > cur_input.limit_field)))
1914 if(buffer[k]== cur_chr)
1916 if(k < cur_input.limit_field)
1922 if((((c >= 48)&&(c <= 57)) ||((c >= 97)&&
1924 if(k + 2 <= cur_input.limit_field)
1927 if((((cc >= 48)&&(cc <= 57)) ||((cc >= 97
1935 else cur_chr = c - 87;
1937 cur_chr = 16 * cur_chr + cc - 48;
1938 else cur_chr = 16 * cur_chr + cc - 87;
1939 buffer[k - 1]= cur_chr;
1942 buffer[k - 1]= c + 64;
1943 else buffer[k - 1]= c - 64;
1944 cur_input.limit_field = cur_input.limit_field - d;
1946 while(k <= cur_input.limit_field){
1948 buffer[k]= buffer[k + d];
1957 if(k > cur_input.loc_field + 1)
1959 cur_cs = id_lookup(cur_input.loc_field, k - cur_input.loc_field
1961 cur_input.loc_field = k;
1967 if(buffer[k]== cur_chr)
1969 if(k < cur_input.limit_field)
1975 if((((c >= 48)&&(c <= 57)) ||((c >= 97)&&(
1977 if(k + 2 <= cur_input.limit_field)
1980 if((((cc >= 48)&&(cc <= 57)) ||((cc >= 97)
1988 else cur_chr = c - 87;
1989 if(cc <= 57) /* cc may be used without ... */
1990 cur_chr = 16 * cur_chr + cc - 48;
1991 else cur_chr = 16 * cur_chr + cc - 87;
1992 buffer[k - 1]= cur_chr;
1995 buffer[k - 1]= c + 64;
1996 else buffer[k - 1]= c - 64;
1997 cur_input.limit_field = cur_input.limit_field - d;
1999 while(k <= cur_input.limit_field){
2000 buffer[k]= buffer[k + d];
2007 /* cur_cs:=single_base+buffer[loc]; incr(loc); */
2008 cur_cs = 257 + buffer[cur_input.loc_field];
2009 incr(cur_input.loc_field);
2011 lab40: cur_cmd = eqtb[cur_cs].hh.b0;
2012 cur_chr = eqtb[cur_cs].hh.v.RH;
2014 check_outer_validity ();
2022 cur_cs = cur_chr + 1;
2023 cur_cmd = eqtb[cur_cs].hh.b0;
2024 cur_chr = eqtb[cur_cs].hh.v.RH;
2025 cur_input.state_field = 1;
2027 check_outer_validity ();
2035 if(cur_chr == buffer[cur_input.loc_field])
2036 if(cur_input.loc_field < cur_input.limit_field)
2038 c = buffer[cur_input.loc_field + 1];
2041 cur_input.loc_field = cur_input.loc_field + 2;
2042 if((((c >= 48)&&(c <= 57)) ||((c >= 97)&&(c <=
2044 if(cur_input.loc_field <= cur_input.limit_field)
2046 cc = buffer[cur_input.loc_field];
2047 if((((cc >= 48)&&(cc <= 57)) ||((cc >= 97)&&(
2050 incr(cur_input.loc_field);
2053 else cur_chr = c - 87;
2055 cur_chr = 16 * cur_chr + cc - 48;
2056 else cur_chr = 16 * cur_chr + cc - 87;
2062 else cur_chr = c - 64;
2066 cur_input.state_field = 1;
2073 print_err("Text line contains an invalid character");
2074 help2("A funny symbol that I can't read has just been input.",
2075 "Continue, and I'll forget that it ever happened.");
2076 deletions_allowed = false;
2078 deletions_allowed = true;
2084 cur_input.state_field = 17;
2090 cur_input.loc_field = cur_input.limit_field + 1;
2100 cur_input.loc_field = cur_input.limit_field + 1;
2106 cur_input.loc_field = cur_input.limit_field + 1;
2108 cur_cmd = eqtb[cur_cs].hh.b0;
2109 cur_chr = eqtb[cur_cs].hh.v.RH;
2111 check_outer_validity ();
2121 cur_input.state_field = 1;
2131 cur_input.state_field = 1;
2147 cur_input.state_field = 1;
2155 cur_input.state_field = 33;
2156 if(cur_input.name_field > 17) {
2158 first = cur_input.start_field;
2160 if(input_ln(input_file[cur_input.index_field], true)) {
2161 firm_up_the_line ();
2163 else force_eof = true;
2166 print_char(41); /*)*/
2172 end_file_reading ();
2173 check_outer_validity ();
2176 if((eqtb[(hash_size + 3211)].cint < 0)||
2177 (eqtb[(hash_size + 3211)].cint > 255))
2178 decr(cur_input.limit_field);
2179 /* long to unsigned char ... */
2180 else buffer[cur_input.limit_field]= eqtb[(hash_size + 3211)].cint;
2181 first = cur_input.limit_field + 1;
2182 cur_input.loc_field = cur_input.start_field;
2185 if(!(cur_input.name_field == 0)) {
2191 end_file_reading ();
2194 if(selector < 18) open_log_file ();
2195 if(interaction > 1){
2196 if((eqtb[(hash_size + 3211)].cint < 0)||
2197 (eqtb[(hash_size + 3211)].cint > 255)
2199 incr(cur_input.limit_field);
2200 if(cur_input.limit_field == cur_input.start_field)
2201 print_nl("(Please type a command or say `\\end')"); /* */
2203 first = cur_input.start_field;
2209 cur_input.limit_field = last;
2210 if((eqtb[(hash_size + 3211)].cint < 0)||
2211 (eqtb[(hash_size + 3211)].cint > 255)
2213 decr(cur_input.limit_field);
2214 /* long to unsigned char ... */
2215 else buffer[cur_input.limit_field]= eqtb[(hash_size + 3211)].cint;
2216 first = cur_input.limit_field + 1;
2217 cur_input.loc_field = cur_input.start_field;
2220 fatal_error("*** (job aborted, no legal \\end found)"); /* */
2221 return; // abort_flag set
2226 pause_for_instructions ();
2232 else if(cur_input.loc_field != 0)
2234 t = mem[cur_input.loc_field].hh.v.LH;
2235 cur_input.loc_field = mem[cur_input.loc_field].hh.v.RH;
2239 cur_cmd = eqtb[cur_cs].hh.b0;
2240 cur_chr = eqtb[cur_cs].hh.v.RH;
2244 cur_cs = mem[cur_input.loc_field].hh.v.LH - 4095;
2245 cur_input.loc_field = 0;
2246 cur_cmd = eqtb[cur_cs].hh.b0;
2247 cur_chr = eqtb[cur_cs].hh.v.RH;
2255 check_outer_validity ();
2261 /* cur_cmd = t >> 8; */ /* top 8 bits */
2263 /* cur_chr = t & 255; */ /* last 8 bits */
2273 begin_token_list(param_stack[cur_input.limit_field + cur_chr - 1],
2290 if(align_state == 0)
2292 if(scanner_status == 4){
2293 fatal_error("(interwoven alignment preambles are not allowed)"); /* */
2294 return; // abort_flag set
2297 cur_cmd = mem[cur_align + 5].hh.v.LH;
2298 mem[cur_align + 5].hh.v.LH = cur_chr;
2300 begin_token_list(mem_top - 10, 2);
2301 else begin_token_list(mem[cur_align + 2].cint, 2);
2302 align_state = 1000000L;
2307 #pragma optimize ("", on) /* 96/Sep/12 */
2309 /*****************************************************************************/