OSDN Git Service

updated sources.
[putex/putex.git] / src / texsourc / tex6.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 void align_peek (void) 
27 {
28 lab20:
29   align_state = 1000000L;
30   do {
31     get_x_token();
32   } while (!(cur_cmd != 10));
33   if (cur_cmd == 34) {
34     scan_left_brace();
35     new_save_level(7);
36     if (mode == -1)
37       normal_paragraph();
38   } else if (cur_cmd == 2) {
39     fin_align();
40   } else if ((cur_cmd == 5) && (cur_chr == 258))
41     goto lab20;
42   else {
43     init_row();
44     init_col();
45   }
46 }
47 /* used in itex.c only */
48 halfword finite_shrink_(halfword p)
49 {
50   register halfword Result;
51   halfword q;
52   if (noshrinkerroryet) {
53     noshrinkerroryet = false;
54     print_err("Infinite glue shrinkage found in a paragraph");
55     help5("The paragraph just ended includes some glue that has",
56       "infinite shrinkability, e.g., `\\hskip 0pt minus 1fil'.",
57       "Such glue doesn't belong there---it allows a paragraph",
58       "of any length to fit on one line. But it's safe to proceed,",
59       "since the offensive shrinkability has been made finite.");
60     error();
61   }
62   q = new_spec(p);
63   mem[q].hh.b1 = 0;
64   delete_glue_ref(p);
65   Result = q;
66   return Result;
67 }
68 void try_break_ (integer pi, small_number breaktype)
69 {
70   halfword r;
71   halfword prevr;
72   halfword oldl;
73   bool nobreakyet;
74   halfword prevprevr;
75   halfword s;
76   halfword q;
77   halfword v;
78   integer t;
79   internal_font_number f;
80   halfword l;
81   bool noderstaysactive;
82   scaled linewidth;
83   char fitclass;
84   halfword b;       /* current badness */
85   integer d;
86   bool artificialdemerits;
87   halfword savelink;
88   scaled shortfall;
89   if (abs(pi)>= 10000)
90     if (pi > 0)
91       goto lab10;
92     else
93       pi = -10000;
94   nobreakyet = true;
95   prevr = active;
96   oldl = 0;
97   cur_active_width[1] = active_width[1];
98   cur_active_width[2] = active_width[2];
99   cur_active_width[3] = active_width[3];
100   cur_active_width[4] = active_width[4];
101   cur_active_width[5] = active_width[5];
102   cur_active_width[6] = active_width[6];
103   while (true) {
104 lab22:
105     r = mem[prevr].hh.v.RH;
106     if (mem[r].hh.b0 == 2) {
107       cur_active_width[1] = cur_active_width[1] + mem[r + 1].cint;
108       cur_active_width[2] = cur_active_width[2] + mem[r + 2].cint;
109       cur_active_width[3] = cur_active_width[3] + mem[r + 3].cint;
110       cur_active_width[4] = cur_active_width[4] + mem[r + 4].cint;
111       cur_active_width[5] = cur_active_width[5] + mem[r + 5].cint;
112       cur_active_width[6] = cur_active_width[6] + mem[r + 6].cint;
113       prevprevr = prevr;
114       prevr = r;
115       goto lab22;
116     }
117     {
118       l = mem[r + 1].hh.v.LH; 
119       if (l > oldl) {
120         if ((minimum_demerits < 1073741823L) &&  /* 2^30 - 1 */
121           ((oldl != easyline)||(r == active))) {
122             if (nobreakyet) {
123               nobreakyet = false; 
124               break_width[1] = background[1];
125               break_width[2] = background[2];
126               break_width[3] = background[3];
127               break_width[4] = background[4];
128               break_width[5] = background[5];
129               break_width[6] = background[6];
130               s = cur_p;
131 /* if break_type>unhyphenated then if cur_p<>null then l.16451 */
132               if (breaktype > 0)
133                 if (cur_p != 0)
134                 {
135                   t = mem[cur_p].hh.b1;
136                   v = cur_p;
137                   s = mem[cur_p + 1].hh.v.RH;
138                   while (t > 0) {
139                     decr(t);
140                     v = mem[v].hh.v.RH; 
141                     if ((v >= hi_mem_min)) {
142                       f = mem[v].hh.b0; 
143                       break_width[1]= break_width[1]- font_info[width_base[f]+ font_info[char_base[f]+ mem[v].hh.b1].qqqq.b0].cint;
144                     } else switch (mem[v].hh.b0)
145                     {
146                     case 6:
147                       {
148                         f = mem[v + 1].hh.b0;
149                         break_width[1]= break_width[1]- font_info[width_base[f]+ font_info[char_base[f]+ mem[v + 1].hh.b1].qqqq.b0].cint;
150                       }
151                       break;
152                     case 0:
153                     case 1:
154                     case 2:
155                     case 11:
156                       break_width[1]= break_width[1]- mem[v + 1].cint;
157                       break;
158                     default:
159                       {
160                         confusion("disc1");
161                         return;       // abort_flag set
162                       }
163                       break;
164                     }
165                   }
166                   while (s != 0) {  /* while s<>null do l.16453 */
167                     if ((s >= hi_mem_min)) {
168                       f = mem[s].hh.b0;
169                       break_width[1]= break_width[1]+ font_info[width_base[f]+ font_info[char_base[f]+ mem[s].hh.b1].qqqq.b0].cint;
170                     } else switch(mem[s].hh.b0)
171                     {
172                     case 6:
173                       {
174                         f = mem[s + 1].hh.b0;
175                         break_width[1]= break_width[1]+ font_info[width_base[f]+ font_info[char_base[f]+ mem[s + 1].hh.b1].qqqq.b0].cint;
176                       }
177                       break;
178                     case 0:
179                     case 1:
180                     case 2:
181 /* didn't used to drop through to case 11 from case 2 in  3.141 */
182                     case 11:
183 /* used to be some extra code here in case 11 in 3.141 */
184                       break_width[1]= break_width[1]+ mem[s + 1].cint;
185                       break;
186                     default:
187                       {
188                         confusion("disc1");
189                         return;       // abort_flag set
190                       }
191                       break;
192                     }
193 /* used to be an increment t here in 3.141 */
194                     s = mem[s].hh.v.RH;
195                   }
196                   break_width[1] = break_width[1] + disc_width;
197 /* used to be a test on t here instead in 3.141 */
198                   if (mem[cur_p + 1].hh.v.RH == 0)
199                     s = mem[v].hh.v.RH;
200                 } 
201                 while (s != 0) {
202                   if ((s >= hi_mem_min))
203                     goto lab30;
204                   switch(mem[s].hh.b0)
205                   {
206                   case 10:
207                     {
208                       v = mem[s + 1].hh.v.LH;
209                       break_width[1]= break_width[1]- mem[v + 1].cint;
210                       break_width[2 + mem[v].hh.b0]= break_width[2 + mem[v].hh.b0]- mem[v + 2].cint;
211                       break_width[6]= break_width[6]- mem[v + 3].cint;
212                     }
213                     break;
214                   case 12:
215                     ;
216                     break;
217                   case 9:
218 /* case 9 used to drop through to case 11 in 3.141 */
219                     break_width[1]= break_width[1]- mem[s + 1].cint;
220                     break;
221                   case 11:
222 /* changes here in nature of test since 3.141 */
223                     if (mem[s].hh.b1 != 1)
224                       goto lab30;
225                     else
226                       break_width[1]= break_width[1]- mem[s + 1].cint;
227                     break;
228                   default:
229                     goto lab30;
230                     break;
231                   }
232                   s = mem[s].hh.v.RH;
233                 }
234 lab30:
235                 ;
236             }
237             if (mem[prevr].hh.b0 == 2) {
238               mem[prevr + 1].cint = mem[prevr + 1].cint - cur_active_width[1] + break_width[1];
239               mem[prevr + 2].cint = mem[prevr + 2].cint - cur_active_width[2] + break_width[2];
240               mem[prevr + 3].cint = mem[prevr + 3].cint - cur_active_width[3] + break_width[3];
241               mem[prevr + 4].cint = mem[prevr + 4].cint - cur_active_width[4] + break_width[4];
242               mem[prevr + 5].cint = mem[prevr + 5].cint - cur_active_width[5] + break_width[5];
243               mem[prevr + 6].cint = mem[prevr + 6].cint - cur_active_width[6] + break_width[6];
244             } else if (prevr == active) {
245               active_width[1] = break_width[1];
246               active_width[2] = break_width[2];
247               active_width[3] = break_width[3];
248               active_width[4] = break_width[4];
249               active_width[5] = break_width[5];
250               active_width[6] = break_width[6];
251             } else {
252               q = get_node(7);
253               mem[q].hh.v.RH = r;
254               mem[q].hh.b0 = 2;
255               mem[q].hh.b1 = 0;
256               mem[q + 1].cint = break_width[1]- cur_active_width[1];
257               mem[q + 2].cint = break_width[2]- cur_active_width[2];
258               mem[q + 3].cint = break_width[3]- cur_active_width[3];
259               mem[q + 4].cint = break_width[4]- cur_active_width[4];
260               mem[q + 5].cint = break_width[5]- cur_active_width[5];
261               mem[q + 6].cint = break_width[6]- cur_active_width[6];
262               mem[prevr].hh.v.RH = q;
263               prevprevr = prevr;
264               prevr = q;
265             }
266             if (abs(adj_demerits) >= 1073741823L - minimum_demerits)
267               minimum_demerits = 1073741822L; /* 2^30 - 2 */
268             else
269               minimum_demerits = minimum_demerits + abs(adj_demerits); 
270             {
271               register integer for_end;
272               fitclass = 0;
273               for_end = 3;
274               if (fitclass <= for_end) do {
275                 if (minimal_demerits[fitclass] <= minimum_demerits) {
276                   q = get_node(2);
277                   mem[q].hh.v.RH = passive;
278                   passive = q;
279                   mem[q + 1].hh.v.RH = cur_p;
280                   ;
281 #ifdef STAT
282                   incr(pass_number);
283                   mem[q].hh.v.LH = pass_number;
284 #endif /* STAT */
285                   mem[q + 1].hh.v.LH = best_place[fitclass];
286                   q = get_node(3);
287                   mem[q + 1].hh.v.RH = passive;
288                   mem[q + 1].hh.v.LH = best_pl_line[fitclass] + 1;
289                   mem[q].hh.b1 = fitclass;
290                   mem[q].hh.b0 = breaktype;
291                   mem[q + 2].cint = minimal_demerits[fitclass];
292                   mem[q].hh.v.RH = r;
293                   mem[prevr].hh.v.RH = q;
294                   prevr = q;
295                   ;
296 #ifdef STAT
297                   if (tracing_paragraphs > 0) {
298                     print_nl("@@");
299                     print_int(mem[passive].hh.v.LH);
300                     print_string(": line ");
301                     print_int(mem[q + 1].hh.v.LH - 1);
302                     print_char('.');
303                     print_int(fitclass);
304                     if (breaktype == 1)
305                       print_char('-');
306                     print_string(" t=");
307                     print_int(mem[q + 2].cint);
308                     print_string(" -> @@");
309                     if (mem[passive + 1].hh.v.LH == 0)
310                       print_char('0');
311                     else
312                       print_int(mem[mem[passive + 1].hh.v.LH].hh.v.LH);
313                   } 
314 #endif /* STAT */
315                 }
316                 minimal_demerits[fitclass]= 1073741823L; /* 2^30 - 1 */
317               } while(fitclass++ < for_end);
318             }
319             minimum_demerits = 1073741823L; /* 2^30 - 1 */
320             if (r != active) {
321               q = get_node(7);
322               mem[q].hh.v.RH = r;
323               mem[q].hh.b0 = 2;
324               mem[q].hh.b1 = 0;
325               mem[q + 1].cint = cur_active_width[1] - break_width[1];
326               mem[q + 2].cint = cur_active_width[2] - break_width[2];
327               mem[q + 3].cint = cur_active_width[3] - break_width[3];
328               mem[q + 4].cint = cur_active_width[4] - break_width[4];
329               mem[q + 5].cint = cur_active_width[5] - break_width[5];
330               mem[q + 6].cint = cur_active_width[6] - break_width[6];
331               mem[prevr].hh.v.RH = q;
332               prevprevr = prevr;
333               prevr = q;
334             }
335         }
336         if (r == active)
337           goto lab10;
338         if (l > easyline) {
339           linewidth = second_width; 
340           oldl = 262142L;       /* 2^18 - 2 ? */
341         } else {
342           oldl = l;
343           if (l > last_special_line)
344             linewidth = second_width;
345           else if (par_shape_ptr == 0)
346             linewidth = first_width;
347           else
348             linewidth = mem[par_shape_ptr + 2 * l].cint;
349         }
350       }
351     }
352     {
353       artificialdemerits = false; 
354       shortfall = linewidth - cur_active_width[1];  /* linewidth may be ... */
355       if (shortfall > 0)
356         if ((cur_active_width[3]!= 0) || (cur_active_width[4]!= 0) || (cur_active_width[5]!= 0)) {
357           b = 0;
358           fitclass = 2;
359         } else {
360           if (shortfall > 7230584L)
361             if (cur_active_width[2]< 1663497L) {
362               b = 10000;
363               fitclass = 0;
364               goto lab31;
365             }
366           b = badness(shortfall, cur_active_width[2]);
367           if (b > 12)
368             if (b > 99)
369               fitclass = 0;
370             else
371               fitclass = 1;
372           else fitclass = 2;
373 lab31:
374           ;
375         } else {
376           if (- (integer) shortfall > cur_active_width[6])
377             b = 10001;
378           else
379             b = badness(- (integer) shortfall, cur_active_width[6]);
380           if (b > 12)
381             fitclass = 3;
382           else
383             fitclass = 2;
384         }
385       if ((b > 10000)||(pi == -10000)) {
386         if (final_pass && (minimum_demerits == 1073741823L) &&  /* 2^30 - 1 */
387             (mem[r].hh.v.RH == active) && (prevr == active))
388           artificialdemerits = true;
389         else if (b > threshold)
390           goto lab60;
391         noderstaysactive = false;
392       } else {
393         prevr = r;
394         if (b > threshold)
395           goto lab22;
396         noderstaysactive = true;
397       }
398       if (artificialdemerits)
399         d = 0;
400       else {
401         d = line_penalty + b;
402         if (abs(d)>= 10000)
403           d = 100000000L;
404         else
405           d = d * d;
406         if (pi != 0)
407           if (pi > 0)
408             d = d + pi * pi;
409           else if (pi > -10000)
410             d = d - pi * pi;
411         if ((breaktype == 1) && (mem[r].hh.b0 == 1))
412           if (cur_p != 0)
413             d = d + double_hyphen_demerits;
414           else
415             d = d + final_hyphen_demerits;
416         if (abs(toint(fitclass)- toint(mem[r].hh.b1)) > 1)
417           d = d + adj_demerits;
418       }
419       ;
420 #ifdef STAT
421       if (tracing_paragraphs > 0) {
422         if (printed_node != cur_p) {
423           print_nl("");
424           if (cur_p == 0)
425             short_display(mem[printed_node].hh.v.RH);
426           else {
427             savelink = mem[cur_p].hh.v.RH;
428             mem[cur_p].hh.v.RH = 0;
429             print_nl("");
430             short_display(mem[printed_node].hh.v.RH);
431             mem[cur_p].hh.v.RH = savelink;
432           }
433           printed_node = cur_p;
434         }
435         print_nl("@");
436         if (cur_p == 0)
437           print_esc("par");
438         else if (mem[cur_p].hh.b0 != 10) {
439           if (mem[cur_p].hh.b0 == 12)
440             print_esc("penalty");
441           else if (mem[cur_p].hh.b0 == 7)
442             print_esc("discretionary");
443           else if (mem[cur_p].hh.b0 == 11)
444             print_esc("kern");
445           else
446             print_esc("math");
447         }
448         print_string(" via @@");
449         if (mem[r + 1].hh.v.RH == 0)
450           print_char('0');
451         else
452           print_int(mem[mem[r + 1].hh.v.RH].hh.v.LH);
453         print_string(" b=");
454         if (b > 10000)
455           print_char('*');
456         else print_int(b);
457         print_string(" p=");
458         print_int(pi);
459         print_string(" d=");
460         if (artificialdemerits)
461           print_char('*');
462         else print_int(d);
463       }
464 #endif /* STAT */
465       d = d + mem[r + 2].cint; 
466       if (d <= minimal_demerits[fitclass]) {
467         minimal_demerits[fitclass]= d;
468         best_place[fitclass]= mem[r + 1].hh.v.RH;
469         best_pl_line[fitclass]= l;
470         if (d < minimum_demerits)
471           minimum_demerits = d;
472       }
473       if (noderstaysactive)
474         goto lab22;
475 lab60:
476       mem[prevr].hh.v.RH = mem[r].hh.v.RH;
477       free_node(r, 3);
478       if (prevr == active) {
479         r = mem[active].hh.v.RH;
480         if (mem[r].hh.b0 == 2) {
481           active_width[1] = active_width[1] + mem[r + 1].cint;
482           active_width[2] = active_width[2] + mem[r + 2].cint;
483           active_width[3] = active_width[3] + mem[r + 3].cint;
484           active_width[4] = active_width[4] + mem[r + 4].cint;
485           active_width[5] = active_width[5] + mem[r + 5].cint;
486           active_width[6] = active_width[6] + mem[r + 6].cint;
487           cur_active_width[1] = active_width[1];
488           cur_active_width[2] = active_width[2];
489           cur_active_width[3] = active_width[3];
490           cur_active_width[4] = active_width[4];
491           cur_active_width[5] = active_width[5];
492           cur_active_width[6] = active_width[6];
493           mem[active].hh.v.RH = mem[r].hh.v.RH;
494           free_node(r, 7);
495         }
496       } else if (mem[prevr].hh.b0 == 2) {
497         r = mem[prevr].hh.v.RH;
498         if (r == active) {
499           cur_active_width[1] = cur_active_width[1] - mem[prevr + 1].cint;
500           cur_active_width[2] = cur_active_width[2] - mem[prevr + 2].cint;
501           cur_active_width[3] = cur_active_width[3] - mem[prevr + 3].cint;
502           cur_active_width[4] = cur_active_width[4] - mem[prevr + 4].cint;
503           cur_active_width[5] = cur_active_width[5] - mem[prevr + 5].cint;
504           cur_active_width[6] = cur_active_width[6] - mem[prevr + 6].cint;
505           mem[prevprevr].hh.v.RH = active; /* prevprevr may be used ... */
506           free_node(prevr, 7);
507           prevr = prevprevr;
508         } else if (mem[r].hh.b0 == 2) {
509           cur_active_width[1] = cur_active_width[1] + mem[r + 1].cint;
510           cur_active_width[2] = cur_active_width[2] + mem[r + 2].cint;
511           cur_active_width[3] = cur_active_width[3] + mem[r + 3].cint;
512           cur_active_width[4] = cur_active_width[4] + mem[r + 4].cint;
513           cur_active_width[5] = cur_active_width[5] + mem[r + 5].cint;
514           cur_active_width[6] = cur_active_width[6] + mem[r + 6].cint;
515           mem[prevr + 1].cint = mem[prevr + 1].cint + mem[r + 1].cint;
516           mem[prevr + 2].cint = mem[prevr + 2].cint + mem[r + 2].cint;
517           mem[prevr + 3].cint = mem[prevr + 3].cint + mem[r + 3].cint;
518           mem[prevr + 4].cint = mem[prevr + 4].cint + mem[r + 4].cint;
519           mem[prevr + 5].cint = mem[prevr + 5].cint + mem[r + 5].cint;
520           mem[prevr + 6].cint = mem[prevr + 6].cint + mem[r + 6].cint;
521           mem[prevr].hh.v.RH = mem[r].hh.v.RH;
522           free_node(r, 7);
523         }
524       }
525     }
526   }
527 lab10:
528   ;
529 #ifdef STAT
530   if (cur_p == printed_node)
531     if (cur_p != 0)
532       if (mem[cur_p].hh.b0 == 7) {
533         t = mem[cur_p].hh.b1;
534         while (t > 0) {
535           decr(t);
536           printed_node = mem[printed_node].hh.v.RH;
537         }
538       } 
539 #endif /* STAT */
540 /*  must exit here, there are no internal return - except for confusion */
541 /*  savedbadness = b; */      /* 96/Feb/9 - for test in itex.c */
542 }
543 /* end of the old tex5.c here */
544 void post_line_break_(integer finalwidowpenalty)
545 {
546   halfword q, r, s;
547   bool discbreak;
548   bool postdiscbreak;
549   scaled curwidth;
550   scaled curindent;
551   quarterword t;
552   integer pen;
553   halfword curline;
554   q = mem[best_bet + 1].hh.v.RH;
555   cur_p = 0;
556   do {
557     r = q;
558     q = mem[q + 1].hh.v.LH;
559     mem[r + 1].hh.v.LH = cur_p;
560     cur_p = r;
561   } while (!(q == 0));
562   curline = prev_graf + 1;
563   do {
564     q = mem[cur_p + 1].hh.v.RH;
565     discbreak = false;
566     postdiscbreak = false;
567     if (q != 0)
568       if (mem[q].hh.b0 == 10) {
569         delete_glue_ref(mem[q + 1].hh.v.LH);
570         mem[q + 1].hh.v.LH = eqtb[(hash_size + 790)].hh.v.RH;
571         mem[q].hh.b1 = 9;
572         incr(mem[eqtb[(hash_size + 790)].hh.v.RH].hh.v.RH);
573         goto lab30;
574       } else {
575         if (mem[q].hh.b0 == 7) {
576           t = mem[q].hh.b1;
577           if (t == 0)
578             r = mem[q].hh.v.RH;
579           else {
580             r = q;
581             while (t > 1) {
582               r = mem[r].hh.v.RH;
583               decr(t);
584             }
585             s = mem[r].hh.v.RH;
586             r = mem[s].hh.v.RH;
587             mem[s].hh.v.RH = 0;
588             flush_node_list(mem[q].hh.v.RH);
589             mem[q].hh.b1 = 0;
590           }
591           if (mem[q + 1].hh.v.RH != 0) {
592             s = mem[q + 1].hh.v.RH;
593             while (mem[s].hh.v.RH != 0)
594               s = mem[s].hh.v.RH;
595             mem[s].hh.v.RH = r;
596             r = mem[q + 1].hh.v.RH;
597             mem[q + 1].hh.v.RH = 0;
598             postdiscbreak = true;
599           }
600           if (mem[q + 1].hh.v.LH != 0) {
601             s = mem[q + 1].hh.v.LH;
602             mem[q].hh.v.RH = s;
603             while (mem[s].hh.v.RH != 0)
604               s = mem[s].hh.v.RH;
605             mem[q + 1].hh.v.LH = 0;
606             q = s;
607           }
608           mem[q].hh.v.RH = r;
609           discbreak = true;
610         } else if ((mem[q].hh.b0 == 9)||(mem[q].hh.b0 == 11))
611           mem[q + 1].cint = 0;
612       } else {
613         q = temp_head;
614         while (mem[q].hh.v.RH != 0)
615           q = mem[q].hh.v.RH;
616       }
617     r = new_param_glue(8);
618     mem[r].hh.v.RH = mem[q].hh.v.RH;
619     mem[q].hh.v.RH = r;
620     q = r;
621 lab30:
622     ;
623     r = mem[q].hh.v.RH;
624     mem[q].hh.v.RH = 0;
625     q = mem[temp_head].hh.v.RH;
626     mem[temp_head].hh.v.RH = r;
627     if (eqtb[(hash_size + 789)].hh.v.RH != 0) {
628       r = new_param_glue(7);
629       mem[r].hh.v.RH = q;
630       q = r;
631     }
632     if (curline > last_special_line) {
633       curwidth = second_width;
634       curindent = second_indent;
635     } else if (par_shape_ptr == 0) {
636       curwidth = first_width;
637       curindent = first_indent;
638     } else {
639       curwidth = mem[par_shape_ptr + 2 * curline].cint;
640       curindent = mem[par_shape_ptr + 2 * curline - 1].cint;
641     }
642     adjust_tail = adjust_head;
643     just_box = hpack(q, curwidth, 0);
644     mem[just_box + 4].cint = curindent;
645     append_to_vlist(just_box);
646 /* if adjust_head<>adjust_tail then l.17346 */
647     if (adjust_head != adjust_tail) {
648       mem[tail].hh.v.RH = mem[adjust_head].hh.v.RH;
649       tail = adjust_tail;
650     }
651     adjust_tail = 0; /* adjust_tail:=null */
652     if (curline + 1 != best_line) {
653       pen = inter_line_penalty;
654       if (curline == prev_graf + 1)
655         pen = pen + club_penalty;
656       if (curline + 2 == best_line)
657         pen = pen + finalwidowpenalty;
658       if (discbreak)
659         pen = pen + broken_penalty;
660       if (pen != 0) {
661         r = new_penalty(pen);
662         mem[tail].hh.v.RH = r;
663         tail = r;
664       }
665     }
666     incr(curline);
667     cur_p = mem[cur_p + 1].hh.v.LH;
668     if (cur_p != 0)
669       if (!postdiscbreak) {
670         r = temp_head;
671         while (true) {
672           q = mem[r].hh.v.RH;
673           if (q == mem[cur_p + 1].hh.v.RH)
674             goto lab31;
675           if ((q >= hi_mem_min))
676             goto lab31;
677           if ((mem[q].hh.b0 < 9))
678             goto lab31;
679 /* change in tests here from 3.141 != 1 instead of == 2 */
680           if (mem[q].hh.b0 == 11)
681             if (mem[q].hh.b1 != 1)
682               goto lab31;
683           r = q;
684         }
685 lab31:
686         if (r != temp_head) {
687           mem[r].hh.v.RH = 0;
688   flush_node_list(mem[temp_head].hh.v.RH); 
689   mem[temp_head].hh.v.RH = q; 
690       } 
691     } 
692   } while(!(cur_p == 0)); 
693   if ((curline != best_line)||(mem[temp_head].hh.v.RH != 0)) {
694     confusion("disc2");
695     return;       // abort_flag set
696   }
697   prev_graf = best_line - 1; 
698
699 /* Reconstitute ligatures during hyphenation pass */
700 small_number reconstitute_(small_number j, small_number n, halfword bchar, halfword hchar) 
701 {/* 22 30 */ register small_number Result; 
702   halfword p; 
703   halfword t; 
704   ffourquarters q; 
705   halfword currh; 
706   halfword testchar; 
707   scaled w; 
708   font_index k; 
709   hyphen_passed = 0;            /* paragraph 907 ? */
710   t = hold_head; 
711   w = 0; 
712   mem[hold_head].hh.v.RH = 0; 
713   cur_l = hu[j]; 
714   cur_q = t; 
715   if (j == 0)
716   {
717     ligature_present = init_lig; 
718     p = init_list; 
719     if (ligature_present)
720     lft_hit = init_lft; 
721 /*   while p>null do l.17772 */
722 /*    while(p > 0){ */  /* NO! */
723     while(p != 0){          /* 94/Mar/22 BUG FIX */
724       {
725 /*    append_charnode_to_t(character(p)); */ 
726   mem[t].hh.v.RH = get_avail(); 
727   t = mem[t].hh.v.RH; 
728   mem[t].hh.b0 = hf; 
729   mem[t].hh.b1 = mem[p].hh.b1; 
730       } 
731       p = mem[p].hh.v.RH; /* p:=link(p); */
732     } 
733   } 
734   else if (cur_l < 256)
735   {
736     mem[t].hh.v.RH = get_avail(); 
737     t = mem[t].hh.v.RH; 
738     mem[t].hh.b0 = hf; 
739     mem[t].hh.b1 = cur_l; 
740   } 
741   lig_stack = 0;    /* lig_stack:=null; */
742   {
743     if (j < n)
744     cur_r = hu[j + 1]; 
745     else cur_r = bchar; 
746     if (odd(hyf[j])) 
747     currh = hchar; 
748     else currh = 256; 
749   } 
750   lab22: if (cur_l == 256)   /* if cur_l = non_char then */
751   {
752     k = bchar_label[hf];    /* begin k:=bchar_label[hf]; */
753 /*  if k=non_address then goto done@+else q:=font_info[k].qqqq; l.17812 */
754 /*    if (k == font_mem_size) */
755     if (k == non_address)    /* i.e. 0 ---  96/Jan/15 */
756     goto lab30; 
757     else q = font_info[k].qqqq; 
758   } 
759   else {
760     q = font_info[char_base[hf]+ cur_l].qqqq; 
761     if (((q.b2)% 4)!= 1)
762     goto lab30; 
763     k = lig_kern_base[hf]+ q.b3; 
764     q = font_info[k].qqqq; 
765     if (q.b0 > 128)
766     {
767       k = lig_kern_base[hf]+ 256 * q.b2 + q.b3 + 32768L - 256 *(128); 
768       q = font_info[k].qqqq; 
769     } 
770   } 
771   if (currh < 256) /* if cur_rh < non_char then test_char:=cur_rh */
772     testchar = currh; 
773   else testchar = cur_r;  /* else test_char:=cur_r; l.17817 */
774 /* loop@+begin if next_char(q)=test_char then if skip_byte(q)<=stop_flag then */
775   while(true){
776     if (q.b1 == testchar)
777     if (q.b0 <= 128)
778     if (currh < 256)   /*  if cur_rh<non_char then */
779     {
780       hyphen_passed = j; 
781       hchar = 256; 
782       currh = 256; 
783       goto lab22;     /* goto continue; */
784     } 
785     else {    /* else begin if hchar<non_char then if odd(hyf[j]) then */
786     if (hchar < 256)
787       if (odd(hyf[j])) 
788       {
789   hyphen_passed = j; 
790   hchar = 256; 
791       } 
792       if (q.b2 < 128)  /* if op_byte(q)<kern_flag then */
793       {
794 // @<Carry out a ligature replacement, updating the cursor structure
795 //  and possibly advancing~|j|; |goto continue| if the cursor doesn't
796 //  advance, otherwise |goto done|@>;  => l.17869
797   if (cur_l == 256)    /* begin if cur_l=non_char then lft_hit:=true; */
798     lft_hit = true; 
799   if (j == n)
800     if (lig_stack == 0)/* if lig_stack=null ? */
801       rt_hit = true; 
802   {
803     if (interrupt != 0){
804       pause_for_instructions();
805     }
806   } 
807   switch(q.b2)  /* case op_byte(q) of */
808   {case 1 : 
809   case 5 : 
810     {
811       cur_l = q.b3; 
812       ligature_present = true; 
813     } 
814     break; 
815   case 2 : 
816   case 6 : 
817     {
818       cur_r = q.b3; 
819 /*   if lig_stack>null then character(lig_stack):=cur_r */
820 /*      if (lig_stack > 0) */      /* 94/Mar/22 */
821       if (lig_stack != 0)      /* line breaking?? */
822       mem[lig_stack].hh.b1 = cur_r; /* l.17877 ? */
823       else {
824         lig_stack = new_lig_item(cur_r); 
825         if (j == n)
826         bchar = 256; 
827         else {
828     p = get_avail(); 
829     mem[lig_stack + 1].hh.v.RH = p; 
830     mem[p].hh.b1 = hu[j + 1]; 
831     mem[p].hh.b0 = hf; 
832         } 
833       } 
834     } 
835     break; 
836   case 3 : 
837     {
838       cur_r = q.b3; 
839       p = lig_stack; 
840       lig_stack = new_lig_item(cur_r); 
841       mem[lig_stack].hh.v.RH = p; 
842     } 
843     break; 
844   case 7 : 
845   case 11 : 
846     {
847       if (ligature_present)
848       {
849         p = new_ligature(hf, cur_l, mem[cur_q].hh.v.RH); 
850         if (lft_hit)
851         {
852     mem[p].hh.b1 = 2; 
853     lft_hit = false; 
854         } 
855 /*        if (false)
856         if (lig_stack == 0){
857           incr(mem[p].hh.b1); 
858           rt_hit = false; 
859         } */              /* removed 99/Jan/6 */
860       mem[cur_q].hh.v.RH = p; 
861       t = p; 
862         ligature_present = false; 
863       } 
864       cur_q = t; 
865       cur_l = q.b3; 
866       ligature_present = true; 
867     } 
868     break; 
869     default: 
870     {
871 /* othercases begin cur_l:=rem_byte(q);
872     ligature_present:=true; {\.{=:}} l.17869 */
873       cur_l = q.b3; 
874       ligature_present = true; 
875 /*   if lig_stack>null then pop_lig_stack l.17870 => l.17828 */
876 /*      if (lig_stack > 0)*/       /* 94/Mar/22 ??? */
877       if (lig_stack != 0)        /* BUG FIX  */
878       {
879 /*        if (mem[lig_stack + 1].hh.v.RH > 0) */ /* 94/Mar/22  */
880         if (mem[lig_stack + 1].hh.v.RH != 0) /* l.17828 ? */
881         {
882     mem[t].hh.v.RH = mem[lig_stack + 1].hh.v.RH; 
883     t = mem[t].hh.v.RH; 
884     incr(j); 
885         } 
886         p = lig_stack; 
887         lig_stack = mem[p].hh.v.RH; 
888         free_node(p, 2); 
889         if (lig_stack == 0)  /* if lig_stack=null ? */
890         {
891     if (j < n)
892     cur_r = hu[j + 1]; 
893     else cur_r = bchar; 
894     if (odd(hyf[j])) 
895     currh = hchar; 
896     else currh = 256; 
897         } 
898         else cur_r = mem[lig_stack].hh.b1; 
899       } 
900       else if (j == n)
901       goto lab30; 
902       else {
903     
904         {
905     mem[t].hh.v.RH = get_avail(); 
906     t = mem[t].hh.v.RH; 
907     mem[t].hh.b0 = hf; 
908     mem[t].hh.b1 = cur_r; 
909         } 
910         incr(j); 
911         {
912     if (j < n)
913     cur_r = hu[j + 1]; 
914     else cur_r = bchar; 
915     if (odd(hyf[j])) 
916     currh = hchar; 
917     else currh = 256; 
918         } 
919       } 
920     } 
921     break; 
922   } 
923   if (q.b2 > 4)
924   if (q.b2 != 7)
925   goto lab30; 
926   goto lab22; 
927       } 
928       w = font_info[kern_base[hf]+ 256 * q.b2 + q.b3].cint; 
929       goto lab30; 
930     } 
931     if (q.b0 >= 128)
932     if (currh == 256)
933     goto lab30; 
934     else {
935   
936       currh = 256; 
937       goto lab22; 
938     } 
939     k = k + q.b0 + 1; 
940     q = font_info[k].qqqq; 
941   } 
942   lab30:; 
943   if (ligature_present)
944   {
945     p = new_ligature(hf, cur_l, mem[cur_q].hh.v.RH); 
946     if (lft_hit)
947     {
948       mem[p].hh.b1 = 2; 
949       lft_hit = false; 
950     } 
951     if (rt_hit)
952     if (lig_stack == 0)  /* if lig_stack=null ? */
953     {
954       incr(mem[p].hh.b1); 
955       rt_hit = false; 
956     } 
957     mem[cur_q].hh.v.RH = p; 
958     t = p; 
959     ligature_present = false; 
960   } 
961   if (w != 0)
962   {
963     mem[t].hh.v.RH = new_kern(w); 
964     t = mem[t].hh.v.RH; 
965     w = 0; 
966   } 
967 /*  if (lig_stack > 0)*/     /* 94/Mar/22 ??? l.17870 */
968   if (lig_stack != 0)        /* l.17841 */
969   {
970 /* begin cur_q:=t; cur_l:=character(lig_stack);
971   ligature_present:=true; l.17842 */
972     cur_q = t; 
973     cur_l = mem[lig_stack].hh.b1; 
974     ligature_present = true; 
975     {
976 /*   pop_lig_stack; goto continue; l.17843 => l.17828 */
977 /*      if (mem[lig_stack + 1].hh.v.RH > 0) *//* 94/Mar/22 */
978       if (mem[lig_stack + 1].hh.v.RH != 0) /* BUG FIX */
979       {
980   mem[t].hh.v.RH = mem[lig_stack + 1].hh.v.RH; 
981   t = mem[t].hh.v.RH; 
982   incr(j); 
983       } 
984       p = lig_stack; 
985       lig_stack = mem[p].hh.v.RH; 
986       free_node(p, 2); 
987       if (lig_stack == 0)
988       {
989   if (j < n)
990   cur_r = hu[j + 1]; 
991   else cur_r = bchar; 
992   if (odd(hyf[j])) 
993   currh = hchar; 
994   else currh = 256; 
995       } 
996       else cur_r = mem[lig_stack].hh.b1; 
997     } 
998     goto lab22; 
999   } 
1000   Result = j; 
1001   return Result; 
1002 }
1003 /* #pragma optimize ("g", off) */ /* not needed for MSVC it seems ... */
1004 void hyphenate (void) 
1005 {/* 50 30 40 41 42 45 10 */
1006 /*  char i, j, l;  */
1007   char i, j; 
1008   int l;              /* 95/Jan/7 */
1009   halfword q, r, s; 
1010   halfword bchar; 
1011   halfword majortail, minortail; 
1012 /*  ASCII_code c;  */
1013   int c;              /* 95/Jan/7 */
1014   char cloc; 
1015 /*  integer rcount; */
1016   int rcount;           /* 95/Jan/7 */
1017   halfword hyfnode; 
1018   trie_pointer z; 
1019   integer v; 
1020   hyph_pointer h; 
1021   str_number k; 
1022   pool_pointer u; 
1023   {
1024     register integer for_end; 
1025     j = 0; 
1026     for_end = hn; 
1027     if (j <= for_end) do 
1028       hyf[j]= 0; 
1029     while(j++ < for_end);
1030   } 
1031   h = hc[1]; 
1032   incr(hn); 
1033   hc[hn]= cur_lang; 
1034   {
1035     register integer for_end; 
1036     j = 2; 
1037     for_end = hn; 
1038     if (j <= for_end) do 
1039 /*    h =(h + h + hc[j])% 607;  */
1040       h =(h + h + hc[j])% hyphen_prime; 
1041     while(j++ < for_end);
1042   } 
1043   while(true){
1044     k = hyph_word[h]; 
1045     if (k == 0)
1046     goto lab45; 
1047     if (length(k) < hn)
1048     goto lab45; 
1049     if (length(k) == hn)
1050     {
1051       j = 1; 
1052       u = str_start[k]; 
1053       do {
1054     if (str_pool[u]< hc[j])
1055   goto lab45; 
1056   if (str_pool[u]> hc[j])
1057   goto lab30; 
1058   incr(j); 
1059   incr(u); 
1060       } while(!(j > hn)); 
1061       s = hyph_list[h]; 
1062       while(s != 0){  /* while s<>null do l.18173 */
1063     
1064   hyf[mem[s].hh.v.LH]= 1; 
1065   s = mem[s].hh.v.RH; 
1066       } 
1067       decr(hn); 
1068       goto lab40; 
1069     } 
1070     lab30:; 
1071     if (h > 0)
1072     decr(h); 
1073 /*    else h = 607;  */
1074     else h = hyphen_prime; 
1075   } 
1076   lab45: decr(hn); 
1077   if (trie_trc[cur_lang + 1]!= cur_lang)
1078   return; 
1079   hc[0]= 0; 
1080   hc[hn + 1]= 0; 
1081   hc[hn + 2]= 256; 
1082   {
1083     register integer for_end; 
1084     j = 0; 
1085     for_end = hn - rhyf + 1; 
1086     if (j <= for_end) do 
1087     {
1088       z = trie_trl[cur_lang + 1]+ hc[j]; 
1089       l = j; 
1090       while(hc[l]== trie_trc[z]){
1091       if (trie_tro[z]!= min_trie_op)
1092   {
1093     v = trie_tro[z]; 
1094     do {
1095         v = v + op_start[cur_lang]; 
1096       i = l - hyf_distance[v]; 
1097       if (hyf_num[v]> hyf[i])
1098       hyf[i]= hyf_num[v]; 
1099       v = hyf_next[v]; 
1100     } while(!(v == min_trie_op)); 
1101   } 
1102   incr(l); 
1103   z = trie_trl[z]+ hc[l]; 
1104       } 
1105     } 
1106   while(j++ < for_end); } 
1107   lab40: {
1108       register integer for_end; 
1109     j = 0; 
1110     for_end = lhyf - 1; 
1111     if (j <= for_end) do 
1112       hyf[j]= 0; 
1113     while(j++ < for_end);
1114      } 
1115   {
1116     register integer for_end; 
1117     j = 0; 
1118     for_end = rhyf - 1; 
1119     if (j <= for_end) do 
1120       hyf[hn - j]= 0; 
1121     while(j++ < for_end);
1122   } 
1123 /* was j = 0; for_end = rhyf - 1; in 3.141 */
1124   {
1125     register integer for_end; 
1126     j = lhyf; 
1127     for_end = hn - rhyf; 
1128     if (j <= for_end) do 
1129 /* lost if (j <= for_end) do since 3.141 */
1130       if (odd(hyf[j])) 
1131         goto lab41; 
1132     while(j++ < for_end);
1133   } 
1134   return; 
1135   lab41:; 
1136   q = mem[hb].hh.v.RH; 
1137   mem[hb].hh.v.RH = 0; 
1138   r = mem[ha].hh.v.RH; 
1139   mem[ha].hh.v.RH = 0; 
1140   bchar = hyfbchar; 
1141   if ((ha >= hi_mem_min)) 
1142   if (mem[ha].hh.b0 != hf)
1143   goto lab42; 
1144   else {
1145       
1146     init_list = ha; 
1147     init_lig = false; 
1148     hu[0]= mem[ha].hh.b1; 
1149   } 
1150   else if (mem[ha].hh.b0 == 6)
1151   if (mem[ha + 1].hh.b0 != hf)
1152   goto lab42; 
1153   else {
1154       
1155     init_list = mem[ha + 1].hh.v.RH; 
1156     init_lig = true; 
1157     init_lft =(mem[ha].hh.b1 > 1); 
1158     hu[0]= mem[ha + 1].hh.b1; 
1159     if (init_list == 0)
1160     if (init_lft)
1161     {
1162       hu[0]= 256; 
1163       init_lig = false; 
1164     } 
1165     free_node(ha, 2); 
1166   } 
1167   else {
1168       
1169     if (!(r >= hi_mem_min)) 
1170     if (mem[r].hh.b0 == 6)
1171     if (mem[r].hh.b1 > 1)
1172     goto lab42; 
1173     j = 1; 
1174     s = ha; 
1175     init_list = 0; 
1176     goto lab50; 
1177   } 
1178   s = cur_p; 
1179   while(mem[s].hh.v.RH != ha)s = mem[s].hh.v.RH; 
1180   j = 0; 
1181   goto lab50; 
1182   lab42: s = ha; 
1183   j = 0; 
1184   hu[0]= 256; 
1185   init_lig = false; 
1186   init_list = 0; 
1187   lab50: flush_node_list(r); 
1188   do {
1189       l = j; 
1190     j = reconstitute(j, hn, bchar, hyf_char)+ 1; 
1191     if (hyphen_passed == 0)
1192     {
1193       mem[s].hh.v.RH = mem[hold_head].hh.v.RH; 
1194 /*      while(mem[s].hh.v.RH > 0)*/ /* 94/Mar/22 */
1195       while(mem[s].hh.v.RH != 0)    /* l.17903 */
1196       s = mem[s].hh.v.RH; 
1197       if (odd(hyf[j - 1])) 
1198       {
1199   l = j; 
1200   hyphen_passed = j - 1; 
1201   mem[hold_head].hh.v.RH = 0; /* link(hold_head):=null; */
1202       } 
1203     } 
1204     if (hyphen_passed > 0)
1205     do {
1206   r = get_node(2); 
1207       mem[r].hh.v.RH = mem[hold_head].hh.v.RH; 
1208       mem[r].hh.b0 = 7; 
1209       majortail = r; 
1210       rcount = 0; 
1211 /* while link(major_tail)>null do advance_major_tail; l.17929 */
1212 /*      while(mem[majortail].hh.v.RH > 0){ */ /* 94/Mar/22 */
1213       while(mem[majortail].hh.v.RH != 0){   /* ??? */
1214     
1215   majortail = mem[majortail].hh.v.RH; 
1216   incr(rcount); 
1217       } 
1218       i = hyphen_passed; 
1219       hyf[i]= 0; 
1220 /* minor_tail:=null; pre_break(r):=null; l.17943 */
1221       minortail = 0; 
1222       mem[r + 1].hh.v.LH = 0; 
1223 /* hyf_node:=new_character(hf,hyf_char); */
1224       hyfnode = new_character(hf, hyf_char); 
1225       if (hyfnode != 0)  /* if hyf_node<>null then */
1226       {
1227   incr(i); 
1228   c = hu[i]; 
1229   hu[i]= hyf_char; 
1230   {
1231     mem[hyfnode].hh.v.RH = avail; 
1232     avail = hyfnode; 
1233   ;
1234 #ifdef STAT
1235     decr(dyn_used); 
1236 #endif /* STAT */
1237   } 
1238       } 
1239       while(l <= i){
1240 /*  begin l:=reconstitute(l,i,font_bchar[hf],non_char)+1; l.17948 */
1241   l = reconstitute(l, i, font_bchar[hf], 256)+ 1; 
1242 /*  if link(hold_head)>null then l.17949 */
1243 /*  if (mem[hold_head].hh.v.RH > 0)*/  /* 94/Mar/22 */
1244   if (mem[hold_head].hh.v.RH != 0) /* BUG FIX ??? */
1245   {
1246     if (minortail == 0)/*      if minor_tail=null then */
1247     mem[r + 1].hh.v.LH = mem[hold_head].hh.v.RH; 
1248     else mem[minortail].hh.v.RH = mem[hold_head].hh.v.RH; 
1249     minortail = mem[hold_head].hh.v.RH; 
1250 /*    while link(minor_tail)>null do minor_tail:=link(minor_tail); l.17953 */
1251 /*    while(mem[minortail].hh.v.RH > 0)*/ /* 94/Mar/22 */
1252     while(mem[minortail].hh.v.RH != 0)  /* BUG FIX */
1253       minortail = mem[minortail].hh.v.RH; 
1254   } 
1255       } 
1256       if (hyfnode != 0) /* if hyf_node<>null then l.17956 */
1257       {
1258   hu[i]= c; 
1259   l = i; 
1260   decr(i); 
1261       } 
1262 /* minor_tail:=null; post_break(r):=null; c_loc:=0; l.17964 */
1263       minortail = 0; 
1264       mem[r + 1].hh.v.RH = 0; 
1265       cloc = 0; 
1266 /* if bchar_label[hf]<non_address then l.17991 3.1415 */
1267 /*      if (bchar_label[hf]< font_mem_size) */
1268 /* if bchar_label[hf]<>non_address then l.17991 3.14159 */
1269       if (bchar_label[hf]!= non_address) /* i.e. 0 --- 96/Jan/15 */
1270       {
1271   decr(l); 
1272   c = hu[l]; 
1273   cloc = l; 
1274   hu[l]= 256; 
1275       } 
1276       while(l < j){
1277     
1278   do {
1279       l = reconstitute(l, hn, bchar, 256)+ 1; 
1280     if (cloc > 0)
1281     {
1282       hu[cloc]= c;    /* c may be used ... */
1283       cloc = 0; 
1284     } 
1285 /*   if link(hold_head)>null then l. l.17973 */
1286 /*    if (mem[hold_head].hh.v.RH > 0)  */    /* 94/Mar/22 ??? */
1287     if (mem[hold_head].hh.v.RH != 0)     /* BUG FIX */
1288     {
1289       if (minortail == 0)/*     begin if minor_tail=null then */
1290       mem[r + 1].hh.v.RH = mem[hold_head].hh.v.RH; 
1291       else mem[minortail].hh.v.RH = mem[hold_head].hh.v.RH; 
1292       minortail = mem[hold_head].hh.v.RH; 
1293 /*     while link(minor_tail)>null do minor_tail:=link(minor_tail); l.17977 */
1294 /*      while(mem[minortail].hh.v.RH > 0)*/ /* 94/Mar/22 */
1295       while(mem[minortail].hh.v.RH != 0)    /* ??? */
1296       minortail = mem[minortail].hh.v.RH; 
1297     } 
1298   } while(!(l >= j)); 
1299   while(l > j){
1300       
1301     j = reconstitute(j, hn, bchar, 256)+ 1; 
1302     mem[majortail].hh.v.RH = mem[hold_head].hh.v.RH; 
1303 /* while link(major_tail)>null do advance_major_tail; l.17987 */
1304 /*    while(mem[majortail].hh.v.RH > 0){ */ /* 94/Mar/22 */
1305     while(mem[majortail].hh.v.RH != 0){   /* ??? */
1306       majortail = mem[majortail].hh.v.RH; 
1307       incr(rcount); 
1308     } 
1309   } 
1310       } 
1311       if (rcount > 127)
1312       {
1313   mem[s].hh.v.RH = mem[r].hh.v.RH; 
1314   mem[r].hh.v.RH = 0; /* link(r):=null */
1315   flush_node_list(r); 
1316       } 
1317       else {
1318     
1319   mem[s].hh.v.RH = r; 
1320   mem[r].hh.b1 = rcount; 
1321       } 
1322       s = majortail; 
1323       hyphen_passed = j - 1; 
1324       mem[hold_head].hh.v.RH = 0;  /* link(hold_head):=null; */
1325     } while(!(! odd(hyf[j - 1]))); 
1326   } while(!(j > hn)); 
1327   mem[s].hh.v.RH = q; 
1328   flush_list(init_list); 
1329
1330 /* #pragma optimize ("g", off) */ /* not needed for MSVC it seems ... */
1331 /* used only in itex.c */
1332 void new_hyph_exceptions (void) 
1333 {/* 21 10 40 45 */ 
1334 /*  small_number n;  */ /* in 3.141 */
1335   char n; 
1336 /*  small_number j;  */ /* in 3.141 */
1337   char j; 
1338   hyph_pointer h; 
1339   str_number k; 
1340   halfword p; 
1341   halfword q; 
1342   str_number s, t; 
1343   pool_pointer u, v; 
1344   scan_left_brace(); 
1345   if (language <= 0)
1346     cur_lang = 0; 
1347   else if (language > 255)
1348     cur_lang = 0; 
1349   else cur_lang = language; 
1350   n = 0; 
1351   p = 0; 
1352
1353   while(true){
1354     get_x_token(); 
1355
1356 lab21: switch(cur_cmd){
1357     case 11 : 
1358     case 12 : 
1359     case 68 : 
1360       if (cur_chr == 45)
1361       {
1362   if (n < 63)
1363   {
1364     q = get_avail(); 
1365     mem[q].hh.v.RH = p; 
1366     mem[q].hh.v.LH = n; 
1367     p = q; 
1368   } 
1369       } 
1370       else {
1371     
1372   if (eqtb[(hash_size + 2139) + cur_chr].hh.v.RH == 0)
1373   {
1374           print_err("Not a letter");
1375           help2("Letters in \\hyphenation words must have \\lccode>0.",
1376                   "Proceed; I'll ignore the character I just read.");
1377     error(); 
1378   } 
1379   else if (n < 63)
1380   {
1381     incr(n); 
1382     hc[n]= eqtb[(hash_size + 2139) + cur_chr].hh.v.RH; 
1383   } 
1384       } 
1385       break; 
1386     case 16 : 
1387       {
1388   scan_char_num(); 
1389   cur_chr = cur_val; 
1390   cur_cmd = 68; 
1391   goto lab21; 
1392       } 
1393       break; 
1394     case 10 : 
1395     case 2 : 
1396       {
1397   if (n > 1)
1398   {
1399     incr(n); 
1400     hc[n]= cur_lang; 
1401     {
1402 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1403 #ifdef ALLOCATESTRING
1404       if (pool_ptr + n > current_pool_size)
1405 /*      str_pool = realloc_str_pool (increment_pool_size); */
1406       str_pool = realloc_str_pool (increment_pool_size + n);
1407       if (pool_ptr + n > current_pool_size){ /* in case it failed 94/Jan/24 */
1408       overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
1409       return;     // abort_flag set
1410     }
1411 #else
1412 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1413       if (pool_ptr + n > pool_size){
1414       overflow("pool size", pool_size - init_pool_ptr); /* pool size */
1415       return;     // abort_flag set
1416     }
1417 #endif
1418     } 
1419     h = 0; 
1420     {
1421       register integer for_end; 
1422       j = 1; 
1423       for_end = n; 
1424       if (j <= for_end) do 
1425       {
1426 /*      h =(h + h + hc[j])% 607;  */
1427         h =(h + h + hc[j])% hyphen_prime; 
1428         {
1429           str_pool[pool_ptr]= hc[j]; 
1430           incr(pool_ptr); 
1431         } 
1432       } 
1433       while(j++ < for_end);
1434     } 
1435     s = make_string(); 
1436 /*    if (hyph_count == 607)*/
1437     if (hyph_count == hyphen_prime){
1438 /*      overflow(942, 607);  */ 
1439       overflow("exception dictionary", hyphen_prime); /* exception dictionary - NOT DYNAMIC */
1440 /*    not dynamic ---- but can be set -e=... from command line in ini-TeX */
1441       return;     // abort_flag set
1442     }
1443     incr(hyph_count); 
1444     while (hyph_word[h]!= 0) {
1445       k = hyph_word[h];
1446       if (length(k) < length(s))
1447         goto lab40;
1448       if (length(k) > length(s))
1449         goto lab45; 
1450       u = str_start[k]; 
1451       v = str_start[s]; 
1452       do {
1453     if (str_pool[u]< str_pool[v])
1454         goto lab40; 
1455         if (str_pool[u]> str_pool[v])
1456         goto lab45; 
1457         incr(u); 
1458         incr(v); 
1459       } while(!(u == str_start[k + 1])); 
1460       lab40: q = hyph_list[h]; 
1461       hyph_list[h]= p; 
1462       p = q; 
1463       t = hyph_word[h]; 
1464       hyph_word[h]= s; 
1465       s = t; 
1466       lab45:; 
1467       if (h > 0)
1468       decr(h); 
1469 /*      else h = 607;  */
1470       else h = hyphen_prime; 
1471     } 
1472     hyph_word[h]= s; 
1473     hyph_list[h]= p; 
1474   } 
1475   if (cur_cmd == 2)
1476   return; 
1477   n = 0; 
1478   p = 0; 
1479       } 
1480       break; 
1481       default: 
1482       {
1483                   print_err("Improper ");
1484   print_esc("hyphenation");
1485   print_string("will be flushed");
1486   help2("Hyphenation exceptions must contain only letters",
1487           "and hyphens. But continue; I'll forgive and forget.");
1488   error(); 
1489     }
1490       break; 
1491   } /* end of switch */
1492   }
1493
1494 halfword prune_page_top_(halfword p)
1495 {register halfword Result;
1496   halfword prevp; 
1497   halfword q; 
1498   prevp = temp_head; 
1499   mem[temp_head].hh.v.RH = p; 
1500 /* while p<>null do l.18803 */
1501   while(p != 0)switch(mem[p].hh.b0)
1502   {case 0 : 
1503   case 1 : 
1504   case 2 : 
1505     {
1506       q = new_skip_param(10); 
1507       mem[prevp].hh.v.RH = q; 
1508       mem[q].hh.v.RH = p; 
1509       if (mem[temp_ptr + 1].cint > mem[p + 3].cint)
1510       mem[temp_ptr + 1].cint = mem[temp_ptr + 1].cint - mem[p + 3]
1511      .cint; 
1512       else mem[temp_ptr + 1].cint = 0; 
1513       p = 0;  /* p:=null */
1514     } 
1515     break; 
1516   case 8 : 
1517   case 4 : 
1518   case 3 : 
1519     {
1520       prevp = p; 
1521       p = mem[prevp].hh.v.RH; 
1522     } 
1523     break; 
1524   case 10 : 
1525   case 11 : 
1526   case 12 : 
1527     {
1528       q = p; 
1529       p = mem[q].hh.v.RH; 
1530       mem[q].hh.v.RH = 0; 
1531       mem[prevp].hh.v.RH = p; 
1532       flush_node_list(q); 
1533     } 
1534     break; 
1535     default: 
1536     {
1537       confusion("pruning");
1538       return 0;       // abort_flag set
1539     }
1540     break; 
1541   } 
1542   Result = mem[temp_head].hh.v.RH; 
1543   return Result; 
1544
1545 halfword vert_break_(halfword p, scaled h, scaled d)
1546 {/* 30 45 90 */ register halfword Result;
1547   halfword prevp; 
1548   halfword q, r; 
1549   integer pi; 
1550   integer b; 
1551   integer leastcost; 
1552   halfword best_place; 
1553   scaled prevdp; 
1554 /*  small_number t;  */
1555   int t;              /* 95/Jan/7 */
1556   prevp = p; 
1557   leastcost = 1073741823L;  /* 2^30 - 1 */
1558   active_width[1]= 0; 
1559   active_width[2]= 0; 
1560   active_width[3]= 0; 
1561   active_width[4]= 0; 
1562   active_width[5]= 0; 
1563   active_width[6]= 0; 
1564   prevdp = 0; 
1565   while(true){
1566     if (p == 0)  /* if p=null l.18879 */
1567     pi = -10000; 
1568     else switch(mem[p].hh.b0)
1569     {case 0 : 
1570     case 1 : 
1571     case 2 : 
1572       {
1573   active_width[1]= active_width[1]+ prevdp + mem[p + 3].cint; 
1574   prevdp = mem[p + 2].cint; 
1575   goto lab45; 
1576       } 
1577       break; 
1578     case 8 : 
1579       goto lab45; 
1580       break; 
1581     case 10 : 
1582       if ((mem[prevp].hh.b0 < 9)) 
1583       pi = 0; 
1584       else goto lab90; 
1585       break; 
1586     case 11 : 
1587       {
1588   if (mem[p].hh.v.RH == 0)/* if link(p)=null l.18903 */
1589   t = 12; 
1590   else t = mem[mem[p].hh.v.RH].hh.b0; 
1591   if (t == 10)
1592   pi = 0; 
1593   else goto lab90; 
1594       } 
1595       break; 
1596     case 12 : 
1597       pi = mem[p + 1].cint; 
1598       break; 
1599     case 4 : 
1600     case 3 : 
1601       goto lab45; 
1602       break; 
1603       default: 
1604       {
1605         confusion("vertbreak");
1606         return 0;       // abort_flag set
1607       }
1608       break; 
1609     } 
1610     if (pi < 10000)      /* pi may be used ... */
1611     {
1612       if (active_width[1]< h)
1613       if ((active_width[3]!= 0)||(active_width[4]!= 0)||(
1614       active_width[5]!= 0)) 
1615       b = 0; 
1616       else b = badness(h - active_width[1], active_width[2]); 
1617       else if (active_width[1]- h > active_width[6])
1618       b = 1073741823L;  /* 2^30 - 1 */
1619       else b = badness(active_width[1]- h, active_width[6]); 
1620       if (b < 1073741823L) /* 2^30 - 1 */
1621       if (pi <= -10000)
1622       b = pi; 
1623       else if (b < 10000)
1624       b = b + pi; 
1625       else b = 100000L; 
1626       if (b <= leastcost)
1627       {
1628   best_place = p; 
1629   leastcost = b; 
1630   best_height_plus_depth = active_width[1]+ prevdp; 
1631       } 
1632       if ((b == 1073741823L)||(pi <= -10000))  /* 2^30 - 1 */
1633       goto lab30; 
1634     } 
1635     if ((mem[p].hh.b0 < 10)||(mem[p].hh.b0 > 11)) 
1636     goto lab45; 
1637     lab90: if (mem[p].hh.b0 == 11)
1638     q = p; 
1639     else {
1640   
1641       q = mem[p + 1].hh.v.LH; 
1642       active_width[2 + mem[q].hh.b0]= active_width[2 + mem[q]
1643       .hh.b0]+ mem[q + 2].cint; 
1644       active_width[6]= active_width[6]+ mem[q + 3].cint; 
1645       if ((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0)) 
1646       {
1647                   print_err("Infinite glue shrinkage found in box being split");
1648                   help4("The box you are \\vsplitting contains some infinitely",
1649                           "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
1650                           "Such glue doesn't belong there; but you can safely proceed,",
1651                           "since the offensive shrinkability has been made finite.");
1652   error(); 
1653   r = new_spec(q); 
1654   mem[r].hh.b1 = 0; 
1655   delete_glue_ref(q); 
1656   mem[p + 1].hh.v.LH = r; 
1657   q = r; 
1658       } 
1659     } 
1660     active_width[1]= active_width[1]+ prevdp + mem[q + 1].cint; 
1661     prevdp = 0; 
1662     lab45: if (prevdp > d)
1663     {
1664       active_width[1]= active_width[1]+ prevdp - d; 
1665       prevdp = d; 
1666     } 
1667     prevp = p; 
1668     p = mem[prevp].hh.v.RH; 
1669   } 
1670   lab30: Result = best_place; /* best_place may be used ... */
1671   return Result; 
1672
1673 /* called only from tex7.c */
1674 halfword vsplit_(eight_bits n, scaled h)
1675 {/* 10 30 */ register halfword Result;
1676   halfword v; 
1677   halfword p; 
1678   halfword q; 
1679   v = eqtb[(hash_size + 1578) + n].hh.v.RH; 
1680   if (cur_mark[3]!= 0)
1681   {
1682     delete_token_ref(cur_mark[3]); 
1683     cur_mark[3]= 0; 
1684     delete_token_ref(cur_mark[4]); 
1685     cur_mark[4]= 0; 
1686   } 
1687   if (v == 0)    /* if v=null then l.18999 */
1688   {
1689     Result = 0; /*   begin vsplit:=null; return; */
1690     return(Result); 
1691   } 
1692   if (mem[v].hh.b0 != 1)
1693   {
1694           print_err("");
1695     print_esc("vsplit");
1696     print_string("needs a ");
1697     print_esc("vbox");
1698         help2("The box you are trying to split is an \\hbox.",
1699                 "I can't split such a box, so I'll leave it alone.");
1700     error(); 
1701     Result = 0; 
1702     return(Result); 
1703   } 
1704   q = vert_break(mem[v + 5].hh.v.RH, h, split_max_depth); 
1705   p = mem[v + 5].hh.v.RH; 
1706   if (p == q)
1707   mem[v + 5].hh.v.RH = 0; 
1708   else while(true){
1709     if (mem[p].hh.b0 == 4)
1710     if (cur_mark[3]== 0)
1711     {
1712       cur_mark[3]= mem[p + 1].cint; 
1713       cur_mark[4]= cur_mark[3]; 
1714       mem[cur_mark[3]].hh.v.LH = mem[cur_mark[3]].hh.v.LH + 2; 
1715     } 
1716     else {
1717       delete_token_ref(cur_mark[4]); 
1718       cur_mark[4]= mem[p + 1].cint; 
1719       incr(mem[cur_mark[4]].hh.v.LH); 
1720     } 
1721     if (mem[p].hh.v.RH == q)
1722     {
1723       mem[p].hh.v.RH = 0; 
1724       goto lab30; 
1725     } 
1726     p = mem[p].hh.v.RH; 
1727   } 
1728   lab30:; 
1729   q = prune_page_top(q); 
1730   p = mem[v + 5].hh.v.RH; 
1731   free_node(v, 7); 
1732   if (q == 0)    /* if q=null l.18993 */
1733   eqtb[(hash_size + 1578) + n].hh.v.RH = 0;  /* then box(n):=null */
1734   else eqtb[(hash_size + 1578) + n].hh.v.RH =
1735     vpackage(q, 0, 1, 1073741823L);  /* 2^30 - 1 */
1736   Result = vpackage(p, h, 0, split_max_depth); 
1737   return Result; 
1738
1739 void print_totals (void) 
1740
1741   print_scaled(page_so_far[1]); 
1742   if (page_so_far[2]!= 0)
1743   {
1744     print_string(" plus ");
1745     print_scaled(page_so_far[2]); 
1746     print_string("");
1747   } 
1748   if (page_so_far[3]!= 0)
1749   {
1750     print_string(" plus ");
1751     print_scaled(page_so_far[3]); 
1752     print_string("fil");
1753   } 
1754   if (page_so_far[4]!= 0)
1755   {
1756     print_string(" plus ");
1757     print_scaled(page_so_far[4]); 
1758     print_string("fill");
1759   } 
1760   if (page_so_far[5]!= 0)
1761   {
1762     print_string(" plus ");
1763     print_scaled(page_so_far[5]); 
1764     print_string("filll");
1765   } 
1766   if (page_so_far[6]!= 0)
1767   {
1768     print_string(" minus ");
1769     print_scaled(page_so_far[6]); 
1770   } 
1771
1772 void freeze_page_specs_(small_number s)
1773
1774   page_contents = s; 
1775   page_so_far[0]= vsize; 
1776   page_max_depth = max_depth; 
1777   page_so_far[7]= 0; 
1778   page_so_far[1]= 0; 
1779   page_so_far[2]= 0; 
1780   page_so_far[3]= 0; 
1781   page_so_far[4]= 0; 
1782   page_so_far[5]= 0; 
1783   page_so_far[6]= 0; 
1784   least_page_cost = 1073741823L;  /* 2^30 - 1 */
1785   ;
1786 #ifdef STAT
1787   if (tracing_pages > 0)
1788   {
1789     begin_diagnostic(); 
1790     print_nl("might split");  /*  */
1791     print_scaled(page_so_far[0]); 
1792     print_string(", max depth=");
1793     print_scaled(page_max_depth); 
1794     end_diagnostic(false); 
1795   } 
1796 #endif /* STAT */
1797
1798 void box_error_(eight_bits n)
1799 {
1800     error(); 
1801   begin_diagnostic(); 
1802   print_nl("The following box has been deleted:");  /*  */
1803   show_box(eqtb[(hash_size + 1578) + n].hh.v.RH); 
1804   end_diagnostic(true); 
1805   flush_node_list(eqtb[(hash_size + 1578) + n].hh.v.RH); 
1806   eqtb[(hash_size + 1578) + n].hh.v.RH = 0; 
1807
1808 void ensure_vbox_(eight_bits n)
1809 {
1810   halfword p; 
1811   p = eqtb[(hash_size + 1578) + n].hh.v.RH; 
1812   if (p != 0) /* if p<>null then if type(p)=hlist_node then l.19324 */
1813   if (mem[p].hh.b0 == 0)
1814   {
1815           print_err("Insertions can only be added to a vbox");
1816           help3("Tut tut: You're trying to \\insert into a",
1817                   "\\box register that now contains an \\hbox.",
1818                   "Proceed, and I'll discard its present contents.");
1819     box_error(n); 
1820   } 
1821
1822 /* called only from tex7.c */
1823 void fire_up_(halfword c)
1824 {/* 10 */ 
1825   halfword p, q, r, s; 
1826   halfword prevp; 
1827 /*  unsigned char n;  */
1828   unsigned int n;         /* 95/Jan/7 */
1829   bool wait; 
1830   integer savevbadness; 
1831   scaled savevfuzz; 
1832   halfword savesplittopskip; 
1833   if (mem[best_page_break].hh.b0 == 12)
1834   {
1835     geq_word_define((hash_size + 3202), mem[best_page_break + 1].cint); 
1836     mem[best_page_break + 1].cint = 10000; 
1837   } 
1838   else geq_word_define((hash_size + 3202), 10000); 
1839   if (cur_mark[2]!= 0)
1840   {
1841     if (cur_mark[0]!= 0)
1842     delete_token_ref(cur_mark[0]); 
1843     cur_mark[0]= cur_mark[2]; 
1844     incr(mem[cur_mark[0]].hh.v.LH); 
1845     delete_token_ref(cur_mark[1]); 
1846     cur_mark[1]= 0; 
1847   } 
1848   if (c == best_page_break)
1849   best_page_break = 0; 
1850   if (eqtb[(hash_size + 1833)].hh.v.RH != 0)
1851   {
1852           print_err("");
1853     print_esc("box");
1854     print_string("255 is not void");
1855         help2("You shouldn't use \\box255 except in \\output routines.",
1856                 "Proceed, and I'll discard its present contents.");
1857     box_error(255); 
1858   } 
1859   insert_penalties = 0; 
1860   savesplittopskip = eqtb[(hash_size + 792)].hh.v.RH; 
1861   if (holding_inserts <= 0)
1862   {
1863     r = mem[mem_top].hh.v.RH; 
1864     while(r != mem_top){
1865   
1866       if (mem[r + 2].hh.v.LH != 0)
1867       {
1868   n = mem[r].hh.b1; 
1869   ensure_vbox(n); 
1870 /*    if box(n)=null then box(n):=new_null_box; l.19759 */
1871   if (eqtb[(hash_size + 1578) + n].hh.v.RH == 0)
1872   eqtb[(hash_size + 1578) + n].hh.v.RH = new_null_box(); 
1873   p = eqtb[(hash_size + 1578) + n].hh.v.RH + 5; 
1874   while(mem[p].hh.v.RH != 0)p = mem[p].hh.v.RH; 
1875   mem[r + 2].hh.v.RH = p; 
1876       } 
1877       r = mem[r].hh.v.RH; 
1878     } 
1879   } 
1880   q = hold_head; 
1881   mem[q].hh.v.RH = 0; 
1882   prevp = page_head; 
1883   p = mem[prevp].hh.v.RH; 
1884   while(p != best_page_break){
1885       
1886     if (mem[p].hh.b0 == 3)
1887     {
1888       if (holding_inserts <= 0)
1889       {
1890   r = mem[mem_top].hh.v.RH; 
1891   while(mem[r].hh.b1 != mem[p].hh.b1)r = mem[r].hh.v.RH 
1892   ; 
1893 /*  if best_ins_ptr(r)=null then wait:=true l.19783 */
1894   if (mem[r + 2].hh.v.LH == 0)
1895   wait = true; 
1896   else {
1897       
1898     wait = false; 
1899     s = mem[r + 2].hh.v.RH; 
1900     mem[s].hh.v.RH = mem[p + 4].hh.v.LH; 
1901     if (mem[r + 2].hh.v.LH == p)
1902     {
1903       if (mem[r].hh.b0 == 1)
1904       if ((mem[r + 1].hh.v.LH == p)&&(mem[r + 1].hh.v.RH 
1905       != 0)) 
1906       {
1907         while(mem[s].hh.v.RH != mem[r + 1].hh.v.RH)s = mem 
1908        [s].hh.v.RH; 
1909         mem[s].hh.v.RH = 0; 
1910         eqtb[(hash_size + 792)].hh.v.RH = mem[p + 4].hh.v.RH; 
1911         mem[p + 4].hh.v.LH = prune_page_top(mem[r + 1].hh.v.RH 
1912       ); 
1913         if (mem[p + 4].hh.v.LH != 0)
1914         {
1915     temp_ptr = vpackage(mem[p + 4].hh.v.LH, 0, 1, 
1916     1073741823L);  /* 2^30 - 1 */
1917     mem[p + 3].cint = mem[temp_ptr + 3].cint + mem[
1918     temp_ptr + 2].cint; 
1919     free_node(temp_ptr, 7); 
1920     wait = true; 
1921         } 
1922       } 
1923       mem[r + 2].hh.v.LH = 0; 
1924       n = mem[r].hh.b1; 
1925       temp_ptr = mem[eqtb[(hash_size + 1578) + n].hh.v.RH + 5].hh.v.RH; 
1926       free_node(eqtb[(hash_size + 1578) + n].hh.v.RH, 7); 
1927       eqtb[(hash_size + 1578) + n].hh.v.RH = vpackage(temp_ptr, 0, 1, 
1928       1073741823L);  /* 2^30 - 1 */
1929     } 
1930     else {
1931         
1932       while(mem[s].hh.v.RH != 0)s = mem[s].hh.v.RH; 
1933       mem[r + 2].hh.v.RH = s; 
1934     } 
1935   } 
1936   mem[prevp].hh.v.RH = mem[p].hh.v.RH; 
1937   mem[p].hh.v.RH = 0; 
1938   if (wait)
1939   {
1940     mem[q].hh.v.RH = p; 
1941     q = p; 
1942     incr(insert_penalties); 
1943   } 
1944   else {
1945       
1946     delete_glue_ref(mem[p + 4].hh.v.RH); 
1947     free_node(p, 5); 
1948   } 
1949   p = prevp; 
1950       } 
1951     } 
1952     else if (mem[p].hh.b0 == 4)
1953     {
1954       if (cur_mark[1]== 0)
1955       {
1956   cur_mark[1]= mem[p + 1].cint; 
1957   incr(mem[cur_mark[1]].hh.v.LH); 
1958       } 
1959       if (cur_mark[2]!= 0)
1960       delete_token_ref(cur_mark[2]); 
1961       cur_mark[2]= mem[p + 1].cint; 
1962       incr(mem[cur_mark[2]].hh.v.LH); 
1963     } 
1964     prevp = p; 
1965     p = mem[prevp].hh.v.RH; 
1966   } 
1967   eqtb[(hash_size + 792)].hh.v.RH = savesplittopskip; 
1968   if (p != 0)    /* if p<>null then l.19730 */
1969   {
1970     if (mem[contrib_head].hh.v.RH == 0)/* if link(contrib_head)=null then */
1971     if (nest_ptr == 0)
1972     tail = page_tail; 
1973     else nest[0].tail_field = page_tail; 
1974     mem[page_tail].hh.v.RH = mem[contrib_head].hh.v.RH; 
1975     mem[contrib_head].hh.v.RH = p; 
1976     mem[prevp].hh.v.RH = 0; /*   link(prev_p):=null; */
1977   } 
1978   savevbadness = vbadness; 
1979   vbadness = 10000; 
1980   savevfuzz = eqtb[(hash_size + 3739)].cint; 
1981   eqtb[(hash_size + 3739)].cint = 1073741823L;  /* 2^30 - 1 */
1982   eqtb[(hash_size + 1833)].hh.v.RH = vpackage(mem[page_head].hh.v.RH, 
1983   best_size, 0, page_max_depth); 
1984   vbadness = savevbadness; 
1985   eqtb[(hash_size + 3739)].cint = savevfuzz; 
1986 /*  if (last_glue != 262143L) */
1987   if (last_glue != empty_flag)
1988   delete_glue_ref(last_glue); 
1989   page_contents = 0; 
1990   page_tail = page_head; 
1991   mem[page_head].hh.v.RH = 0; 
1992 /*  last_glue = 262143L;  */
1993   last_glue = empty_flag; 
1994   last_penalty = 0; 
1995   last_kern = 0; 
1996   page_so_far[7]= 0; 
1997   page_max_depth = 0; 
1998   if (q != hold_head)
1999   {
2000     mem[page_head].hh.v.RH = mem[hold_head].hh.v.RH; 
2001     page_tail = q; 
2002   } 
2003   r = mem[mem_top].hh.v.RH; 
2004   while(r != mem_top){
2005       
2006     q = mem[r].hh.v.RH; 
2007     free_node(r, 4); 
2008     r = q; 
2009   } 
2010   mem[mem_top].hh.v.RH = mem_top; 
2011 /* if (top_mark<>null)and(first_mark=null) then l.19654 */
2012   if ((cur_mark[0]!= 0)&&(cur_mark[1]== 0)) 
2013   {
2014     cur_mark[1]= cur_mark[0]; 
2015     incr(mem[cur_mark[0]].hh.v.LH); 
2016   } 
2017 /* if output_routine<>null then */
2018   if (output_routine != 0)
2019   if (dead_cycles >= max_dead_cycles)
2020   {
2021           print_err("Output loop---");
2022     print_int(dead_cycles); 
2023     print_string(" consecutive dead cycles");
2024         help3("I've concluded that your \\output is awry; it never does",
2025                 "\\ship_out, so I'm shipping \box255 out myself. Next ",
2026                 "increase \\maxdeadcycles if you want me to be more patient!");
2027     error(); 
2028   } 
2029   else {
2030     output_active = true; 
2031     incr(dead_cycles); 
2032     push_nest(); 
2033     mode = -1; 
2034     cur_list.aux_field.cint = ignore_depth; 
2035     mode_line = - (integer) line; 
2036     begin_token_list(output_routine, 6); /* output */
2037     new_save_level(8); 
2038     normal_paragraph(); 
2039     scan_left_brace(); 
2040     return; 
2041   } 
2042   {
2043     if (mem[page_head].hh.v.RH != 0)
2044     {
2045       if (mem[contrib_head].hh.v.RH == 0)
2046       if (nest_ptr == 0)
2047       tail = page_tail; 
2048       else nest[0].tail_field = page_tail; 
2049       else mem[page_tail].hh.v.RH = mem[contrib_head].hh.v.RH; 
2050       mem[contrib_head].hh.v.RH = mem[page_head].hh.v.RH; 
2051       mem[page_head].hh.v.RH = 0; 
2052       page_tail = page_head; 
2053     } 
2054     ship_out(eqtb[(hash_size + 1833)].hh.v.RH);
2055     eqtb[(hash_size + 1833)].hh.v.RH = 0; 
2056   } 
2057
2058 /* used to continue here with build_page etc in tex6.c */
2059