OSDN Git Service

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