OSDN Git Service

297e242d14800e4c7b8be3d44734dadb377561ad
[putex/putex.git] / src / texsourc / tex4.c
1 /* Copyright 2014 Clerk Ma
2
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License as published by
5    the Free Software Foundation; either version 2 of the License, or
6    (at your option) any later version.
7
8    This program is distributed in the hope that it will be useful, but
9    WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11    General Public License for more details.
12
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16    02110-1301 USA.  */
17
18 #define EXTERN extern
19
20 #include "texd.h"
21
22 /* sec 0581 */
23 void char_warning_(internal_font_number f, eight_bits c)
24
25   if (tracing_lost_chars > 0)
26   {
27     if (show_missing == 0)
28       begin_diagnostic();
29
30     if (show_missing) /* add ! before 94/June/10 */
31     {
32       print_nl("! ");
33       print_string("Missing character: there is no ");
34     }
35     else
36       print_nl("Missing character: there is no ");
37
38     print(c);
39
40     if (show_numeric) /* bkph 93/Dec/21 */
41     {
42       print_char(' ');
43       print_char('(');
44
45       if (c / 100 > 0)
46       {
47         print_char(48 + c / 100);
48 /*      c = c % 100; */
49         c = c - (c / 100) * 100;      /* ? */
50         print_char(48 + c / 10);
51       }
52       else
53       {
54 /*      c = c % 100; */
55         c = c - (c / 100) * 100;      /* ? */
56         if (c / 10 > 0) print_char(48 + c / 10);
57       }
58       print_char(48 + c % 10);
59       print_char(')');
60 /*    print_char(32); */
61     }
62 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
63     print_string(" in font ");
64     slow_print(font_name[f]);
65     print_char('!');
66 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
67 /*  if (show_missing) show_context(); */    /* in tex2.c 94/June/10 */
68     if (show_missing)
69     {
70       if (f != 0)
71         show_context();     /* not if its the nullfont */
72     }
73
74     if (show_missing == 0)            /* show on screen 94/June/10 */
75       end_diagnostic(false);
76
77     missing_characters++;           /* bkph 93/Dec/16 */
78 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
79   }
80 }
81 /* sec 0582 */
82 halfword new_character_(internal_font_number f, eight_bits c)
83 {
84   halfword p;
85
86   if (font_bc[f] <= c)
87     if (font_ec[f] >= c)
88       if (char_exists(char_info(f, c)))
89       {
90         p = get_avail();
91         font(p) = f;
92         character(p) = c;
93         return p;
94       }
95
96   char_warning(f, c);
97   return 0;
98 }
99 /* sec 0598 */
100 void dvi_swap (void)
101
102   if (trace_flag)
103   {
104     show_char('\n');
105     sprintf(log_line, "dvi_swap %d", dvi_gone);
106     show_line(log_line, 0);
107   }
108
109   if (dvi_limit == dvi_buf_size)
110   {
111     write_dvi(0, half_buf - 1);
112     dvi_limit = half_buf;
113     dvi_offset = dvi_offset + dvi_buf_size;
114     dvi_ptr = 0;
115   }
116   else
117   {
118     write_dvi(half_buf, dvi_buf_size - 1);
119     dvi_limit = dvi_buf_size;
120   }
121
122   dvi_gone = dvi_gone + half_buf;
123 }
124 /* sec 0600 */
125 void dvi_four_(integer x)
126
127   if (x >= 0)
128     dvi_out(x / 0100000000);
129   else
130   {
131     x = x + 010000000000;
132     x = x + 010000000000;
133     dvi_out((x / 0100000000) + 128);
134   }
135
136   x = x % 0100000000;
137   dvi_out(x / 0200000);
138   x = x % 0200000;
139   dvi_out(x / 0400);
140   dvi_out(x % 0400);
141 }
142 /* sec 0601 */
143 void dvi_pop_(integer l)
144 {
145   if ((l == dvi_offset + dvi_ptr) && (dvi_ptr > 0))
146     decr(dvi_ptr);
147   else
148     dvi_out(pop);
149 }
150 /* sec 0602 */
151 void dvi_font_def_(internal_font_number f)
152 {
153   pool_pointer k;
154
155 #ifdef INCREASEFONTS
156   if (f <= 256)
157   {
158     dvi_out(fnt_def1);
159     dvi_out(f - 1);
160   }
161   else
162   {
163     dvi_out(fnt_def2);
164     dvi_out(((f - 1) >> 8));
165     dvi_out(((f - 1) & 255));
166   }
167 #else
168   dvi_out(fnt_def1);
169   dvi_out(f - 1);
170 #endif
171
172   dvi_out(font_check[f].b0);
173   dvi_out(font_check[f].b1);
174   dvi_out(font_check[f].b2);
175   dvi_out(font_check[f].b3);
176   dvi_four(font_size[f]); 
177   dvi_four(font_dsize[f]);
178   dvi_out(length(font_area[f]));
179   dvi_out(length(font_name[f]));
180
181   for (k = str_start[font_area[f]]; k <= str_start[font_area[f] + 1] - 1; k++)
182     dvi_out(str_pool[k]);
183
184   for (k = str_start[font_name[f]]; k <= str_start[font_name[f] + 1] - 1; k++)
185     dvi_out(str_pool[k]);
186 }
187 /* sec 0607 */
188 void zmovement(scaled w, eight_bits o)
189 {
190   small_number mstate;
191   halfword p, q;
192   integer k;
193
194   q = get_node(movement_node_size);
195   width(q) = w;
196   location(q) = dvi_offset + dvi_ptr;
197
198   if (o == down1)
199   {
200     link(q) = down_ptr;
201     down_ptr = q;
202   }
203   else
204   {
205     link(q) = right_ptr;
206     right_ptr = q;
207   }
208
209   p = link(q);
210   mstate = none_seen;
211
212   while (p != 0)
213   {
214     if (width(p) == w)
215       switch(mstate + info(p))
216       {
217         case none_seen + yz_OK:
218         case none_seen + y_OK:
219         case z_seen + yz_OK:
220         case z_seen + y_OK:
221           if (location(p) < dvi_gone)
222             goto lab45;
223           else
224           {
225             k = location(p) - dvi_offset;
226
227             if (k < 0)
228               k = k + dvi_buf_size;
229
230             dvi_buf[k] = dvi_buf[k] + y1 - down1;
231             info(p) = y_here;
232             goto lab40;
233           }
234           break;
235
236         case none_seen + z_OK:
237         case y_seen + yz_OK:
238         case y_seen + z_OK:
239           if (location(p) < dvi_gone)
240             goto lab45;
241           else
242           {
243             k = location(p) - dvi_offset;
244
245             if (k < 0)
246               k = k + dvi_buf_size;
247
248             dvi_buf[k] = dvi_buf[k] + z1 - down1;
249             info(p) = z_here;
250             goto lab40;
251           }
252           break;
253
254         case none_seen + y_here:
255         case none_seen + z_here:
256         case y_seen + z_here:
257         case z_seen + y_here:
258           goto lab40;
259           break;
260
261         default:
262           break;
263       }
264     else switch (mstate + info(p))
265     {
266       case none_seen + y_here:
267         mstate = y_seen;
268         break;
269
270       case none_seen + z_here:
271         mstate = z_seen;
272         break;
273
274       case y_seen + z_here:
275       case z_seen + y_here:
276         goto lab45;
277         break;
278
279       default:
280         break;
281     }
282     p = link(p);
283   }
284 lab45:
285
286   info(q) = yz_OK;
287
288   if (abs(w) >= 8388608L) /* 2^23 */
289   {
290     dvi_out(o + 3);
291     dvi_four(w);
292     return;
293   }
294
295   if (abs(w) >= 32768L)
296   {
297     dvi_out(o + 2);
298
299     if (w < 0)
300       w = w + 16777216L;  /* 2^24 */
301     //dvi_out(w / 65536L);
302     dvi_out((w >> 16));
303 /*    w = w % 65536L; */
304     w = w & 65535L;
305     goto lab2;
306   }
307
308   if (abs(w)>= 128)
309   {
310     dvi_out(o + 1);
311
312     if (w < 0)
313       w = w + 65536L;
314
315     goto lab2;
316   }
317
318   dvi_out(o);
319
320   if (w < 0)
321     w = w + 256;
322
323   goto lab1;
324 lab2:
325   //dvi_out(w / 256);
326   dvi_out((w >> 8));
327 lab1:
328   //dvi_out(w % 256);
329   dvi_out(w & 255);
330   return;
331 lab40:
332   info(q) = info(p);
333
334   if (info(q) == y_here)
335   {
336     dvi_out(o + y0 - down1);
337
338     while (link(q) != p)
339     {
340       q = link(q);
341
342       switch (info(q))
343       {
344         case yz_OK:
345           info(q) = z_OK;
346           break;
347
348         case y_OK:
349           info(q) = d_fixed;
350           break;
351
352         default:
353           break;
354       }
355     }
356   }
357   else
358   {
359     dvi_out(o + z0 - down1);
360
361     while (link(q) != p)
362     {
363       q = link(q);
364
365       switch (info(q))
366       {
367         case yz_OK:
368           info(q) = y_OK;
369           break;
370
371         case z_OK:
372           info(q) = d_fixed;
373           break;
374
375         default:
376           break;
377       }
378     }
379   }
380 }
381 /* sec 0615 */
382 void prune_movements_(integer l)
383 {
384   halfword p;
385
386   while (down_ptr != 0)
387   {
388     if (location(down_ptr) < l)
389       goto lab30;
390
391     p = down_ptr;
392     down_ptr = link(p);
393     free_node(p, movement_node_size);
394   }
395
396 lab30:
397   while (right_ptr != 0)
398   {
399     if (location(right_ptr) < l)
400       return;
401
402     p = right_ptr;
403     right_ptr = link(p);
404     free_node(p, movement_node_size);
405   }
406 }
407 /* sec 1368 */
408 void special_out_(pointer p)
409 {
410   char old_setting;
411   pool_pointer k;
412
413   synch_h();
414   synch_v();
415   old_setting = selector;
416   selector = new_string;
417
418 #ifdef ALLOCATESTRING
419   if (pool_ptr + 32000 > current_pool_size)
420     str_pool = realloc_str_pool (increment_pool_size);
421
422   show_token_list(link(write_tokens(p)), 0, 10000000L);
423 #else
424   show_token_list(link(write_tokens(p)), 0, pool_size - pool_ptr);
425 #endif
426
427   selector = old_setting;
428   str_room(1);
429
430   if (cur_length < 256)
431   {
432     dvi_out(xxx1);
433     dvi_out(cur_length);
434   }
435   else
436   {
437     dvi_out(xxx4);
438     dvi_four(cur_length); 
439   } 
440
441   for (k = str_start[str_ptr]; k <= pool_ptr - 1; k++)
442     dvi_out(str_pool[k]);
443
444   pool_ptr = str_start[str_ptr];
445 }
446 /* sec 1370 */
447 void write_out_(pointer p)
448 {
449   char old_setting;
450 /*  integer oldmode;  */
451   int oldmode;          /* 1995/Jan/7 */
452 /*  small_number j;  */
453   int j;              /* 1995/Jan/7 */
454   halfword q, r;
455
456   q = get_avail();
457   info(q) = right_brace_token + '}';
458   r = get_avail();
459   link(q) = r;
460   info(r) = end_write_token;
461   ins_list(q);
462   begin_token_list(write_tokens(p), write_text);
463   q = get_avail();
464   info(q) = left_brace_token + '{';
465   ins_list(q);
466   oldmode = mode;
467   mode = 0;
468   cur_cs = write_loc;
469   q = scan_toks(false, true);
470   get_token();
471
472   if (cur_tok != end_write_token)
473   {
474     print_err("Unbalanced write command");
475     help2("On this page there's a \\write with fewer real {'s than }'s.",
476         "I can't handle that very well; good luck.");
477     error();
478
479     do
480       {
481         get_token();
482       }
483     while (!(cur_tok == end_write_token));
484   }
485
486   mode = oldmode;
487   end_token_list();
488   old_setting = selector;
489   j = write_stream(p);
490
491   if (write_open[j])
492     selector = j;
493   else
494   {
495     if ((j == 17) && (selector == term_and_log))
496       selector = log_only;
497
498     print_nl("");
499   }
500
501   token_show(def_ref);
502   print_ln();
503   flush_list(def_ref);
504   selector = old_setting;
505 }
506 /* sec 1373 */
507 void out_what_(pointer p)
508 {
509 /*  small_number j;  */
510   int j;            /* 1995/Jan/7 */
511
512   switch (subtype(p))
513   {
514     case open_node:
515     case write_node:
516     case close_node:
517       if (!doing_leaders)
518       {
519         j = write_stream(p);
520
521         if (subtype(p) == write_node)
522         {
523           write_out(p);
524         }
525         else
526         {
527           if (write_open[j])
528             (void) a_close(write_file[j]); 
529
530           if (subtype(p) == close_node)
531             write_open[j]= false; 
532           else if (j < 16)
533           {
534             cur_name = open_name(p);
535             cur_area = open_area(p);
536             cur_ext = open_ext(p); 
537
538             if (cur_ext == 335)  /* "" */
539               cur_ext = 785;  /* => ".tex" */
540
541             pack_file_name(cur_name, cur_area, cur_ext);
542
543             while (! a_open_out(write_file[j]))
544             {
545               prompt_file_name("output file name", ".tex");
546             }
547
548             write_open[j] = true;
549           }
550         }
551       }
552       break; 
553
554     case special_node:
555       special_out(p); 
556       break;
557
558     case language_node:
559       ;
560       break;
561
562     default:
563       {
564         confusion("ext4");
565         return;
566       }
567       break;
568   }
569 }
570 /* sec 0619 */
571 void hlist_out (void)
572 {
573   scaled base_line;
574   scaled left_edge;
575   scaled save_h, save_v;
576   halfword this_box;
577 /*  glue_ord g_order;  */
578   int g_order;           /* 95/Jan/7 */
579 /*  char g_sign;  */
580   int g_sign;            /* 95/Jan/7 */
581   halfword p;
582   integer save_loc;
583   halfword leader_box;
584   scaled leader_wd;
585   scaled lx;
586   boolean outer_doing_leaders;
587   scaled edge;
588   real glue_temp;
589   real cur_glue;
590   scaled cur_g;
591
592   cur_g = 0;
593   cur_glue = 0.0;
594   this_box = temp_ptr;
595   g_order = glue_order(this_box);
596   g_sign = glue_sign(this_box);
597   p = list_ptr(this_box);
598   incr(cur_s);
599
600   if (cur_s > 0)
601     dvi_out(push);
602
603   if (cur_s > max_push)
604     max_push = cur_s;
605
606   save_loc = dvi_offset + dvi_ptr;
607   base_line = cur_v;
608   left_edge = cur_h;
609
610   while (p != 0)
611 lab21:
612     if (is_char_node(p))
613     {
614       synch_h();
615       synch_v();
616
617       do
618         {
619           f = font(p);
620           c = character(p);
621
622           if (f != dvi_f)
623           {
624             if (!font_used[f])
625             {
626               dvi_font_def(f);
627               font_used[f] = true;
628             }
629
630             if (f <= 64 + font_base)
631               dvi_out(f - font_base - 1 + fnt_num_0);
632 #ifdef INCREASEFONTS
633             /* if we allow greater than 256 fonts */
634             else if (f <= 256)
635             {
636               dvi_out(fnt1);
637               dvi_out(f - 1);
638             }
639 #else
640             else
641             {
642               dvi_out(fnt1);
643               dvi_out(f - 1);
644             }
645 #endif
646
647 #ifdef INCREASEFONTS
648             else
649             {
650               dvi_out(fnt2);
651               dvi_out(((f - 1) >> 8));  /* top byte */
652               dvi_out(((f - 1) & 255)); /* bottom byte */
653             }
654 #endif
655
656             dvi_f = f;
657           }
658
659           if (c >= 128)
660             dvi_out(set1);
661
662           dvi_out(c);
663           cur_h = cur_h + char_width(f, char_info(f, c));
664           p = link(p);
665         }
666       while (!(!is_char_node(p)));
667
668       dvi_h = cur_h;
669   }
670   else
671   {
672     switch (type(p))
673     {
674       case hlist_node:
675       case vlist_node:
676         if (list_ptr(p) == 0)
677           cur_h = cur_h + width(p);
678         else
679         {
680           save_h = dvi_h;
681           save_v = dvi_v;
682           cur_v = base_line + shift_amount(p);
683           temp_ptr = p;
684           edge = cur_h;
685
686           if (type(p) == vlist_node)
687             vlist_out();
688           else
689             hlist_out();
690
691           dvi_h = save_h;
692           dvi_v = save_v;
693           cur_h = edge + width(p);
694           cur_v = base_line;
695         }
696         break;
697
698       case rule_node:
699         {
700           rule_ht = height(p);
701           rule_dp = depth(p);
702           rule_wd = width(p);
703           goto lab14;
704         }
705         break;
706
707       case whatsit_node:
708         out_what(p);
709         break;
710
711       case glue_node:
712         {
713           g = glue_ptr(p);
714           rule_wd = width(g) - cur_g;
715
716           if (g_sign != normal)
717           {
718             if (g_sign == stretching)
719             {
720               if (stretch_order(g) == g_order)
721               {
722                 cur_glue = cur_glue + stretch(g);
723                 glue_temp = glue_set(this_box) * cur_glue;
724
725                 if (glue_temp > 1000000000.0)
726                   glue_temp = 1000000000.0;
727                 else if (glue_temp < -1000000000.0)
728                   glue_temp = -1000000000.0;
729
730                 cur_g = round(glue_temp);
731               }
732             }
733             else if (shrink_order(g) == g_order)
734             {
735               cur_glue = cur_glue - shrink(g);
736               glue_temp = glue_set(this_box) * cur_glue;
737
738               if (glue_temp > 1000000000.0)
739                 glue_temp = 1000000000.0;
740               else if (glue_temp < -1000000000.0)
741                 glue_temp = -1000000000.0;
742
743               cur_g = round(glue_temp);
744             }
745           }
746
747           rule_wd = rule_wd + cur_g;
748
749           if (subtype(p) >= a_leaders)
750           {
751             leader_box = leader_ptr(p);
752
753             if (type(leader_box) == rule_node)
754             {
755               rule_ht = height(leader_box);
756               rule_dp = depth(leader_box);
757               goto lab14;
758             }
759
760             leader_wd = width(leader_box);
761
762             if ((leader_wd > 0) && (rule_wd > 0))
763             {
764               rule_wd = rule_wd + 10;
765               edge = cur_h + rule_wd;
766               lx = 0;
767
768               if (subtype(p) == a_leaders)
769               {
770                 save_h = cur_h;
771                 cur_h = left_edge + leader_wd * ((cur_h - left_edge) / leader_wd);
772
773                 if (cur_h < save_h)
774                   cur_h = cur_h + leader_wd;
775               }
776               else
777               {
778                 lq = rule_wd / leader_wd;
779                 lr = rule_wd % leader_wd;
780
781                 if (subtype(p) == c_leaders)
782                   cur_h = cur_h + (lr / 2);
783                 else
784                 {
785                   lx =(2 * lr + lq + 1) / (2 * lq + 2);
786                   cur_h = cur_h + ((lr - (lq - 1)* lx) / 2);
787                 }
788               }
789
790               while (cur_h + leader_wd <= edge)
791               {
792                 cur_v = base_line + shift_amount(leader_box);
793                 synch_v();
794                 save_v = dvi_v;
795                 synch_h();
796                 save_h = dvi_h;
797                 temp_ptr = leader_box;
798                 outer_doing_leaders = doing_leaders;
799                 doing_leaders = true;
800
801                 if (type(leader_box) == vlist_node)
802                   vlist_out();
803                 else
804                   hlist_out();
805
806                 doing_leaders = outer_doing_leaders;
807                 dvi_v = save_v;
808                 dvi_h = save_h;
809                 cur_v = base_line;
810                 cur_h = save_h + leader_wd + lx;
811               }
812
813               cur_h = edge - 10;
814               goto lab15;
815             }
816           }
817
818           goto lab13;
819         }
820         break;
821
822       case kern_node:
823       case math_node:
824         cur_h = cur_h + width(p);
825         break;
826
827       case ligature_node:
828         {
829           mem[lig_trick] = mem[lig_char(p)];
830           link(lig_trick) = link(p);
831           p = lig_trick;
832           goto lab21;
833         }
834         break;
835
836       default:
837         break;
838     }
839
840     goto lab15;
841 lab14:
842     if ((rule_ht == -1073741824L))  /* - 2^30 */
843       rule_ht = height(this_box);
844
845     if ((rule_dp == -1073741824L))     /* - 2^30 */
846       rule_dp = depth(this_box);
847
848     rule_ht = rule_ht + rule_dp;
849
850     if ((rule_ht > 0) && (rule_wd > 0))
851     {
852       synch_h();
853       cur_v = base_line + rule_dp;
854       synch_v();
855       dvi_out(set_rule);
856       dvi_four(rule_ht);
857       dvi_four(rule_wd);
858       cur_v = base_line;
859       dvi_h = dvi_h + rule_wd;
860     }
861 lab13:
862     cur_h = cur_h + rule_wd;
863 lab15:
864     p = link(p);
865   }
866
867   prune_movements(save_loc);
868
869   if (cur_s > 0)
870     dvi_pop(save_loc);
871
872   decr(cur_s);
873 }
874 /* sec 0629 */
875 void vlist_out (void)
876 {
877   scaled left_edge;
878   scaled top_edge;
879   scaled save_h, save_v;
880   halfword this_box;
881 /*  glue_ord g_order;  */
882   int g_order;         /* 95/Jan/7 */
883 /*  char g_sign;  */
884   int g_sign;          /* 95/Jan/7 */
885   halfword p;
886   integer save_loc;
887   halfword leader_box;
888   scaled leader_ht;
889   scaled lx;
890   boolean outer_doing_leaders;
891   scaled edge;
892   real glue_temp;
893   real cur_glue;
894   scaled cur_g;
895
896   cur_g = 0;
897   cur_glue = 0.0;
898   this_box = temp_ptr;
899   g_order = glue_order(this_box);
900   g_sign = glue_sign(this_box);
901   p = list_ptr(this_box);
902   incr(cur_s);
903
904   if (cur_s > 0)
905     dvi_out(push);
906
907   if (cur_s > max_push)
908     max_push = cur_s;
909
910   save_loc = dvi_offset + dvi_ptr;
911   left_edge = cur_h;
912   cur_v = cur_v - height(this_box);
913   top_edge = cur_v;
914
915   while (p != 0)
916   {
917     if (is_char_node(p))
918     {
919       confusion("vlistout");
920       return;
921     }
922     else
923     {
924       switch (type(p))
925       {
926         case hlist_node:
927         case vlist_node:
928           if (list_ptr(p) == 0)
929             cur_v = cur_v + height(p) + depth(p);
930           else
931           {
932             cur_v = cur_v + height(p);
933             synch_v();
934             save_h = dvi_h;
935             save_v = dvi_v;
936             cur_h = left_edge + shift_amount(p);
937             temp_ptr = p;
938
939             if (type(p) == vlist_node)
940               vlist_out();
941             else
942               hlist_out();
943
944             dvi_h = save_h;
945             dvi_v = save_v;
946             cur_v = save_v + depth(p);
947             cur_h = left_edge;
948           }
949           break;
950
951         case rule_node:
952           {
953             rule_ht = height(p);
954             rule_dp = depth(p);
955             rule_wd = width(p);
956             goto lab14;
957           }
958           break;
959
960         case whatsit_node:
961           out_what(p);
962           break;
963
964         case glue_node:
965           {
966             g = glue_ptr(p);
967             rule_ht = width(g) - cur_g;
968
969             if (g_sign != normal)
970             {
971               if (g_sign == stretching)
972               {
973                 if (stretch_order(g) == g_order)
974                 {
975                   cur_glue = cur_glue + stretch(g);
976                   glue_temp = glue_set(this_box) * cur_glue;
977
978                   if (glue_temp > 1000000000.0)
979                     glue_temp = 1000000000.0;
980                   else if (glue_temp < -1000000000.0)
981                     glue_temp = -1000000000.0;
982
983                   cur_g = round(glue_temp);
984                 }
985               }
986               else if (shrink_order(g) == g_order)   /* BUG FIX !!! */
987               {
988                 cur_glue = cur_glue - shrink(g);
989                 glue_temp = glue_set(this_box) * cur_glue;
990
991                 if (glue_temp > 1000000000.0)
992                   glue_temp = 1000000000.0;
993                 else if (glue_temp < -1000000000.0)
994                   glue_temp = -1000000000.0;
995
996                 cur_g = round(glue_temp);
997               }
998             }
999
1000             rule_ht = rule_ht + cur_g;
1001
1002             if (subtype(p) >= a_leaders)
1003             {
1004               leader_box = leader_ptr(p);
1005
1006               if (type(leader_box) == rule_node)
1007               {
1008                 rule_wd = width(leader_box);
1009                 rule_dp = 0;
1010                 goto lab14;
1011               }
1012
1013               leader_ht = height(leader_box) + depth(leader_box);
1014
1015               if ((leader_ht > 0) && (rule_ht > 0))
1016               {
1017                 rule_ht = rule_ht + 10;
1018                 edge = cur_v + rule_ht;
1019                 lx = 0;
1020
1021                 if (subtype(p) == a_leaders)
1022                 {
1023                   save_v = cur_v;
1024                   cur_v = top_edge + leader_ht * ((cur_v - top_edge) / leader_ht);
1025
1026                   if (cur_v < save_v)
1027                     cur_v = cur_v + leader_ht;
1028                 }
1029                 else
1030                 {
1031                   lq = rule_ht / leader_ht;
1032                   lr = rule_ht % leader_ht;
1033
1034                   if (subtype(p) == c_leaders)
1035                     cur_v = cur_v + (lr / 2);
1036                   else
1037                   {
1038                     lx = (2 * lr + lq + 1) / (2 * lq + 2);
1039                     cur_v = cur_v + ((lr - (lq - 1) * lx) / 2);
1040                   }
1041                 }
1042
1043                 while (cur_v + leader_ht <= edge)
1044                 {
1045                   cur_h = left_edge + shift_amount(leader_box);
1046                   synch_h();
1047                   save_h = dvi_h;
1048                   cur_v = cur_v + height(leader_box);
1049                   synch_v();
1050                   save_v = dvi_v;
1051                   temp_ptr = leader_box;
1052                   outer_doing_leaders = doing_leaders;
1053                   doing_leaders = true;
1054
1055                   if (type(leader_box) == vlist_node)
1056                     vlist_out();
1057                   else
1058                     hlist_out();
1059
1060                   doing_leaders = outer_doing_leaders;
1061                   dvi_v = save_v;
1062                   dvi_h = save_h;
1063                   cur_h = left_edge;
1064                   cur_v = save_v - height(leader_box) + leader_ht + lx;
1065                 }
1066
1067                 cur_v = edge - 10;
1068                 goto lab15;
1069               }
1070             }
1071
1072             goto lab13;
1073           }
1074           break;
1075
1076         case kern_node:
1077           cur_v = cur_v + width(p);
1078           break;
1079
1080         default:
1081           break;
1082       }
1083       goto lab15;
1084 lab14:
1085       if ((rule_wd == -1073741824L))    /* -2^30 */
1086         rule_wd = width(this_box);
1087
1088       rule_ht = rule_ht + rule_dp;
1089       cur_v = cur_v + rule_ht;
1090
1091       if ((rule_ht > 0) && (rule_wd > 0))
1092       {
1093         synch_h();
1094         synch_v();
1095         dvi_out(put_rule);
1096         dvi_four(rule_ht);
1097         dvi_four(rule_wd);
1098       }
1099
1100       goto lab15;
1101 lab13:
1102       cur_v = cur_v + rule_ht;
1103     }
1104 lab15:
1105     p = link(p);
1106   }
1107
1108   prune_movements(save_loc);
1109
1110   if (cur_s > 0)
1111     dvi_pop(save_loc);
1112
1113   decr(cur_s);
1114 }
1115 /* sec 0638 */
1116 void dvi_ship_out_(halfword p)
1117 {
1118   integer page_loc;
1119   char j, k;
1120   pool_pointer s;
1121   char old_setting;
1122
1123   if (tracing_output > 0)
1124   {
1125     print_nl("");
1126     print_ln();
1127     print_string("Completed box being shipped out");
1128   }
1129
1130   if (term_offset > max_print_line - 9)
1131     print_ln();
1132   else if ((term_offset > 0) || (file_offset > 0))
1133     print_char(' ');
1134
1135   print_char('[');
1136   j = 9;
1137
1138   while ((count(j) == 0) && (j > 0))
1139     decr(j);
1140
1141   for (k = 0; k <= j; k++)
1142   {
1143     print_int(count(k));
1144
1145     if (k < j)
1146       print_char('.');
1147   }
1148
1149 #ifndef _WINDOWS
1150   fflush(stdout);
1151 #endif
1152
1153   if (tracing_output > 0)
1154   {
1155     print_char(']');
1156     begin_diagnostic();
1157     show_box(p);
1158     end_diagnostic(true);
1159   }
1160
1161   if ((height(p) > max_dimen) || (depth(p) > max_dimen) ||
1162       (height(p) + depth(p) + v_offset > max_dimen) ||
1163       (width(p) + h_offset > max_dimen))
1164   {
1165     print_err("Huge page cannot be shipped out");
1166     help2("The page just created is more than 18 feet tall or",
1167         "more than 18 feet wide, so I suspect something went wrong.");
1168     error();
1169
1170     if (tracing_output <= 0)
1171     {
1172       begin_diagnostic();
1173       print_nl("The following box has been deleted:");
1174       show_box(p);
1175       end_diagnostic(true);
1176     }
1177
1178     goto lab30;
1179   }
1180
1181   if (height(p) + depth(p) + v_offset > max_v)
1182     max_v = height(p) + depth(p) + v_offset;
1183
1184   if (width(p) + h_offset > max_h)
1185     max_h = width(p) + h_offset;
1186
1187   dvi_h = 0;
1188   dvi_v = 0;
1189   cur_h = h_offset;
1190   dvi_f = null_font;
1191   ensure_dvi_open();
1192
1193   if (total_pages == 0)
1194   {
1195     dvi_out(pre);
1196     dvi_out(id_byte);
1197     dvi_four(25400000L);  /* magic DVI scale factor */
1198     dvi_four(473628672L); /* 7227 * 65536 */
1199     prepare_mag();
1200     dvi_four(mag);
1201     old_setting = selector;
1202     selector = new_string;
1203     print_string(" TeX output ");
1204     print_int(year);
1205     print_char('.');
1206     print_two(month);
1207     print_char('.');
1208     print_two(day);
1209     print_char(':');
1210     print_two(tex_time / 60);
1211     print_two(tex_time % 60);
1212     selector = old_setting;
1213     dvi_out(cur_length);
1214
1215     for (s = str_start[str_ptr]; s <= pool_ptr - 1; s++)
1216       dvi_out(str_pool[s]);
1217
1218     pool_ptr = str_start[str_ptr];
1219   }
1220
1221   page_loc = dvi_offset + dvi_ptr;
1222   dvi_out(bop);
1223
1224   for (k = 0; k <= 9; k++)
1225     dvi_four(count(k));
1226
1227   dvi_four(last_bop);
1228   last_bop = page_loc;
1229   cur_v = height(p) + v_offset;
1230   temp_ptr = p;
1231
1232   if (type(p) == vlist_node)
1233     vlist_out();
1234   else
1235     hlist_out();
1236
1237   dvi_out(eop);
1238   incr(total_pages);
1239   cur_s = -1;
1240
1241 lab30:;
1242   if (tracing_output <= 0)
1243     print_char(']');
1244
1245   dead_cycles = 0;
1246
1247 #ifndef _WINDOWS
1248   fflush(stdout);
1249 #endif
1250
1251 #ifdef STAT
1252   if (tracing_stats > 1)
1253   {
1254     print_nl("Memory usage before: ");
1255     print_int(var_used);
1256     print_char('&');
1257     print_int(dyn_used);
1258     print_char(';');
1259   }
1260 #endif
1261
1262   flush_node_list(p);
1263
1264 #ifdef STAT
1265   if (tracing_stats > 1)
1266   {
1267     print_string(" after: ");
1268     print_int(var_used);
1269     print_char('&');
1270     print_int(dyn_used);
1271     print_string("; still utouched: ");
1272     print_int(hi_mem_min - lo_mem_max - 1);
1273     print_ln();
1274   }
1275 #endif
1276 }
1277 void ship_out_(halfword p)
1278 {
1279   switch (shipout_flag)
1280   {
1281     case out_dvi_flag:
1282     case out_xdv_flag:
1283       dvi_ship_out_(p);
1284       break;
1285   }
1286 }
1287 /* sec 0645 */
1288 void scan_spec_(group_code c, boolean three_codes)
1289 {
1290   integer s;
1291   char spec_code;
1292
1293   if (three_codes)
1294     s = saved(0);
1295
1296   if (scan_keyword("to"))
1297     spec_code = exactly;
1298   else if (scan_keyword("spread"))
1299     spec_code = additional;
1300   else
1301   {
1302     spec_code = additional;
1303     cur_val = 0;
1304     goto lab40;
1305   }
1306
1307   scan_dimen(false, false, false);
1308
1309 lab40:
1310   if (three_codes)
1311   {
1312     saved(0) = s;
1313     incr(save_ptr);
1314   }
1315
1316   saved(0) = spec_code;
1317   saved(1) = cur_val;
1318   save_ptr = save_ptr + 2;
1319   new_save_level(c);
1320   scan_left_brace();
1321 }
1322 /* sec 0649 */
1323 halfword hpack_(halfword p, scaled w, small_number m)
1324 {
1325   halfword r;
1326   halfword q;
1327   scaled h, d, x;
1328   scaled s;
1329   halfword g;
1330 /*  glue_ord o;  */
1331   int o;              /* 95/Jan/7 */
1332   internal_font_number f;
1333   four_quarters i;
1334   eight_bits hd;
1335
1336   last_badness = 0;
1337   r = get_node(box_node_size);
1338   type(r) = hlist_node;
1339   subtype(r) = 0;
1340   shift_amount(r) = 0;
1341   q = r + list_offset;
1342   link(q) = p;
1343   h = 0;
1344   d = 0;
1345   x = 0;
1346   total_stretch[normal] = 0;
1347   total_shrink[normal] = 0;
1348   total_stretch[fil] = 0;
1349   total_shrink[fil] = 0;
1350   total_stretch[fill] = 0;
1351   total_shrink[fill] = 0;
1352   total_stretch[filll] = 0;
1353   total_shrink[filll] = 0;
1354
1355   while (p != 0)
1356   {
1357 lab21:
1358     while (is_char_node(p))
1359     {
1360       f = font(p);
1361       i = char_info(f, character(p));
1362       hd = height_depth(i);
1363       x = x + char_width(f, i);
1364       s = char_height(f, hd);
1365
1366       if (s > h)
1367         h = s;
1368
1369       s = char_depth(f, hd);
1370
1371       if (s > d)
1372         d = s;
1373
1374       p = link(p);
1375     }
1376
1377     if (p != 0)
1378     {
1379       switch (type(p))
1380       {
1381         case hlist_node:
1382         case vlist_node:
1383         case rule_node:
1384         case unset_node:
1385           {
1386             x = x + width(p);
1387
1388             if (type(p) >= rule_node)
1389               s = 0;
1390             else
1391               s = shift_amount(p);
1392
1393             if (height(p) - s > h)
1394               h = height(p) - s;
1395
1396             if (depth(p) + s > d)
1397               d = depth(p) + s;
1398           }
1399           break;
1400
1401         case ins_node:
1402         case mark_node:
1403         case adjust_node:
1404           if (adjust_tail != 0)
1405           {
1406             while (link(q) != p)
1407               q = link(q);
1408
1409             if (type(p) == adjust_node)
1410             {
1411               link(adjust_tail) = adjust_ptr(p);
1412
1413               while (link(adjust_tail) != 0)
1414                 adjust_tail = link(adjust_tail);
1415
1416               p = link(p);
1417               free_node(link(q), small_node_size);
1418             }
1419             else
1420             {
1421               link(adjust_tail) = p;
1422               adjust_tail = p;
1423               p = link(p);
1424             }
1425
1426             link(q) = p;
1427             p = q;
1428           }
1429           break;
1430
1431         case whatsit_node:
1432           break;
1433         case glue_node:
1434           {
1435             g = glue_ptr(p);
1436             x = x + width(g);
1437             o = stretch_order(g);
1438             total_stretch[o] = total_stretch[o] + stretch(g);
1439             o = shrink_order(g);
1440             total_shrink[o] = total_shrink[o] + shrink(g);
1441
1442             if (subtype(p) >= a_leaders)
1443             {
1444               g = leader_ptr(p);
1445
1446               if (height(g) > h)
1447                 h = height(g);
1448
1449               if (depth(g) > d)
1450                 d = depth(g);
1451             }
1452           }
1453           break;
1454
1455         case kern_node:
1456         case math_node:
1457           x = x + width(p);
1458           break;
1459
1460         case ligature_node:
1461           {
1462             mem[lig_trick] = mem[lig_char(p)];
1463             link(lig_trick) = link(p);
1464             p = lig_trick;
1465             goto lab21;
1466           }
1467           break;
1468
1469         default:
1470           break;
1471       }
1472       p = link(p);
1473     }
1474   }
1475
1476   if (adjust_tail != 0)
1477     link(adjust_tail) = 0;
1478
1479   height(r) = h;
1480   depth(r) = d;
1481
1482   if (m == additional)
1483     w = x + w;
1484
1485   width(r) = w;
1486   x = w - x;
1487
1488   if (x == 0)
1489   {
1490     glue_sign(r) = normal;
1491     glue_order(r) = normal;
1492     glue_set(r) = 0.0;
1493     goto lab10;
1494   }
1495   else if (x > 0)
1496   {
1497     if (total_stretch[filll] != 0)
1498       o = filll;
1499     else if (total_stretch[fill] != 0)
1500       o = fill;
1501     else if (total_stretch[fil] != 0)
1502       o = fil;
1503     else
1504       o = normal;
1505
1506     glue_order(r) = o;
1507     glue_sign(r) = stretching;
1508
1509     if (total_stretch[o] != 0)
1510       glue_set(r) = x / ((double) total_stretch[o]);
1511     else
1512     {
1513       glue_sign(r) = normal;
1514       glue_set(r) = 0.0;
1515     }
1516
1517     if (o == normal)
1518       if (list_ptr(r) != 0)
1519       {
1520         last_badness = badness(x, total_stretch[normal]);
1521
1522         if (last_badness > hbadness)
1523         {
1524           print_ln();
1525
1526           if (last_badness > 100)
1527             print_nl("Underfull");
1528           else
1529             print_nl("Loose");
1530
1531           print_string(" \\hbox (badness ");
1532           print_int(last_badness);
1533
1534           if (last_badness > 100) /* Y&Y TeX */
1535             underfull_hbox++;   /* 1996/Feb/9 */
1536
1537           goto lab50;
1538         }
1539       }
1540       goto lab10;
1541   }
1542   else
1543   {
1544     if (total_shrink[filll] != 0)
1545       o = filll;
1546     else if (total_shrink[fill] != 0)
1547       o = fill;
1548     else if (total_shrink[fil] != 0)
1549       o = fil;
1550     else
1551       o = normal;
1552
1553     glue_order(r) = o;
1554     glue_sign(r) = shrinking;
1555
1556     if (total_shrink[o] != 0)
1557       glue_set(r) =(- (integer) x) / ((double) total_shrink[o]);
1558     else
1559     {
1560       glue_sign(r) = normal;
1561       glue_set(r) = 0.0;
1562     }
1563
1564     if ((total_shrink[o] < - (integer) x) && (o == 0) && (list_ptr(r) != 0))
1565     {
1566       last_badness = 1000000L;
1567       glue_set(r) = 1.0;
1568
1569       if ((- (integer) x - total_shrink[normal] > hfuzz) || (hbadness < 100))
1570       {
1571           if ((overfull_rule > 0) && (- (integer) x - total_shrink[0] > hfuzz))
1572           {
1573               while (link(q) != 0)
1574                 q = link(q);
1575  
1576               link(q) = new_rule();
1577               width(link(q)) = overfull_rule;
1578           }
1579
1580           print_ln();
1581           print_nl("Overfull \\hbox (");
1582           print_scaled(- (integer) x - total_shrink[normal]);
1583           print_string("pt too wide");
1584
1585           overfull_hbox++;
1586
1587           goto lab50;
1588       }
1589     }
1590     else if (o == normal)
1591       if (list_ptr(r) != 0)
1592       {
1593         last_badness = badness(- (integer) x, total_shrink[normal]);
1594
1595         if (last_badness > hbadness)
1596         {
1597           print_ln();
1598           print_nl("Tight \\hbox (badness ");
1599           print_int(last_badness);
1600           goto lab50;
1601         }
1602       }
1603       goto lab10;
1604   }
1605
1606 lab50:
1607   if (output_active)
1608     print_string(") has occurred while \\output is active");
1609   else
1610   {
1611     if (pack_begin_line != 0)
1612     {
1613       if (pack_begin_line > 0)
1614         print_string(") in paragraph at lines ");
1615       else
1616         print_string(") in alignment at lines ");
1617
1618       print_int(abs(pack_begin_line));
1619       print_string("--");
1620     }
1621     else
1622       print_string(") detected at line ");
1623
1624     print_int(line);
1625   }
1626
1627   print_ln();
1628   font_in_short_display = null_font;
1629   short_display(list_ptr(r));
1630   print_ln();
1631   begin_diagnostic();
1632   show_box(r);
1633   end_diagnostic(true);
1634
1635 lab10:
1636   return r;
1637 }
1638 /* sec 0668 */
1639 halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
1640 {
1641   halfword r;
1642   scaled w, d, x;
1643   scaled s;
1644   halfword g;
1645 /*  glue_ord o;  */
1646   int o;              /* 95/Jan/7 */
1647
1648   last_badness = 0;
1649   r = get_node(box_node_size);
1650   type(r) = vlist_node;
1651   subtype(r) = min_quarterword;
1652   shift_amount(r) = 0;
1653   list_ptr(r) = p;
1654   w = 0;
1655   d = 0;
1656   x = 0;
1657   total_stretch[normal] = 0;
1658   total_shrink[normal] = 0;
1659   total_stretch[fil] = 0;
1660   total_shrink[fil] = 0;
1661   total_stretch[fill] = 0;
1662   total_shrink[fill] = 0;
1663   total_stretch[filll] = 0;
1664   total_shrink[filll] = 0;
1665
1666   while (p != 0)
1667   {
1668     if (is_char_node(p))
1669     {
1670       confusion("vpack");
1671       return 0;
1672     }
1673     else switch (type(p))
1674     {
1675       case hlist_node:
1676       case vlist_node:
1677       case rule_node:
1678       case unset_node:
1679         {
1680           x = x + d + height(p);
1681           d = depth(p);
1682
1683           if (type(p) >= rule_node)
1684             s = 0;
1685           else
1686             s = shift_amount(p);
1687
1688           if (width(p) + s > w)
1689             w = width(p) + s;
1690         }
1691         break;
1692
1693       case whatsit_node:
1694         break;
1695
1696       case glue_node:
1697         {
1698           x = x + d;
1699           d = 0;
1700           g = glue_ptr(p);
1701           x = x + width(g);
1702           o = stretch_order(g);
1703           total_stretch[o] = total_stretch[o] + stretch(g);
1704           o = shrink_order(g);
1705           total_shrink[o] = total_shrink[o] + shrink(g);
1706
1707           if (subtype(p) >= a_leaders)
1708           {
1709             g = leader_ptr(p);
1710
1711             if (width(g) > w)
1712               w = width(g);
1713           }
1714         }
1715         break;
1716
1717       case kern_node:
1718         {
1719           x = x + d + width(p);
1720           d = 0;
1721         }
1722         break;
1723
1724       default:
1725         break;
1726     }
1727     p = link(p);
1728   }
1729
1730   width(r) = w;
1731
1732   if (d > l)
1733   {
1734     x = x + d - l;
1735     depth(r) = l;
1736   }
1737   else
1738     depth(r) = d;
1739
1740   if (m == additional)
1741     h = x + h;
1742
1743   height(r) = h;
1744   x = h - x;
1745
1746   if (x == 0)
1747   {
1748     glue_sign(r) = normal;
1749     glue_order(r) = normal;
1750     glue_set(r) = 0.0;
1751     goto lab10;
1752   }
1753   else if (x > 0)
1754   {
1755     if (total_stretch[filll] != 0)
1756       o = filll;
1757     else if (total_stretch[fill] != 0)
1758       o = fill;
1759     else if (total_stretch[fil] != 0)
1760       o = fil;
1761     else
1762       o = normal;
1763
1764     glue_order(r) = o;
1765     glue_sign(r) = stretching;
1766
1767     if (total_stretch[o] != 0)
1768       glue_set(r) = x / ((double) total_stretch[o]);
1769     else
1770     {
1771       glue_sign(r) = normal;
1772       glue_set(r) = 0.0;
1773     }
1774
1775     if (o == normal)
1776       if (list_ptr(r) != 0)
1777       {
1778         last_badness = badness(x, total_stretch[normal]);
1779
1780         if (last_badness > vbadness)
1781         {
1782           print_ln();
1783
1784           if (last_badness > 100)
1785             print_nl("Underfull");
1786           else
1787             print_nl("Loose");
1788
1789           print_string(" \\vbox (badness ");
1790           print_int(last_badness);
1791
1792           if (last_badness > 100)
1793             underfull_vbox++; /* 1996/Feb/9 */
1794
1795           goto lab50;
1796         }
1797       }
1798       goto lab10;
1799   }
1800   else
1801   {
1802     if (total_shrink[filll] != 0)
1803       o = filll;
1804     else if (total_shrink[fill] != 0)
1805       o = fill;
1806     else if (total_shrink[fil] != 0)
1807       o = fil;
1808     else
1809       o = normal;
1810
1811     glue_order(r) = o;
1812     glue_sign(r) = shrinking;
1813
1814     if (total_shrink[o] != 0)
1815       glue_set(r) =(- (integer) x)/ ((double) total_shrink[o]);
1816     else
1817     {
1818       glue_sign(r) = normal;
1819       glue_set(r) = 0.0;
1820     }
1821
1822     if ((total_shrink[o] < - (integer) x) && (o == 0) && (list_ptr(r) != 0))
1823     {
1824       last_badness = 1000000L;
1825       glue_set(r) = 1.0;
1826
1827       if ((- (integer) x - total_shrink[0] > vfuzz) || (vbadness < 100))
1828       {
1829         print_ln();
1830         print_nl("Overfull \\vbox (");
1831         print_scaled(- (integer) x - total_shrink[0]);
1832         print_string("pt too high");
1833
1834         overfull_vbox++;    /* 1996/Feb/9 */
1835
1836         goto lab50;
1837       }
1838     }
1839     else if (o == 0)
1840       if (list_ptr(r) != 0)
1841       {
1842         last_badness = badness(- (integer) x, total_shrink[normal]);
1843         if (last_badness > vbadness)
1844         {
1845           print_ln();
1846           print_nl("Tight \\vbox (badness ");
1847           print_int(last_badness);
1848           goto lab50;
1849         }
1850       }
1851     goto lab10;
1852   }
1853
1854 lab50:
1855   if (output_active)
1856     print_string(") has occurred while \\output is active");
1857   else
1858   {
1859     if (pack_begin_line != 0)
1860     {
1861       print_string(") in alignment at lines ");
1862       print_int(abs(pack_begin_line));
1863       print_string("--");
1864     }
1865     else
1866       print_string(") detected at line ");
1867
1868     print_int(line);
1869     print_ln();
1870   }
1871
1872   begin_diagnostic();
1873   show_box(r);
1874   end_diagnostic(true);
1875
1876 lab10:
1877   return r;
1878 }
1879 /* sec 0679 */
1880 void append_to_vlist_(halfword b)
1881 {
1882   scaled d;
1883   halfword p;
1884
1885   if (prev_depth > ignore_depth)
1886   {
1887     d = width(baseline_skip) - prev_depth - height(b);
1888
1889     if (d < line_skip_limit)
1890       p = new_param_glue(line_skip_code);
1891     else
1892     {
1893       p = new_skip_param(baseline_skip_code);
1894       width(temp_ptr) = d;
1895     }
1896     link(tail) = p;
1897     tail = p;
1898   }
1899
1900   link(tail) = b;
1901   tail = b;
1902   prev_depth = depth(b);
1903 }
1904 /* sec 0686 */
1905 halfword new_noad (void)
1906 {
1907   halfword p;
1908
1909   p = get_node(noad_size);
1910   type(p) = ord_noad;
1911   subtype(p) = normal;
1912   mem[nucleus(p)].hh = empty_field;
1913   mem[subscr(p)].hh = empty_field;
1914   mem[supscr(p)].hh = empty_field;
1915
1916   return p;
1917 }
1918 /* sec 0688 */
1919 halfword new_style_(small_number s)
1920 {
1921   halfword p;
1922
1923   p = get_node(style_node_size);
1924   type(p) = style_node;
1925   subtype(p) = s;
1926   width(p) = 0;
1927   depth(p) = 0;
1928
1929   return p;
1930 }
1931 /* sec 0689 */
1932 halfword new_choice (void)
1933 {
1934   halfword p;
1935
1936   p = get_node(style_node_size);
1937   type(p) = choice_node;
1938   subtype(p) = 0;
1939   display_mlist(p) = 0;
1940   text_mlist(p) = 0;
1941   script_mlist(p) = 0;
1942   script_script_mlist(p) = 0;
1943
1944   return p;
1945 }
1946 /* sec 0693 */
1947 void show_info (void)
1948 {
1949   show_node_list(info(temp_ptr));
1950 }
1951 /* sec 0704 */
1952 halfword fraction_rule_(scaled t)
1953 {
1954   halfword p;
1955
1956   p = new_rule();
1957   height(p) = t;
1958   depth(p) = 0;
1959
1960   return p;
1961 }
1962 /* sec 0705 */
1963 halfword overbar_(halfword b, scaled k, scaled t)
1964 {
1965   halfword p, q;
1966
1967   p = new_kern(k);
1968   link(p) = b;
1969   q = fraction_rule(t);
1970   link(q) = p;
1971   p = new_kern(t);
1972   link(p) = q;
1973   return vpackage(p, 0, 1, 1073741823L); /* 2^30 - 1 */
1974 }
1975 /* sec 0709 */
1976 halfword char_box_(internal_font_number f, quarterword c)
1977 {
1978   four_quarters q;
1979   eight_bits hd;
1980   halfword b, p;
1981
1982   q = char_info(f, c);
1983   hd = height_depth(q);
1984   b = new_null_box();
1985   width(b) = char_width(f, q) + char_italic(f, q);
1986   height(b) = char_height(f, hd);
1987   depth(b) = char_depth(f, hd);
1988   p = get_avail();
1989   character(p) = c;
1990   font(p) = f;
1991   list_ptr(b) = p;
1992
1993   return b;
1994 }
1995 /* sec 0711 */
1996 void stack_into_box_(halfword b, internal_font_number f, quarterword c)
1997 {
1998   halfword p;
1999
2000   p = char_box(f, c);
2001   link(p) = list_ptr(b);
2002   list_ptr(b) = p;
2003   height(b) = height(p);
2004 }
2005 /* sec 0712 */
2006 scaled height_plus_depth_(internal_font_number f, quarterword c)
2007 {
2008   four_quarters q;
2009   eight_bits hd;
2010
2011   q = char_info(f, c);
2012   hd = height_depth(q);
2013   return char_height(f, hd) + char_depth(f, hd);
2014 }
2015 /* sec 0706 */
2016 halfword var_delimiter_(halfword d, small_number s, scaled v)
2017 {
2018   halfword b;
2019   internal_font_number f, g;
2020   quarterword c, x, y;
2021   integer m, n;
2022   scaled u;
2023   scaled w;
2024   four_quarters q;
2025   four_quarters r;
2026   eight_bits hd;
2027 /*  small_number z;  */
2028   int z;                  /* 95/Jan/7 */
2029 /*  boolean large_attempt;  */
2030   int large_attempt;           /* 95/Jan/7 */
2031
2032   f = null_font;
2033   w = 0;
2034   large_attempt = false;
2035   z = small_fam(d);
2036   x = small_char(d);
2037
2038   while (true)
2039   {
2040     if ((z != 0) || (x != 0))
2041     {
2042       z = z + s + 16;
2043
2044       do
2045         {
2046           z = z - 16;
2047           g = fam_fnt(z);
2048
2049           if (g != null_font)
2050           {
2051             y = x;
2052
2053             if ((y >= font_bc[g]) && (y <= font_ec[g]))
2054             {
2055 lab22:
2056               q = char_info(g, y);
2057               
2058               if ((q.b0 > 0))
2059               {
2060                 if (char_tag(q) == ext_tag)
2061                 {
2062                   f = g;
2063                   c = y;
2064                   goto lab40;
2065                 }
2066
2067                 hd = height_depth(q);
2068                 u = char_height(g, hd) + char_depth(g, hd);
2069
2070                 if (u > w)
2071                 {
2072                   f = g;
2073                   c = y;
2074                   w = u;
2075
2076                   if (u >= v)
2077                     goto lab40;
2078                 }
2079
2080                 if (char_tag(q) == list_tag)
2081                 {
2082                   y = rem_byte(q);
2083                   goto lab22;
2084                 }
2085               }
2086             }
2087           }
2088         }
2089       while (!(z < 16));
2090     }
2091
2092     if (large_attempt)
2093       goto lab40;
2094
2095     large_attempt = true;
2096     z = large_fam(d);
2097     x = large_char(d);
2098   }
2099 lab40:
2100   if (f != null_font)
2101     if (char_tag(q) == ext_tag)
2102     {
2103       b = new_null_box();
2104       type(b) = vlist_node;
2105       r = font_info[exten_base[f] + rem_byte(q)].qqqq;
2106       c = ext_rep(r);
2107       u = height_plus_depth(f, c);
2108       w = 0;
2109       q = char_info(f, c);
2110       width(b) = char_width(f, q) + char_italic(f, q);
2111       c = ext_bot(r);
2112
2113       if (c != min_quarterword)
2114         w = w + height_plus_depth(f, c);
2115
2116       c = ext_mid(r);
2117
2118       if (c != min_quarterword)
2119         w = w + height_plus_depth(f, c);
2120
2121       c = ext_top(r);
2122
2123       if (c != min_quarterword)
2124         w = w + height_plus_depth(f, c);
2125
2126       n = 0;
2127
2128       if (u > 0)
2129         while (w < v)
2130         {
2131           w = w + u;
2132           incr(n);
2133
2134           if (ext_mid(r) != min_quarterword)
2135             w = w + u;
2136         }
2137
2138       c = ext_bot(r);
2139
2140       if (c != min_quarterword)
2141         stack_into_box(b, f, c);
2142
2143       c = ext_rep(r);
2144
2145       for (m = 1; m <= n; m++)
2146         stack_into_box(b, f, c);
2147
2148       c = ext_mid(r);
2149
2150       if (c != min_quarterword)
2151       {
2152         stack_into_box(b, f, c);
2153         c = ext_rep(r);
2154
2155         for (m = 1; m <= n; m++)
2156           stack_into_box(b, f, c);
2157       }
2158
2159       c = ext_top(r);
2160
2161       if (c != 0)
2162         stack_into_box(b, f, c);
2163       
2164       depth(b) = w - height(b);
2165     }
2166     else
2167       b = char_box(f, c);
2168   else
2169   {
2170     b = new_null_box();
2171     width(b) = null_delimiter_space;
2172   }
2173
2174   shift_amount(b) = half(height(b) - depth(b)) - axis_height(s);
2175
2176   return b;
2177 }
2178 /* rebox_ etc used to follow here in tex4.c */