OSDN Git Service

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