OSDN Git Service

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