OSDN Git Service

confusion: str_number -> char *.
[putex/putex.git] / src / texsourc / tex7.c
1 #ifdef _WINDOWS
2   #define NOCOMM
3   #define NOSOUND
4   #define NODRIVERS
5   #define STRICT
6   #pragma warning(disable:4115) // kill rpcasync.h complaint
7   #include <windows.h>
8   #define MYLIBAPI __declspec(dllexport)
9 #endif
10
11 #include "texwin.h"
12
13 #pragma warning(disable:4131) // old style declarator
14 #pragma warning(disable:4135) // conversion between different integral types 
15 #pragma warning(disable:4127) // conditional expression is constant
16
17 #include <setjmp.h>
18
19 #define EXTERN extern
20
21 #include "texd.h"
22
23 #pragma warning(disable:4244)       /* 96/Jan/10 */
24
25 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
26 /* sec 0944 */
27 void build_page (void) 
28 {
29   halfword p; 
30   halfword q, r; 
31   integer b, c; 
32   integer pi; 
33 /*  unsigned char n;  */
34   unsigned int n;             /* 95/Jan/7 */
35   scaled delta, h, w; 
36
37 /* begin if (link(contrib_head)=null)or output_active then return; l.19351 */
38   if ((mem[contrib_head].hh.v.RH == 0)|| output_active)
39     return; 
40   do {
41       lab22: p = mem[contrib_head].hh.v.RH; 
42 /*    if (last_glue != 262143L) */
43     if (last_glue != empty_flag)
44       delete_glue_ref(last_glue);
45     last_penalty = 0;
46     last_kern = 0;
47     if (mem[p].hh.b0 == 10)
48     {
49       last_glue = mem[p + 1].hh.v.LH; 
50       incr(mem[last_glue].hh.v.RH); 
51     } 
52     else {
53   
54 /*      last_glue = 262143L;  */
55       last_glue = empty_flag; 
56       if (mem[p].hh.b0 == 12)
57         last_penalty = mem[p + 1].cint; 
58       else if (mem[p].hh.b0 == 11)
59         last_kern = mem[p + 1].cint; 
60     } 
61     switch(mem[p].hh.b0)
62     {
63       case 0 :
64       case 1 :
65       case 2 :
66         if (page_contents < 2)
67         {
68           if (page_contents == 0)
69             freeze_page_specs(2);
70           else
71             page_contents = 2;
72           q = new_skip_param(9);
73           if (mem[temp_ptr + 1].cint > mem[p + 3].cint)
74             mem[temp_ptr + 1].cint = mem[temp_ptr + 1].cint - mem[p + 3].cint;
75           else
76             mem[temp_ptr + 1].cint = 0;
77           mem[q].hh.v.RH = p;
78           mem[contrib_head].hh.v.RH = q;
79           goto lab22;
80       } 
81       else {
82         page_so_far[1]= page_so_far[1]+ page_so_far[7]+ mem[p + 3].cint;
83         page_so_far[7]= mem[p + 2].cint; 
84         goto lab80; 
85       } 
86       break; 
87     case 8 :
88       goto lab80;
89       break; 
90     case 10 :
91       if (page_contents < 2)
92         goto lab31; 
93       else if ((mem[page_tail].hh.b0 < 9)) 
94         pi = 0; 
95       else
96         goto lab90; 
97       break;
98     case 11 : 
99       if (page_contents < 2)
100         goto lab31;
101       else if (mem[p].hh.v.RH == 0)
102         return; 
103       else if (mem[mem[p].hh.v.RH].hh.b0 == 10)
104         pi = 0; 
105       else
106         goto lab90;
107       break; 
108     case 12 : 
109       if (page_contents < 2)
110         goto lab31; 
111       else
112         pi = mem[p + 1].cint; 
113       break; 
114     case 4 : 
115       goto lab80; 
116       break; 
117     case 3 : 
118       {
119         if (page_contents == 0)
120           freeze_page_specs(1);
121         n = mem[p].hh.b1;
122         r = mem_top;
123         while(n >= mem[mem[r].hh.v.RH].hh.b1)
124           r = mem[r].hh.v.RH;
125         n = n; 
126         if (mem[r].hh.b1 != n)
127         {
128           q = get_node(4);
129           mem[q].hh.v.RH = mem[r].hh.v.RH;
130           mem[r].hh.v.RH = q; 
131           r = q;
132           mem[r].hh.b1 = n;
133           mem[r].hh.b0 = 0;
134           ensure_vbox(n);
135           if (eqtb[(hash_size + 1578) + n].hh.v.RH == 0)
136             mem[r + 3].cint = 0; 
137           else
138             mem[r + 3].cint = mem[eqtb[(hash_size + 1578) + n].hh.v.RH + 3].cint + mem[eqtb[(hash_size + 1578) + n].hh.v.RH + 2].cint; 
139           mem[r + 2].hh.v.LH = 0; 
140           q = eqtb[(hash_size + 800) + n].hh.v.RH;
141           if (eqtb[(hash_size + 3218) + n].cint == 1000)
142             h = mem[r + 3].cint; 
143           else
144             h = x_over_n(mem[r + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint; 
145           page_so_far[0]= page_so_far[0]- h - mem[q + 1].cint; 
146           page_so_far[2 + mem[q].hh.b0]= page_so_far[2 + mem[q].hh.b0]+ mem[q + 2].cint; 
147           page_so_far[6]= page_so_far[6]+ mem[q + 3].cint; 
148           if ((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0)) 
149           {
150                         print_err("Infinite glue shrinkage inserted from");
151             print_esc("skip");
152             print_int(n);
153                         help3("The correction glue for page breaking with insertions",
154                                 "must have finite shrinkability. But you may proceed,",
155                                 "since the offensive shrinkability has been made finite."); 
156             error (); 
157           } 
158         } 
159         if (mem[r].hh.b0 == 1)
160           insert_penalties = insert_penalties + mem[p + 1].cint; 
161         else {
162           mem[r + 2].hh.v.RH = p;
163           delta = page_so_far[0]- page_so_far[1]- page_so_far[7] + page_so_far[6];
164           if (eqtb[(hash_size + 3218) + n].cint == 1000)
165             h = mem[p + 3].cint; 
166           else
167             h = x_over_n(mem[p + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint;
168           if (((h <= 0)||(h <= delta)) &&(mem[p + 3].cint + mem[r + 3].cint <= eqtb[(hash_size + 3751) + n].cint))
169           {
170             page_so_far[0]= page_so_far[0]- h; 
171             mem[r + 3].cint = mem[r + 3].cint + mem[p + 3].cint; 
172           } 
173           else {
174             if (eqtb[(hash_size + 3218) + n].cint <= 0)
175               w = 1073741823L;  /* 2^30 - 1 */
176             else {
177               w = page_so_far[0]- page_so_far[1]- page_so_far[7];
178               if (eqtb[(hash_size + 3218) + n].cint != 1000)
179                 w = x_over_n(w, eqtb[(hash_size + 3218) + n].cint)* 1000;
180             } 
181             if (w > eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint)
182               w = eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint; 
183             q = vert_break(mem[p + 4].hh.v.LH, w, mem[p + 2].cint); 
184             mem[r + 3].cint = mem[r + 3].cint + best_height_plus_depth;
185             ;
186 #ifdef STAT
187             if (eqtb[(hash_size + 3196)].cint > 0)
188             {
189               begin_diagnostic (); 
190               print_nl("% split");
191               print_int(n); 
192               print_string(" to");
193               print_scaled(w); 
194               print_char(',');
195               print_scaled(best_height_plus_depth); 
196               print_string(" p=");
197               if (q == 0)    /* if q=null l.19614 */
198                 print_int(-10000); 
199               else if (mem[q].hh.b0 == 12)
200                 print_int(mem[q + 1].cint); 
201               else print_char('0');
202               end_diagnostic(false); 
203             } 
204 #endif /* STAT */
205             if (eqtb[(hash_size + 3218) + n].cint != 1000)
206               best_height_plus_depth = x_over_n(best_height_plus_depth, 1000) * eqtb[(hash_size + 3218) + n].cint; 
207             page_so_far[0]= page_so_far[0]- best_height_plus_depth; 
208             mem[r].hh.b0 = 1; 
209             mem[r + 1].hh.v.RH = q; 
210             mem[r + 1].hh.v.LH = p; 
211             if (q == 0)
212               insert_penalties = insert_penalties - 10000; 
213             else if (mem[q].hh.b0 == 12)
214               insert_penalties = insert_penalties + mem[q + 1].cint; 
215           } 
216         } 
217         goto lab80; 
218       } 
219       break; 
220     default:
221       {
222         confusion("page");
223         return;       // abort_flag set
224       }
225       break; 
226     } 
227     if (pi < 10000)/* pi may be used ... */
228     {
229       if (page_so_far[1]< page_so_far[0])
230         if ((page_so_far[3]!= 0)||(page_so_far[4]!= 0)||(page_so_far[5]!= 0)) 
231           b = 0; 
232         else
233           b = badness(page_so_far[0]- page_so_far[1], page_so_far[2]);
234       else if (page_so_far[1]- page_so_far[0]> page_so_far[6])
235         b = 1073741823L;  /* 2^30 - 1 */
236       else
237         b = badness(page_so_far[1]- page_so_far[0], page_so_far[6]);
238       if (b < 1073741823L) /* 2^30 - 1 */
239         if (pi <= -10000)
240           c = pi; 
241         else if (b < 10000)
242           c = b + pi + insert_penalties; 
243         else
244           c = 100000L; 
245       else
246         c = b; 
247       if (insert_penalties >= 10000)
248         c = 1073741823L;  /* 2^30 - 1 */
249       ;
250 #ifdef STAT
251       if (eqtb[(hash_size + 3196)].cint > 0)
252       {
253         begin_diagnostic (); 
254         print_nl("%");
255         print_string(" t=");
256         print_totals (); 
257         print_string(" g=");
258         print_scaled(page_so_far[0]); 
259         print_string(" b=");
260         if (b == 1073741823L) /* 2^30 - 1 */
261           print_char('*');
262         else
263           print_int(b); 
264         print_string(" p=");
265         print_int(pi); 
266         print_string(" c=");
267         if (c == 1073741823L) /* 2^30 - 1 */
268           print_char('*');
269         else print_int(c); 
270         if (c <= least_page_cost)
271                   print_char('#');
272         end_diagnostic(false); 
273       } 
274 #endif /* STAT */
275       if (c <= least_page_cost)
276       {
277   best_page_break = p; 
278   best_size = page_so_far[0]; 
279   least_page_cost = c; 
280   r = mem[mem_top].hh.v.RH; 
281   while (r != mem_top) {
282     mem[r + 2].hh.v.LH = mem[r + 2].hh.v.RH; 
283     r = mem[r].hh.v.RH; 
284   } 
285       } 
286       if ((c == 1073741823L)||(pi <= -10000))  /* 2^30 - 1 */
287       {
288   fire_up(p); 
289   if (output_active)return; 
290   goto lab30; 
291       } 
292     } 
293     if ((mem[p].hh.b0 < 10)||(mem[p].hh.b0 > 11)) 
294     goto lab80; 
295     lab90: if (mem[p].hh.b0 == 11)
296     q = p; 
297     else {
298       q = mem[p + 1].hh.v.LH; 
299       page_so_far[2 + mem[q].hh.b0]= page_so_far[2 + mem[q].hh.b0]
300       + mem[q + 2].cint; 
301       page_so_far[6]= page_so_far[6]+ mem[q + 3].cint; 
302       if ((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0)) 
303       {
304                   print_err("Infinite glue shrinkage found on current page");
305                   help4("The page about to be output contains some infinitely",
306                           "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
307                           "Such glue doesn't belong there; but you can safely proceed,",
308                           "since the offensive shrinkability has been made finite.");
309   error (); 
310   r = new_spec(q); 
311   mem[r].hh.b1 = 0; 
312   delete_glue_ref(q); 
313   mem[p + 1].hh.v.LH = r; 
314   q = r; 
315       } 
316     } 
317     page_so_far[1]= page_so_far[1]+ page_so_far[7]+ mem[q + 1].cint 
318  ; 
319     page_so_far[7]= 0; 
320     lab80: if (page_so_far[7]> page_max_depth)
321     {
322       page_so_far[1]= page_so_far[1]+ page_so_far[7]- page_max_depth; 
323       page_so_far[7]= page_max_depth; 
324     } 
325     mem[page_tail].hh.v.RH = p; 
326     page_tail = p; 
327     mem[contrib_head].hh.v.RH = mem[p].hh.v.RH; 
328     mem[p].hh.v.RH = 0; 
329     goto lab30; 
330     lab31: mem[contrib_head].hh.v.RH = mem[p].hh.v.RH; 
331     mem[p].hh.v.RH = 0; 
332     flush_node_list(p); 
333     lab30:; 
334   } while(!(mem[contrib_head].hh.v.RH == 0)); 
335   if (nest_ptr == 0)
336   tail = contrib_head; 
337   else nest[0].tail_field = contrib_head; 
338
339 /* sec 1043 */
340 void app_space (void) 
341
342   halfword q; 
343   if ((space_factor >= 2000) && (eqtb[(hash_size + 795)].hh.v.RH != 0)) 
344   q = new_param_glue(13); 
345   else {      
346     if (eqtb[(hash_size + 794)].hh.v.RH != 0)
347     main_p = eqtb[(hash_size + 794)].hh.v.RH; 
348     else {  
349       main_p = font_glue[eqtb[(hash_size + 1834)].hh.v.RH]; 
350       if (main_p == 0)
351       {
352   main_p = new_spec(0); 
353   main_k = param_base[eqtb[(hash_size + 1834)].hh.v.RH]+ 2; 
354   mem[main_p + 1].cint = font_info[main_k].cint; 
355   mem[main_p + 2].cint = font_info[main_k + 1].cint; 
356   mem[main_p + 3].cint = font_info[main_k + 2].cint; 
357   font_glue[eqtb[(hash_size + 1834)].hh.v.RH]= main_p; 
358       } 
359     } 
360     main_p = new_spec(main_p); 
361     if (space_factor >= 2000)
362     mem[main_p + 1].cint = mem[main_p + 1].cint + font_info[7 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint; 
363     mem[main_p + 2].cint = xn_over_d(mem[main_p + 2].cint, cur_list.aux_field.hh.v.LH, 1000); 
364     mem[main_p + 3].cint = xn_over_d(mem[main_p + 3].cint, 1000, space_factor); 
365     q = new_glue(main_p); 
366     mem[main_p].hh.v.RH = 0; 
367   } 
368   mem[tail].hh.v.RH = q; 
369   tail = q; 
370
371 /* called from tex8.c only */
372 /* sec 1047 */
373 void insert_dollar_sign (void) 
374
375   back_input (); 
376   cur_tok = 804;
377   print_err("Proceed; I'll discard its present contents.");
378   help2("I've inserted a begin-math/end-math symbol since I think",
379           "you left one out. Proceed, with fingers crossed.");
380   ins_error (); 
381
382 /* sec 1049 */
383 void you_cant (void) 
384 {
385   print_err("You can't use `");
386   print_cmd_chr(cur_cmd, cur_chr); 
387   print_string("' in ");
388   print_mode(mode); 
389
390 /* sec 1050 */
391 void report_illegal_case (void) 
392
393   you_cant ();
394   help4("Sorry, but I'm not programmed to handle this case;",
395           "I'll just pretend that you didn't ask for it.",
396           "If you're in the wrong mode, you might be able to",
397           "return to the right one by typing `I}' or `I$' or `I\\par'.");
398   error (); 
399
400 /* sec 1051 */
401 bool privileged (void) 
402 {
403   register bool Result; 
404   if (mode > 0)Result = true; 
405   else {
406     report_illegal_case (); 
407     Result = false; 
408   } 
409   return Result; 
410
411 /* sec 1054 */
412 bool its_all_over (void) 
413 {/* 10 */
414   register bool Result; 
415   if (privileged ())
416   {
417     if ((page_head == page_tail) && (head == cur_list.tail_field) && (dead_cycles == 0)) 
418     {
419       Result = true; 
420       return(Result); 
421     } 
422     back_input (); 
423     {
424       mem[tail].hh.v.RH = new_null_box (); 
425       tail = mem[tail].hh.v.RH; 
426     } 
427     mem[tail + 1].cint = eqtb[(hash_size + 3733)].cint; 
428     {
429       mem[tail].hh.v.RH = new_glue(8); 
430       tail = mem[tail].hh.v.RH; 
431     } 
432     {
433       mem[tail].hh.v.RH = new_penalty(-1073741824L); 
434     /* - 2^30  */
435       tail = mem[tail].hh.v.RH; 
436     } 
437     build_page (); 
438   } 
439   Result = false; 
440   return Result; 
441
442 /* sec 1060 */
443 void append_glue (void)
444 {
445   small_number s; 
446   s = cur_chr; 
447   switch(s)
448   {case 0 : 
449       cur_val = 4; 
450   break; 
451   case 1 : 
452     cur_val = 8; 
453     break; 
454   case 2 : 
455     cur_val = 12; 
456     break; 
457   case 3 : 
458     cur_val = 16; 
459     break; 
460   case 4 : 
461     scan_glue(2); 
462         break; 
463   case 5 : 
464     scan_glue(3); 
465         break; 
466   } 
467   {
468     mem[tail].hh.v.RH = new_glue(cur_val); 
469     tail = mem[tail].hh.v.RH; 
470   } 
471   if (s >= 4)
472   {
473     decr(mem[cur_val].hh.v.RH); 
474     if (s > 4)
475       mem[tail].hh.b1 = 99; 
476   } 
477
478 /* sec 1161 */
479 void append_kern (void)
480
481   quarterword s; 
482   s = cur_chr; 
483   scan_dimen(s == 99, false, false); 
484   {
485     mem[tail].hh.v.RH = new_kern(cur_val); 
486     tail = mem[tail].hh.v.RH; 
487   } 
488   mem[tail].hh.b1 = s; 
489
490 /* sec 1054 */
491 void off_save (void) 
492
493   halfword p; 
494   if (cur_group == 0)
495   {
496         print_err("Extra ");
497     print_cmd_chr(cur_cmd, cur_chr);
498         help1("Things are pretty mixed up, but I think the worst is over.");
499     error (); 
500   } else {
501     back_input (); 
502     p = get_avail (); 
503     mem[temp_head].hh.v.RH = p; 
504         print_err("Missing ");
505     switch(cur_group)
506     {case 14 : 
507       {
508 /*  mem[p].hh.v.LH = (hash_size + 4611);  */
509 /*  mem[p].hh.v.LH = (hash_size + 4095 + 516);  */
510   mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 516); /* 96/Jan/10 */
511   print_esc("endgroup");
512       } 
513       break; 
514     case 15 : 
515       {
516   mem[p].hh.v.LH = 804; 
517   print_char('$'); 
518       } 
519       break; 
520     case 16 : 
521       {
522 /*  mem[p].hh.v.LH = (hash_size + 4612);  */
523 /*  mem[p].hh.v.LH = (hash_size + 4095 + 517);  */
524   mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 517); /* 96/Jan/10 */
525   mem[p].hh.v.RH = get_avail (); 
526   p = mem[p].hh.v.RH; 
527   mem[p].hh.v.LH = 3118; 
528   print_esc("right.");
529       } 
530       break; 
531       default: 
532       {
533   mem[p].hh.v.LH = 637; 
534   print_char('}');
535       } 
536       break; 
537     } 
538     print_string(" inserted");
539     begin_token_list(mem[temp_head].hh.v.RH, 4);
540         help5("I've inserted something that you may have forgotten.",
541                 "(See the <inserted text> above.)",
542                 "With luck, this will get me unwedged. But if you",
543                 "really didn't forget anything, try typing `2' now; then",
544                 "my insertion and my current dilemma will both disappear.");
545     error (); 
546   } 
547
548 /* only called from tex8.c */
549 /* sec 1069 */
550 void extra_right_brace (void) 
551 {
552   print_err("Extra }, or forgotten");
553   switch(cur_group)
554   {case 14 : 
555     print_esc("endgroup");
556     break; 
557   case 15 : 
558     print_char('$');
559     break; 
560   case 16 : 
561     print_esc("right");
562     break; 
563   }
564   help5("I've deleted a group-closing symbol because it seems to be",
565           "spurious, as in `$x}$'. But perhaps the } is legitimate and",
566           "you forgot something else, as in `\\hbox{$x}'. In such cases",
567           "the way to recover is to insert both the forgotten and the",
568           "deleted material, e.g., by typing `I$}'."); 
569   error (); 
570   incr(align_state); 
571
572 /* sec 1070 */
573 void normal_paragraph (void) 
574
575 /* if looseness<>0 then eq_word_define(int_base+looseness_code,0); */
576   if (eqtb[(hash_size + 3182)].cint != 0)
577   eq_word_define((hash_size + 3182), 0); 
578   if (eqtb[(hash_size + 3747)].cint != 0)
579   eq_word_define((hash_size + 3747), 0); 
580   if (eqtb[(hash_size + 3204)].cint != 1)
581   eq_word_define((hash_size + 3204), 1); 
582   if (eqtb[(hash_size + 1312)].hh.v.RH != 0)
583   eq_define((hash_size + 1312), 118, 0); 
584
585 /* sec 1075 */
586 void box_end_(integer boxcontext)
587 {
588   halfword p; 
589 /* if box_context<box_flag then ... 1073741824 2^30 */
590   if (boxcontext < 1073741824L)
591   {
592     if (cur_box != 0)
593     {
594       mem[cur_box + 4].cint = boxcontext; 
595       if (abs(mode)== 1)
596       {
597   append_to_vlist(cur_box); 
598   if (adjust_tail != 0)
599   {
600     if (adjust_head != adjust_tail)
601     {
602       mem[tail].hh.v.RH = mem[adjust_head].hh 
603      .v.RH; 
604       tail = adjust_tail; 
605     } 
606     adjust_tail = 0; 
607   } 
608   if (mode > 0){
609     build_page ();
610   }
611       } 
612       else {
613   if (abs(mode)== 102)
614   space_factor = 1000; 
615   else {
616       
617     p = new_noad (); 
618     mem[p + 1].hh.v.RH = 2; 
619     mem[p + 1].hh.v.LH = cur_box; 
620     cur_box = p; 
621   } 
622   mem[tail].hh.v.RH = cur_box; 
623   tail = cur_box; 
624       } 
625     } 
626   } 
627
628 /* following fixed 1994/Apr/5 1 day anno Yang --- moby sigh ... */
629
630 /* else if box_context<box_flag+512 then ... */
631 /*  else if (boxcontext < 1073742336L)*/   /* 2^30 + 512 */ 
632   else if (boxcontext < (1073741824L + 512))   /* 2^30 + 512 */ 
633 /* else if box_context<box_flag+256 then ... */
634 /*  if (boxcontext < 1073742080L)*/ /* 2^30 + 256 */ 
635   if (boxcontext < (1073741824L + 256))/* 2^30 + 256 */ 
636 /* eq_define(box_base-box_flag+box_context,box_ref,cur_box) */
637 /* eq_define((hash_size - 1073740246L) + boxcontext, 119, cur_box); */
638   eq_define((hash_size + 1578 - 1073741824L) + boxcontext, 119, cur_box); 
639 /* else geq_define(box_base-box_flag-256+box_context,box_ref,cur_box) */
640 /* else geq_define((hash_size - 1073740502L) + boxcontext, 119, cur_box); */
641   else geq_define((hash_size + 1322 - 1073741824L) + boxcontext, 119, cur_box); 
642   else if (cur_box != 0)
643 /*  if (boxcontext > 1073742336L)*/  /* 2^30 + 512 */ 
644   if (boxcontext > (1073741824L + 512)) /* 2^30 + 512 */ 
645   {
646     do {
647     get_x_token (); 
648     } while(!((cur_cmd != 10)&&(cur_cmd != 0))); 
649 /* 424 in tex82.bug */
650     if (((cur_cmd == 26) && (abs(mode)!= 1)) ||
651                 ((cur_cmd == 27) && (abs(mode)== 1)))
652     {
653 /*   begin append_glue; subtype(tail):=box_context-(leader_flag-a_leaders); */
654       append_glue (); 
655 /*      -(2^30 + 513 - 100)  */
656       mem[tail].hh.b1 = boxcontext -(1073742237L); 
657       mem[tail + 1].hh.v.RH = cur_box; 
658     } 
659     else {
660     print_err("Leaders not followed by proper glue");
661         help3("You should say `\\leaders <box or rule><hskip or vskip>'.",
662                 "I found the <box or rule>, but there's no suitable",
663                 "<hskip or vskip>, so I'm ignoring these leaders."); 
664       back_error (); 
665       flush_node_list(cur_box); 
666   }
667   }
668   else ship_out(cur_box); 
669
670 /* called only from tex8.c */
671 /* sec 1079 */
672 void begin_box_(integer boxcontext)
673 {/* 10 30 */
674   halfword p, q; 
675   quarterword m; 
676   halfword k; 
677   eight_bits n; 
678   switch(cur_chr){
679   case 0 : 
680     {
681       scan_eight_bit_int (); 
682       cur_box = eqtb[(hash_size + 1578) + cur_val].hh.v.RH; 
683       eqtb[(hash_size + 1578) + cur_val].hh.v.RH = 0; 
684     } 
685     break; 
686   case 1 : 
687     {
688       scan_eight_bit_int (); 
689       cur_box = copy_node_list(eqtb[(hash_size + 1578) + cur_val].hh.v.RH); 
690     } 
691     break; 
692   case 2 : 
693     {
694       cur_box = 0; 
695       if (abs(mode)== 203)
696       {
697   you_cant ();
698   help1("Sorry; this \\lastbox will be void.");
699   error (); 
700       } 
701       else if ((mode == 1)&&(head == cur_list 
702      .tail_field)) 
703       {
704   you_cant ();
705   help2("Sorry...I usually can't take things from the current page.",
706           "This \\lastbox will therefore be void.");
707   error (); 
708       } 
709       else {
710   if (!(tail >= hi_mem_min)) 
711   if ((mem[tail].hh.b0 == 0)||(mem[cur_list 
712  .tail_field].hh.b0 == 1)) 
713   {
714     q = head; 
715     do {
716         p = q; 
717       if (!(q >= hi_mem_min)) 
718       if (mem[q].hh.b0 == 7)
719       {
720         {
721         register integer for_end; 
722         m = 1; 
723         for_end = mem[q].hh.b1; 
724         if (m <= for_end) do 
725           p = mem[p].hh.v.RH; 
726         while(m++ < for_end);
727       } 
728         if (p == tail)
729         goto lab30; 
730       } 
731       q = mem[p].hh.v.RH; 
732     } while(!(q == tail)); 
733     cur_box = tail; 
734     mem[cur_box + 4].cint = 0; 
735     tail = p; 
736     mem[p].hh.v.RH = 0; 
737     lab30:; 
738   } 
739       } 
740     } 
741     break; 
742   case 3 : 
743     {
744       scan_eight_bit_int (); 
745       n = cur_val; 
746       if (! scan_keyword("to"))  /* to */
747       {
748                   print_err("Missing `to' inserted");
749                   help2("I'm working on `\\vsplit<box number> to <dimen>';",
750                           "will look for the <dimen> next.");
751   error (); 
752       } 
753       scan_dimen(false, false, false); 
754       cur_box = vsplit(n, cur_val); 
755     } 
756     break; 
757     default: 
758     {
759       k = cur_chr - 4; 
760       save_stack[save_ptr + 0].cint = boxcontext; 
761       if (k == 102)
762       if ((boxcontext < 1073741824L)&& /* 2^30 */
763       (abs(mode)== 1)
764     )
765       scan_spec(3, true); 
766       else scan_spec(2, true); 
767       else {
768     
769   if (k == 1)
770   scan_spec(4, true); 
771   else {
772       
773     scan_spec(5, true); 
774     k = 1; 
775   } 
776   normal_paragraph (); 
777       } 
778       push_nest (); 
779       mode = - (integer) k; 
780       if (k == 1)
781       {
782   cur_list.aux_field.cint = ignore_depth; 
783   if (eqtb[(hash_size + 1318)].hh.v.RH != 0)/* everyhbox */
784   begin_token_list(eqtb[(hash_size + 1318)].hh.v.RH, 11); 
785       } 
786       else {
787     
788   space_factor = 1000; 
789   if (eqtb[(hash_size + 1317)].hh.v.RH != 0)/* everyhbox */
790     begin_token_list(eqtb[(hash_size + 1317)].hh.v.RH, 10); 
791       } 
792       return; 
793     } 
794     break; 
795   } 
796   box_end(boxcontext); 
797
798 /* sec 1084 */
799 void scan_box_(integer boxcontext)
800
801   do {
802       get_x_token (); 
803   } while(!((cur_cmd != 10)&&(cur_cmd != 0))); 
804   if (cur_cmd == 20){
805     begin_box(boxcontext);
806   }
807   else if ((boxcontext >= 1073742337L)&& /* (2^30 + 512 + 1)  */
808      ((cur_cmd == 36)||(cur_cmd == 35)))
809   {
810     cur_box = scan_rule_spec (); 
811     box_end(boxcontext); 
812   } 
813   else {
814       print_err("A <box> was supposed to be here");
815           help3("I was expecting to see \\hbox or \\vbox or \\copy or \\box or",
816                   "something like that. So you might find something missing in",
817                   "your output. But keep trying; you can fix this later.");
818     back_error (); 
819   }
820
821 /****************************************************************************/
822 void package_ (small_number);
823 /****************************************************************************/
824 /* sec 1091 */
825 small_number norm_min_ (integer h) 
826 {register
827 /*  small_number Result; */
828   int Result;               /* 95/Jan/7 */
829   if (h <= 0)
830     Result = 1; 
831   else if (h >= 63)
832     Result = 63; 
833   else Result = h; 
834   return Result; 
835
836 /* sec 1091 */
837 void new_graf_(bool indented)
838
839   prev_graf = 0; 
840   if ((mode == 1)||(head != cur_list 
841  .tail_field)) 
842   {
843     mem[tail].hh.v.RH = new_param_glue(2); 
844     tail = mem[tail].hh.v.RH; 
845   } 
846 /* used to be followingin 3.141 */
847 /*  cur_list .lhmfield = norm_min(eqtb[(hash_size + 3214)].cint); */
848 /*  cur_list .rhmfield = norm_min(eqtb[(hash_size + 3215)].cint); */
849   push_nest (); 
850   mode = 102; 
851   space_factor = 1000; 
852 /* changes here since 3.141 */
853   if (eqtb[(hash_size + 3213)].cint <= 0)
854   cur_lang = 0; 
855   else if (eqtb[(hash_size + 3213)].cint > 255)
856   cur_lang = 0; 
857   else cur_lang = eqtb[(hash_size + 3213)].cint; 
858   clang = cur_lang; 
859   prev_graf =(norm_min(eqtb[(hash_size + 3214)].cint)* 64 + 
860      norm_min(eqtb[(hash_size + 3215)].cint)) * 65536L + cur_lang; 
861 /* eqtb ??? hash_size ? hash_size + hash_extra ? norm_min etc */
862 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
863   if (indented)
864   {
865     tail = new_null_box (); 
866     mem[head].hh.v.RH = tail; 
867     mem[tail + 1].cint = eqtb[(hash_size + 3730)].cint; 
868   } 
869   if (eqtb[(hash_size + 1314)].hh.v.RH != 0)  /* everypar */
870     begin_token_list(eqtb[(hash_size + 1314)].hh.v.RH, 7); 
871   if (nest_ptr == 1){
872     build_page ();
873   }
874
875 /* procedure indent_in_hmode; l.21058 */
876 /* sec 1093 */
877 void indent_in_hmode (void) 
878
879   halfword p, q; 
880   if (cur_chr > 0)
881   {
882     p = new_null_box (); 
883     mem[p + 1].cint = eqtb[(hash_size + 3730)].cint; 
884     if (abs(mode)== 102)
885     space_factor = 1000; 
886     else {
887   
888       q = new_noad (); 
889       mem[q + 1].hh.v.RH = 2; 
890       mem[q + 1].hh.v.LH = p; 
891       p = q; 
892     } 
893     {
894       mem[tail].hh.v.RH = p; 
895       tail = mem[tail].hh.v.RH; 
896     } 
897   } 
898
899 /* only called from tex8.c */
900 /* sec 1095 */
901 void head_for_vmode (void) 
902
903   if (mode < 0)
904   if (cur_cmd != 36){
905     off_save ();
906   }
907   else {
908           print_err("You can't use `");
909     print_esc("hrule");
910     print_string("' here except with leaders");
911         help2("To put a horizontal rule in an hbox or an alignment,",
912                 "you should use \\leaders or \\hrulefill (see The TeXbook).");
913     error (); 
914   } 
915   else {
916       
917     back_input (); 
918     cur_tok = par_token; 
919     back_input (); 
920     cur_input.index_field = 4; 
921   } 
922
923 /* sec 1096 */
924 void end_graf (void) 
925 {
926   if (mode == 102)
927   {
928     if (head == tail)
929     pop_nest (); 
930     else line_break(eqtb[(hash_size + 3169)].cint); 
931     normal_paragraph (); 
932     error_count = 0; 
933   } 
934
935 /* only called form tex8.c */
936 /* sec 1099 */
937 void begin_insert_or_adjust (void) 
938
939   if (cur_cmd == 38)
940   cur_val = 255; 
941   else {
942       
943     scan_eight_bit_int (); 
944     if (cur_val == 255)
945     {
946                 print_err("You can't ");
947       print_esc("insert");
948       print_int(255);
949           help1("I'm changing to \\insert0; box 255 is special."); 
950       error (); 
951       cur_val = 0; 
952     } 
953   } 
954   save_stack[save_ptr + 0].cint = cur_val; 
955   incr(save_ptr); 
956   new_save_level(11); 
957   scan_left_brace (); 
958   normal_paragraph (); 
959   push_nest (); 
960   mode = -1; 
961   cur_list.aux_field.cint = ignore_depth; 
962
963 /* sec 1101 */
964 void make_mark (void) 
965 {
966   halfword p; 
967   p = scan_toks(false, true); 
968   p = get_node(2); 
969   mem[p].hh.b0 = 4; 
970   mem[p].hh.b1 = 0; 
971   mem[p + 1].cint = def_ref; 
972   mem[tail].hh.v.RH = p; 
973   tail = p; 
974
975 /* sec 1103 */
976 void append_penalty (void) 
977
978     scan_int (); 
979   {
980     mem[tail].hh.v.RH = new_penalty(cur_val); 
981     tail = mem[tail].hh.v.RH; 
982   } 
983   if (mode == 1){
984     build_page ();
985   }
986
987 /* only called from tex8.c */
988 /* sec 1105 */
989 void delete_last (void) 
990 {/* 10 */ 
991   halfword p, q; 
992   quarterword m; 
993   if ((mode == 1) && (tail == cur_list.head_field)) 
994   {
995 /*    if ((cur_chr != 10)||(last_glue != 262143L)) */
996     if ((cur_chr != 10)||(last_glue != empty_flag)) 
997     {
998       you_cant ();
999           help2("Sorry...I usually can't take things from the current page.",
1000                   "Try `I\\vskip-\\lastskip' instead."); 
1001       if (cur_chr == 11)
1002       help_line[0] = "Try `I\\kern-\\last_kern' instead.";
1003       else if (cur_chr != 10)
1004       help_line[0] = "Perhaps you can make the output routine do it.";
1005       error (); 
1006     } 
1007   } 
1008   else {
1009       
1010     if (!(tail >= hi_mem_min)) 
1011     if (mem[tail].hh.b0 == cur_chr)
1012     {
1013       q = head; 
1014       do {
1015     p = q; 
1016   if (!(q >= hi_mem_min)) 
1017   if (mem[q].hh.b0 == 7)
1018   {
1019     {
1020       register integer for_end;
1021       m = 1;
1022       for_end = mem[q].hh.b1;
1023       if (m <= for_end) do 
1024         p = mem[p].hh.v.RH; 
1025       while(m++ < for_end);
1026     } 
1027     if (p == tail)
1028     return; 
1029   } 
1030   q = mem[p].hh.v.RH; 
1031       } while(!(q == tail)); 
1032       mem[p].hh.v.RH = 0; 
1033       flush_node_list(tail); 
1034       tail = p; 
1035     } 
1036   } 
1037
1038 /* only called from tex8.c */
1039 /* procedure unpackage; l.21256 */
1040 /* sec 1110 */
1041 void unpackage (void) 
1042 {/* 10 */
1043   halfword p; 
1044   char c; 
1045   c = cur_chr; 
1046   scan_eight_bit_int (); 
1047   p = eqtb[(hash_size + 1578) + cur_val].hh.v.RH; 
1048   if (p == 0)/* if p=null then return; l.21261 */
1049   return; 
1050   if ((abs(mode)== 203)||((abs(mode)
1051   == 1)&&(mem[p].hh.b0 != 1)) ||((abs(mode)== 
1052   102)&&(mem[p].hh.b0 != 0)))
1053   {
1054           print_err("Incompatible list can't be unboxed");
1055           help3("Sorry, Pandora. (You sneaky devil.)",
1056                   "I refuse to unbox an \\hbox in vertical mode or vice versa.",
1057                   "And I can't open any boxes in math mode.");
1058     error (); 
1059     return; 
1060   } 
1061   if (c == 1)
1062   mem[tail].hh.v.RH = copy_node_list(mem[p + 5].hh 
1063  .v.RH); 
1064   else {
1065       
1066     mem[tail].hh.v.RH = mem[p + 5].hh.v.RH; 
1067     eqtb[(hash_size + 1578) + cur_val].hh.v.RH = 0; 
1068     free_node(p, 7); 
1069   } 
1070   while(mem[tail].hh.v.RH != 0)tail = mem 
1071  [tail].hh.v.RH; 
1072
1073 /* sec 1113 */
1074 void append_italic_correction (void) 
1075 {/* 10 */ 
1076   halfword p; 
1077   internal_font_number f; 
1078   if (tail != head)
1079   {
1080     if ((tail >= hi_mem_min)) 
1081     p = tail; 
1082     else if (mem[tail].hh.b0 == 6)
1083     p = tail + 1; 
1084     else return; 
1085     f = mem[p].hh.b0; 
1086     {
1087       mem[tail].hh.v.RH = new_kern(font_info[italic_base[
1088       f]+(font_info[char_base[f]+ mem[p].hh.b1].qqqq.b2)/ 4]
1089      .cint); 
1090       tail = mem[tail].hh.v.RH; 
1091     } 
1092     mem[tail].hh.b1 = 1; 
1093   } 
1094
1095 /* sec 1117 */
1096 void append_discretionary (void) 
1097
1098   integer c; 
1099   {
1100     mem[tail].hh.v.RH = new_disc (); 
1101     tail = mem[tail].hh.v.RH; 
1102   } 
1103   if (cur_chr == 1)
1104   {
1105     c = hyphen_char[eqtb[(hash_size + 1834)].hh.v.RH]; 
1106     if (c >= 0)
1107     if (c < 256)
1108     mem[tail + 1].hh.v.LH = new_character(eqtb[(hash_size + 1834)]
1109    .hh.v.RH, c); 
1110   } 
1111   else {
1112       
1113     incr(save_ptr); 
1114     save_stack[save_ptr - 1].cint = 0; 
1115     new_save_level(10); 
1116     scan_left_brace (); 
1117     push_nest (); 
1118     mode = -102; 
1119     space_factor = 1000; 
1120   } 
1121
1122 /* only called form tex8.c */
1123 /* sec 1119 */
1124 void build_discretionary (void) 
1125 {/* 30 10 */ 
1126   halfword p, q; 
1127   integer n; 
1128   unsave (); 
1129   q = head; 
1130   p = mem[q].hh.v.RH; 
1131   n = 0; 
1132   while(p != 0){
1133       
1134     if (!(p >= hi_mem_min)) 
1135     if (mem[p].hh.b0 > 2)
1136     if (mem[p].hh.b0 != 11)
1137     if (mem[p].hh.b0 != 6)
1138     {
1139                 print_err("Improper discretionary list");
1140                 help1("Discretionary lists must contain only boxes and kerns.");
1141       error (); 
1142       begin_diagnostic (); 
1143       print_nl("The following discretionary sublist has been deleted:");  /*  */
1144       show_box(p); 
1145       end_diagnostic(true); 
1146       flush_node_list(p); 
1147       mem[q].hh.v.RH = 0; 
1148       goto lab30; 
1149     } 
1150     q = p; 
1151     p = mem[q].hh.v.RH; 
1152     incr(n); 
1153   } 
1154   lab30:; 
1155   p = mem[head].hh.v.RH; 
1156   pop_nest (); 
1157   switch(save_stack[save_ptr - 1].cint)
1158   {case 0 : 
1159     mem[tail + 1].hh.v.LH = p; 
1160     break; 
1161   case 1 : 
1162     mem[tail + 1].hh.v.RH = p; 
1163     break; 
1164   case 2 : 
1165     {
1166       if ((n > 0)&&(abs(mode)== 203)) 
1167       {
1168                   print_err("Illegal math ");
1169   print_esc("discretionary");
1170   help2("Sorry: The third part of a discretionary break must be",
1171           "empty, in math formulas. I had to delete your third part.");
1172   flush_node_list(p); 
1173   n = 0; 
1174   error (); 
1175       } 
1176       else mem[tail].hh.v.RH = p; 
1177 /* if n <= max_quarterword then replace_count(tail) <- n; p.1120 */
1178 /*      if (n <= 255) */       /* 94/Apr/4 ? */
1179       if (n <= max_quarterword)     /* 96/Oct/12 ??? */
1180       mem[tail].hh.b1 = n; 
1181       else {
1182     print_err("Discretionary list is too long");
1183         help2("Wow---I never thought anybody would tweak me here.",
1184                 "You can't seriously need such a huge discretionary list?");
1185   error (); 
1186       } 
1187       if (n > 0)
1188       tail = q; 
1189       decr(save_ptr); 
1190       return; 
1191     } 
1192     break; 
1193   } 
1194   incr(save_stack[save_ptr - 1].cint); 
1195   new_save_level(10); 
1196   scan_left_brace (); 
1197   push_nest (); 
1198   mode = -102; 
1199   space_factor = 1000; 
1200
1201 /* called only from tex8.c */
1202 /* sec 1123 */
1203 void make_accent (void) 
1204 {
1205   real s, t; 
1206   halfword p, q, r; 
1207   internal_font_number f; 
1208   scaled a, h, x, w, delta; 
1209   ffourquarters i; 
1210   scan_char_num (); 
1211   f = eqtb[(hash_size + 1834)].hh.v.RH; 
1212   p = new_character(f, cur_val); 
1213   if (p != 0)
1214   {
1215     x = font_info[5 + param_base[f]].cint; 
1216     s = font_info[1 + param_base[f]].cint / ((double) 65536.0); 
1217     a = font_info[width_base[f]+ font_info[char_base[f]+ mem[p]
1218     .hh.b1].qqqq.b0].cint; 
1219     do_assignments (); 
1220     q = 0; 
1221     f = eqtb[(hash_size + 1834)].hh.v.RH; 
1222     if ((cur_cmd == 11)||(cur_cmd == 12)||(cur_cmd == 68)) 
1223     q = new_character(f, cur_chr); 
1224     else if (cur_cmd == 16)
1225     {
1226       scan_char_num (); 
1227       q = new_character(f, cur_val); 
1228     } 
1229     else back_input (); 
1230     if (q != 0)
1231     {
1232       t = font_info[1 + param_base[f]].cint / ((double) 65536.0); 
1233       i = font_info[char_base[f]+ mem[q].hh.b1].qqqq; 
1234       w = font_info[width_base[f]+ i.b0].cint; 
1235       h = font_info[height_base[f]+(i.b1)/ 16].cint; 
1236       if (h != x)
1237       {
1238   p = hpack(p, 0, 1); 
1239   mem[p + 4].cint = x - h; 
1240       } 
1241       delta = round((w - a)/ ((double) 2.0)+ h * t - x * s); 
1242       r = new_kern(delta); 
1243       mem[r].hh.b1 = 2; 
1244       mem[tail].hh.v.RH = r; 
1245       mem[r].hh.v.RH = p; 
1246       tail = new_kern(- (integer) a - delta); 
1247       mem[tail].hh.b1 = 2; 
1248       mem[p].hh.v.RH = tail; 
1249       p = q; 
1250     } 
1251     mem[tail].hh.v.RH = p; 
1252     tail = p; 
1253     space_factor = 1000; 
1254   } 
1255
1256 /* sec 1127 */
1257 void align_error (void) 
1258
1259   if (abs(align_state)> 2){
1260           print_err("Misplaced ");
1261     print_cmd_chr(cur_cmd, cur_chr); 
1262     if (cur_tok == 1062) {
1263                 help6("I can't figure out why you would want to use a tab mark",
1264                         "here. If you just want an ampersand, the remedy is",
1265                         "simple: Just type `I\\&' now. But if some right brace",
1266                         "up above has ended a previous alignment prematurely,",
1267                         "you're probably due for more error messages, and you",
1268                         "might try typing `S' now just to see what is salvageable.");
1269     } 
1270     else {
1271                 help5("I can't figure out why you would want to use a tab mark",
1272                         "or \\cr or \\span just now. If something like a right brace",
1273                         "up above has ended a previous alignment prematurely,",
1274                         "you're probably due for more error messages, and you",
1275                         "might try typing `S' now just to see what is salvageable."); 
1276     } 
1277     error (); 
1278   } 
1279   else {
1280     back_input (); 
1281     if (align_state < 0) {
1282                 print_err("Missing { inserted");
1283       incr(align_state); 
1284       cur_tok = 379;    /* belowdisplayshortskip ? */
1285     } 
1286     else {
1287                 print_err("Missing } inserted");
1288       decr(align_state); 
1289       cur_tok = 637; 
1290     }
1291         help3("I've put in what seems to be necessary to fix",
1292                 "the current column of the current alignment.",
1293                 "Try to go on, since this might almost work.");
1294     ins_error (); 
1295   }
1296
1297 /* sec 1129 */
1298 void noalign_error (void) 
1299 {
1300   print_err("Misplaced ");
1301   print_esc("noalign");
1302   help2("I expect to see \\noalign only after the \\cr of",
1303           "an alignment. Proceed, and I'll ignore this case.");
1304   error (); 
1305
1306 /* only called from tex8.c */
1307 /* sec 1129 */
1308 void omit_error (void) 
1309
1310   print_err("Misplaced ");
1311   print_esc("omit");
1312   help2("I expect to see \\omit only after tab marks or the \\cr of",
1313           "an alignment. Proceed, and I'll ignore this case.");
1314   error (); 
1315
1316 /* sec 1131 */
1317 void do_endv (void) 
1318 {
1319   if (cur_group == 6) {
1320     end_graf (); 
1321     if (fin_col ())fin_row ();
1322   } 
1323   else off_save ();
1324
1325 /* only called form tex8.c */
1326 /* sec 1135 */
1327 void cs_error (void) 
1328 {
1329   print_err("Extra ");
1330   print_esc("endcsname");
1331   help1("I'm ignoring this, since I wasn't doing a \\csname."); 
1332   error (); 
1333
1334 /* sec 1136 */
1335 void push_math_(group_code c) 
1336 {
1337   push_nest (); 
1338   mode = -203; 
1339   cur_list.aux_field.cint = 0; 
1340   new_save_level(c); 
1341
1342 /* sec 1138 */
1343 void init_math (void) 
1344 {/* 21 40 45 30 */
1345   scaled w; 
1346   scaled l; 
1347   scaled s; 
1348   halfword p; 
1349   halfword q; 
1350   internal_font_number f; 
1351   integer n; 
1352   scaled v; 
1353   scaled d; 
1354   get_token (); 
1355   if ((cur_cmd == 3)&&(mode > 0)) 
1356   {
1357     if (head == tail)
1358     {
1359       pop_nest (); 
1360       w = -1073741823L; /* - (2^30 - 1) */
1361     } 
1362     else {
1363   
1364       line_break(eqtb[(hash_size + 3170)].cint); 
1365       v = mem[just_box + 4].cint + 2 * font_info[6 +
1366       param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint; 
1367       w = -1073741823L;  /* - (2^30 - 1) */
1368       p = mem[just_box + 5].hh.v.RH; 
1369       while(p != 0){
1370     
1371   lab21: if ((p >= hi_mem_min)) 
1372   {
1373     f = mem[p].hh.b0; 
1374     d = font_info[width_base[f]+ font_info[char_base[f]+ mem[p 
1375   ].hh.b1].qqqq.b0].cint; 
1376     goto lab40; 
1377   } 
1378   switch(mem[p].hh.b0)
1379   {case 0 : 
1380   case 1 : 
1381   case 2 : 
1382     {
1383       d = mem[p + 1].cint; 
1384       goto lab40; 
1385     } 
1386     break; 
1387   case 6 : 
1388     {
1389       mem[lig_trick]= mem[p + 1]; 
1390       mem[lig_trick].hh.v.RH = mem[p].hh.v.RH; 
1391       p = lig_trick; 
1392       goto lab21; 
1393     } 
1394     break; 
1395   case 11 : 
1396   case 9 : 
1397     d = mem[p + 1].cint; 
1398     break; 
1399   case 10 : 
1400     {
1401       q = mem[p + 1].hh.v.LH; 
1402       d = mem[q + 1].cint; 
1403       if (mem[just_box + 5].hh.b0 == 1)
1404       {
1405         if ((mem[just_box + 5].hh.b1 == mem[q].hh.b0)&&(mem 
1406        [q + 2].cint != 0)) 
1407         v = 1073741823L;  /* - (2^30 - 1) */
1408       } 
1409       else if (mem[just_box + 5].hh.b0 == 2)
1410       {
1411         if ((mem[just_box + 5].hh.b1 == mem[q].hh.b1)&&(mem 
1412        [q + 3].cint != 0)) 
1413         v = 1073741823L;  /* - (2^30 - 1) */
1414       } 
1415       if (mem[p].hh.b1 >= 100)
1416       goto lab40; 
1417     } 
1418     break; 
1419   case 8 : 
1420     d = 0; 
1421     break; 
1422     default: 
1423     d = 0; 
1424     break; 
1425   } 
1426   if (v < 1073741823L) /* - (2^30 - 1) */
1427   v = v + d; 
1428   goto lab45; 
1429   lab40: if (v < 1073741823L) /* - (2^30 - 1) */
1430   {
1431     v = v + d; 
1432     w = v; 
1433   } 
1434   else {
1435       
1436     w = 1073741823L;  /* - (2^30 - 1) */
1437     goto lab30; 
1438   } 
1439   lab45: p = mem[p].hh.v.RH; 
1440       } 
1441       lab30:; 
1442     } 
1443     if (eqtb[(hash_size + 1312)].hh.v.RH == 0)
1444     if ((eqtb[(hash_size + 3747)].cint != 0)&&(((eqtb[(hash_size + 3204)].cint >= 0)&& 
1445    (prev_graf + 2 > eqtb[(hash_size + 3204)].cint)) ||(prev_graf + 
1446     1 < - (integer) eqtb[(hash_size + 3204)].cint)))
1447     {
1448       l = eqtb[(hash_size + 3733)].cint - abs(eqtb[(hash_size + 3747)].cint); 
1449       if (eqtb[(hash_size + 3747)].cint > 0)
1450       s = eqtb[(hash_size + 3747)].cint; 
1451       else s = 0; 
1452     } 
1453     else {
1454   
1455       l = eqtb[(hash_size + 3733)].cint; 
1456       s = 0; 
1457     } 
1458     else {
1459   
1460       n = mem[eqtb[(hash_size + 1312)].hh.v.RH].hh.v.LH; 
1461       if (prev_graf + 2 >= n)
1462       p = eqtb[(hash_size + 1312)].hh.v.RH + 2 * n; 
1463       else p = eqtb[(hash_size + 1312)].hh.v.RH + 2 *(prev_graf + 2); 
1464       s = mem[p - 1].cint; 
1465       l = mem[p].cint; 
1466     } 
1467     push_math(15); 
1468     mode = 203; 
1469     eq_word_define((hash_size + 3207), -1); 
1470     eq_word_define((hash_size + 3743), w); 
1471     eq_word_define((hash_size + 3744), l); 
1472     eq_word_define((hash_size + 3745), s); 
1473     if (eqtb[(hash_size + 1316)].hh.v.RH != 0)/* everydisplay */
1474     begin_token_list(eqtb[(hash_size + 1316)].hh.v.RH, 9); 
1475     if (nest_ptr == 1){
1476     build_page ();
1477   }
1478   } 
1479   else {
1480       
1481     back_input (); 
1482     {
1483       push_math(15); 
1484       eq_word_define((hash_size + 3207), -1); 
1485       if (eqtb[(hash_size + 1315)].hh.v.RH != 0)/* everymath */
1486       begin_token_list(eqtb[(hash_size + 1315)].hh.v.RH, 8); 
1487     } 
1488   } 
1489
1490 /* sec 1142 */
1491 void start_eq_no (void) 
1492 {
1493   save_stack[save_ptr + 0].cint = cur_chr; 
1494   incr(save_ptr); 
1495   {
1496     push_math(15); 
1497     eq_word_define((hash_size + 3207), -1); 
1498     if (eqtb[(hash_size + 1315)].hh.v.RH != 0)/* everymath */
1499     begin_token_list(eqtb[(hash_size + 1315)].hh.v.RH, 8); 
1500   } 
1501
1502 /* sec 1151 */
1503 void scan_math_(halfword p)
1504 {/* 20 21 10 */ 
1505   integer c; 
1506   lab20: do {
1507       get_x_token (); 
1508   } while(!((cur_cmd != 10)&&(cur_cmd != 0))); 
1509   lab21: switch(cur_cmd)
1510   {case 11 : 
1511   case 12 : 
1512   case 68 : 
1513     {
1514       c = eqtb[(hash_size + 2907) + cur_chr].hh.v.RH; 
1515       if (c == 32768L)
1516       {
1517   {
1518     cur_cs = cur_chr + 1; 
1519     cur_cmd = eqtb[cur_cs].hh.b0; 
1520     cur_chr = eqtb[cur_cs].hh.v.RH; 
1521     x_token (); 
1522     back_input (); 
1523   } 
1524   goto lab20; 
1525       } 
1526     } 
1527     break; 
1528   case 16 : 
1529     {
1530       scan_char_num (); 
1531       cur_chr = cur_val; 
1532       cur_cmd = 68; 
1533       goto lab21; 
1534     } 
1535     break; 
1536   case 17 : 
1537     {
1538       scan_fifteen_bit_int (); 
1539       c = cur_val; 
1540     } 
1541     break; 
1542   case 69 : 
1543     c = cur_chr; 
1544     break; 
1545   case 15 : 
1546     {
1547       scan_twenty_seven_bit_int (); 
1548       c = cur_val / 4096;  
1549 /*      c = cur_val >> 12; */
1550     } 
1551     break; 
1552     default: 
1553     {
1554       back_input (); 
1555       scan_left_brace (); 
1556       save_stack[save_ptr + 0].cint = p; 
1557       incr(save_ptr); 
1558       push_math(9); 
1559       return; 
1560     } 
1561     break; 
1562   } 
1563   mem[p].hh.v.RH = 1; 
1564   mem[p].hh.b1 = c % 256; 
1565 /*  mem[p].hh.b1 = c & 255; */ /* last 8 bits */
1566   if ((c >= 28672)&& /* 32768 - 4096 ??? if (c>=var_code) and ... */
1567     ((eqtb[(hash_size + 3207)].cint >= 0)&&
1568     (eqtb[(hash_size + 3207)].cint < 16)))
1569   mem[p].hh.b0 = eqtb[(hash_size + 3207)].cint; 
1570   else mem[p].hh.b0 =(c / 256)% 16; 
1571 /*  else mem[p].hh.b0 =(c >> 8)& 15; */ /* 4 bits to left */
1572
1573 /* sec 1155 */
1574 void set_math_char_(integer c)
1575 {
1576   halfword p; 
1577   if (c >= 32768L)
1578   {
1579     cur_cs = cur_chr + 1;          /* ??? */
1580 /*    cur_cmd = eqtb[eqtbextra + cur_cs].hh.b0;  */ /* was wrong ??? */
1581     cur_cmd = eqtb[cur_cs].hh.b0; 
1582 /*    cur_chr = eqtb[cur_cs].hh.v.RH; */ /* should have been eqtbextra ? */
1583     cur_chr = eqtb[cur_cs].hh.v.RH; 
1584     x_token (); 
1585     back_input (); 
1586   } 
1587   else {
1588       
1589     p = new_noad (); 
1590     mem[p + 1].hh.v.RH = 1; 
1591     mem[p + 1].hh.b1 = c % 256;  
1592 /*    mem[p + 1].hh.b1 = c & 255;  */ /* last 8 bits */
1593     mem[p + 1].hh.b0 =(c / 256)% 16; 
1594 /*    mem[p + 1].hh.b0 =(c >> 8)& 15;  */ /* 4 bits to left */
1595     if (c >= 28672)  /* 32768 - 4096 ? */
1596     {
1597       if (((eqtb[(hash_size + 3207)].cint >= 0)&&(eqtb[(hash_size + 3207)].cint < 16)) 
1598     )
1599       mem[p + 1].hh.b0 = eqtb[(hash_size + 3207)].cint; 
1600       mem[p].hh.b0 = 16; 
1601     } 
1602     else mem[p].hh.b0 = 16 +(c / 4096);  
1603 /*    else mem[p].hh.b0 = 16 +(c >> 12);  */
1604     mem[tail].hh.v.RH = p; 
1605     tail = p; 
1606   } 
1607
1608 /* sec 1159 */
1609 void math_limit_switch (void) 
1610 {/* 10 */
1611   if (head != tail)
1612   if (mem[tail].hh.b0 == 17)
1613   {
1614     mem[tail].hh.b1 = cur_chr; 
1615     return; 
1616   }
1617   print_err("Limit controls must follow a math operator");
1618   help1("I'm ignoring this misplaced \\limits or \\nolimits command."); 
1619   error (); 
1620
1621 /* sec 1160 */
1622 void scan_delimiter_(halfword p, bool r)
1623 {
1624    if (r){
1625    scan_twenty_seven_bit_int ();
1626   }
1627   else {
1628       
1629     do {
1630   get_x_token (); 
1631     } while(!((cur_cmd != 10)&&(cur_cmd != 0))); 
1632     switch(cur_cmd)
1633     {case 11 : 
1634     case 12 : 
1635       cur_val = eqtb[(hash_size + 3474) + cur_chr].cint; 
1636       break; 
1637     case 15 : 
1638       scan_twenty_seven_bit_int (); 
1639       break; 
1640       default: 
1641       cur_val = -1; 
1642       break; 
1643     } 
1644   } 
1645   if (cur_val < 0)
1646   {
1647           print_err("Missing delimiter (. inserted)");
1648           help6("I was expecting to see something like `(' or `\\{' or",
1649                   "`\\}' here. If you typed, e.g., `{' instead of `\\{', you",
1650                   "should probably delete the `{' by typing `1' now, so that",
1651                   "braces don't get unbalanced. Otherwise just proceed.",
1652                   "Acceptable delimiters are characters whose \\delcode is",
1653                   "nonnegative, or you can use `\\delimiter <delimiter code>'.");
1654     back_error (); 
1655     cur_val = 0; 
1656   }
1657 /* attempt to speed up - bkph */  /* is compiler smart enough already ? */
1658   mem[p].qqqq.b0 =(cur_val / 1048576L)% 16;   /* 2^20 */
1659 /*  mem[p].qqqq.b0 =(cur_val >> 20)& 15;  */
1660   mem[p].qqqq.b1 =(cur_val / 4096)% 256; 
1661 /*  mem[p].qqqq.b1 =(cur_val >> 12)& 255; */
1662   mem[p].qqqq.b2 =(cur_val / 256)% 16; 
1663 /*  mem[p].qqqq.b2 =(cur_val >> 8)& 15; */
1664   mem[p].qqqq.b3 = cur_val % 256; 
1665 /*  mem[p].qqqq.b3 = cur_val & 255;  */
1666
1667 /* sec 1163 */
1668 void math_radical (void) 
1669
1670   {
1671     mem[tail].hh.v.RH = get_node(5); 
1672     tail = mem[tail].hh.v.RH; 
1673   } 
1674   mem[tail].hh.b0 = 24; 
1675   mem[tail].hh.b1 = 0; 
1676   mem[tail + 1].hh = empty_field; 
1677   mem[tail + 3].hh = empty_field; 
1678   mem[tail + 2].hh = empty_field; 
1679   scan_delimiter(tail + 4, true); 
1680   scan_math(tail + 1); 
1681
1682 /* sec 1165 */
1683 void math_ac (void) 
1684
1685   if (cur_cmd == 45)
1686   {
1687     print_err("Please use ");
1688     print_esc("mathaccent");
1689     print_string(" for accents in math mode");
1690         help2("I'm changing \\accent to \\mathaccent here; wish me luck.",
1691                 "(Accents are not the same in formulas as they are in text.)");
1692     error (); 
1693   } 
1694   {
1695     mem[tail].hh.v.RH = get_node(5); 
1696     tail = mem[tail].hh.v.RH; 
1697   } 
1698   mem[tail].hh.b0 = 28; 
1699   mem[tail].hh.b1 = 0; 
1700   mem[tail + 1].hh = empty_field; 
1701   mem[tail + 3].hh = empty_field; 
1702   mem[tail + 2].hh = empty_field; 
1703   mem[tail + 4].hh.v.RH = 1; 
1704   scan_fifteen_bit_int (); 
1705   mem[tail + 4].hh.b1 = cur_val % 256;  
1706 /*  mem[tail + 4].hh.b1 = cur_val & 255; */
1707   if ((cur_val >= 28672)&& /* 32768 - 4096 ? */
1708     ((eqtb[(hash_size + 3207)].cint >= 0)&&
1709     (eqtb[(hash_size + 3207)].cint < 16)))
1710   mem[tail + 4].hh.b0 = eqtb[(hash_size + 3207)].cint; 
1711   else mem[tail + 4].hh.b0 =(cur_val / 256)% 16; 
1712 /*  else mem[tail + 4].hh.b0 =(cur_val >> 8)& 15; */
1713   scan_math(tail + 1); 
1714
1715 /* sec 1172 */
1716 void append_choices (void) 
1717
1718   {
1719     mem[tail].hh.v.RH = new_choice (); 
1720     tail = mem[tail].hh.v.RH; 
1721   } 
1722   incr(save_ptr); 
1723   save_stack[save_ptr - 1].cint = 0; 
1724   push_math(13); 
1725   scan_left_brace (); 
1726
1727 /* sec 1184 */
1728 halfword fin_mlist_(halfword p)
1729 {register halfword Result; 
1730   halfword q; 
1731   if (cur_list.aux_field.cint != 0)
1732   {
1733     mem[cur_list.aux_field.cint + 3].hh.v.RH = 3; 
1734     mem[cur_list.aux_field.cint + 3].hh.v.LH = mem[head]
1735    .hh.v.RH; 
1736     if (p == 0)
1737     q = cur_list.aux_field.cint; 
1738     else {
1739       q = mem[cur_list.aux_field.cint + 2].hh.v.LH; 
1740       if (mem[q].hh.b0 != 30){
1741       confusion("right");
1742       return 0;       // abort_flag set
1743     }
1744       mem[cur_list.aux_field.cint + 2].hh.v.LH = mem[q].hh.v.RH; 
1745       mem[q].hh.v.RH = cur_list.aux_field.cint; 
1746       mem[cur_list.aux_field.cint].hh.v.RH = p; 
1747     } 
1748   } 
1749   else {
1750     mem[tail].hh.v.RH = p; 
1751     q = mem[head].hh.v.RH; 
1752   } 
1753   pop_nest (); 
1754   Result = q; 
1755   return Result; 
1756
1757 /* sec 1174 */
1758 void build_choices (void) 
1759 {/* 10 */
1760   halfword p; 
1761   unsave (); 
1762   p = fin_mlist(0); 
1763   switch(save_stack[save_ptr - 1].cint)
1764   {case 0 : 
1765     mem[tail + 1].hh.v.LH = p; 
1766     break; 
1767   case 1 : 
1768     mem[tail + 1].hh.v.RH = p; 
1769     break; 
1770   case 2 : 
1771     mem[tail + 2].hh.v.LH = p; 
1772     break; 
1773   case 3 : 
1774     {
1775       mem[tail + 2].hh.v.RH = p; 
1776       decr(save_ptr); 
1777       return; 
1778     } 
1779     break; 
1780   } 
1781   incr(save_stack[save_ptr - 1].cint); 
1782   push_math(13); 
1783   scan_left_brace (); 
1784
1785 /* sec 1176 */
1786 void sub_sup (void) 
1787 {
1788 /*  small_number t; */
1789   int t;              /* 95/Jan/7 */
1790   halfword p; 
1791   t = 0; 
1792   p = 0; 
1793   if (tail != head)
1794   if ((mem[tail].hh.b0 >= 16)&&
1795     (mem[tail].hh.b0 < 30)) 
1796   {
1797     p = tail + 2 + cur_cmd - 7; 
1798     t = mem[p].hh.v.RH; 
1799   } 
1800   if ((p == 0)||(t != 0)) 
1801   {
1802     {
1803       mem[tail].hh.v.RH = new_noad (); 
1804       tail = mem[tail].hh.v.RH; 
1805     } 
1806     p = tail + 2 + cur_cmd - 7; 
1807     if (t != 0)
1808     {
1809       if (cur_cmd == 7)
1810       {
1811                   print_err("Double superscript");
1812                   help1("I treat `x^1^2' essentially like `x^1{}^2'.");
1813       } 
1814       else {
1815     print_err("Double subscript");
1816         help1("I treat `x_1_2' essentially like `x_1{}_2'.");
1817       } 
1818       error (); 
1819     } 
1820   } 
1821   scan_math(p); 
1822
1823 /* used to continue here with math_fraction etc in tex7.c */
1824 /*****************************************************************************/
1825 /* moved down here to avoid pragma optimize questions 96/Sep/12 */
1826 /* #pragma optimize("g", off) */          /* for MC VS compiler */
1827 /* #pragma optimize("a", off) */          /* for MC VS compiler */
1828 /* sec 1086 */
1829 void package_(small_number c)
1830
1831   scaled h; 
1832   halfword p; 
1833   scaled d; 
1834   d = eqtb[(hash_size + 3737)].cint; 
1835   unsave (); 
1836   save_ptr = save_ptr - 3; 
1837   if (mode == -102)
1838   cur_box = hpack(mem[head].hh.v.RH, save_stack[save_ptr 
1839   + 2].cint, save_stack[save_ptr + 1].cint); 
1840   else {
1841     cur_box = vpackage(mem[head].hh.v.RH, save_stack[
1842     save_ptr + 2].cint, save_stack[save_ptr + 1].cint, d); 
1843     if (c == 4)
1844     {
1845       h = 0; 
1846       p = mem[cur_box + 5].hh.v.RH; 
1847       if (p != 0)
1848       if (mem[p].hh.b0 <= 2)
1849       h = mem[p + 3].cint; 
1850       mem[cur_box + 2].cint = mem[cur_box + 2].cint - h + mem[cur_box + 
1851       3].cint; 
1852       mem[cur_box + 3].cint = h; 
1853     } 
1854   } 
1855   pop_nest (); 
1856   box_end(save_stack[save_ptr + 0].cint); 
1857
1858 /* #pragma optimize("g", on) */         /* for MC VS compiler */
1859 /* #pragma optimize("a", on) */         /* for MC VS compiler */
1860 /* #pragma optimize("a",) */          /* 94/Jan/25 */
1861 #pragma optimize ("", on)           /* 96/Sep/12 */
1862 /****************************************************************************/