OSDN Git Service

print_esc: str_number -> char *.
[putex/putex.git] / src / texsourc / tex0.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:4996)
14 #pragma warning(disable:4131) // old style declarator
15 #pragma warning(disable:4135) // conversion between different integral types 
16 #pragma warning(disable:4127) // conditional expression is constant
17
18 #include <setjmp.h>
19
20 #define EXTERN extern
21
22 #include "texd.h"
23
24 #ifdef IGNORED
25 static void winerror (char * message)
26 {
27   (void) MessageBox(NULL, message, "YandYTeX.DLL", MB_ICONSTOP | MB_OK);
28 }
29 #endif
30
31 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
32 void print_err (const char * s)
33 {
34   if (interaction == error_stop_mode);
35   print_nl("! ");
36   print_string(s);
37 }
38 void tex_help (unsigned int n, ...)
39 {
40   unsigned int i;
41   va_list help_arg;
42
43   if (n > 6) n = 6;
44   help_ptr = n;
45   va_start(help_arg, n);
46   for (i = n - 1; i >= 0; i--)
47     help_line[i] = va_arg(help_arg, char *);
48   va_end(help_arg);
49 }
50 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
51
52 // print newline
53 /* sec 0058 */
54 void print_ln(void)
55
56    switch(selector){
57      case term_and_log:
58      {
59        show_char('\n');
60        term_offset = 0; 
61        (void) putc ('\n',  log_file);
62        file_offset = 0; 
63      } 
64      break; 
65      case log_only:
66      {
67        (void) putc ('\n',  log_file);
68        file_offset = 0; 
69      } 
70      break; 
71      case term_only:
72      {
73        show_char('\n');
74        term_offset = 0; 
75      } 
76      break; 
77      case no_print: 
78      case pseudo: 
79      case new_string: ; 
80        break; 
81      default: 
82        (void) putc ('\n',  write_file[selector]);
83        break; 
84   } 
85
86 /* sec 0059 */
87 void print_char_(ASCII_code s)
88 {/* 10 */ 
89     if(s == eqtb[(hash_size + 3212)].cint)
90     if(selector < pseudo){
91       print_ln (); 
92       return; 
93     } 
94   switch(selector){
95     case term_and_log:
96     {
97       (void) show_char(Xchr(s));
98       incr(term_offset); 
99       (void) putc(Xchr(s),  log_file);
100       incr(file_offset); 
101       if(term_offset == max_print_line){
102         show_char('\n');
103         term_offset = 0; 
104       } 
105       if(file_offset == max_print_line){
106         (void) putc ('\n',  log_file);
107         file_offset = 0; 
108       } 
109     } 
110     break; 
111     case log_only:
112     {
113       (void) putc(Xchr(s),  log_file);
114       incr(file_offset); 
115       if(file_offset == max_print_line)print_ln (); 
116     } 
117     break; 
118     case term_only:
119     {
120       (void) show_char(Xchr(s));
121       incr(term_offset); 
122       if(term_offset == max_print_line)print_ln (); 
123     } 
124     break; 
125     case no_print: 
126       ; 
127       break; 
128     case pseudo: 
129       if(tally < trick_count)
130         trick_buf[tally % error_line]= s; 
131       break; 
132     case new_string: 
133     {
134 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
135 #ifdef ALLOCATESTRING
136       if(pool_ptr + 1 > current_pool_size)  { 
137         str_pool = realloc_str_pool (increment_pool_size);  /* 94/Jan/24 */
138       }
139       if(pool_ptr < current_pool_size)          /* 94/Jan/24 */
140 #else
141 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
142         if(pool_ptr < pool_size)
143 #endif
144         {
145           str_pool[pool_ptr]= s; 
146           incr(pool_ptr); 
147         } 
148     } 
149     break; 
150     default: 
151       (void) putc(Xchr(s),  write_file[selector]);
152       break; 
153   } /* end of switch(selector) */
154   incr(tally); 
155
156 /* sec 0059 */
157 /* This could be made more efficient using fputs ? ... bkph */
158 void print_(integer s)
159 {/* 10 */ 
160     pool_pointer j; 
161   integer nl; 
162   if(s >= str_ptr)  s = 259;        /* ??? */
163   else if(s < 256)
164     if(s < 0) s = 259;        /* ??? */
165     else {
166       if(selector > pseudo){
167         print_char(s); 
168         return; 
169       } 
170       if((s == eqtb[(hash_size + 3212)].cint)) 
171         if(selector < 20){
172           print_ln (); 
173           return; 
174         } 
175       nl = eqtb[(hash_size + 3212)].cint; /* save eol */
176       eqtb[(hash_size + 3212)].cint = -1; 
177 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
178 /*      if (!show_in_hex && s < 256)  */      /* show control chars also ?? */
179       if (! show_in_hex && s < 256 && s >= 32) {      /* 94/Jan/26 */
180 /*        following added 1996/Jan/20 */
181         if (show_in_dos && s > 127) {     /* translate ANSI to DOS 850 */
182           if (wintodos[s-128] > 0) print_char (wintodos[s-128]);
183           else {              /* print in hex after all */
184             j = str_start[s]; 
185             while(j < str_start[s + 1]){
186               print_char(str_pool[j]); 
187               incr(j); 
188             } 
189           }
190         }
191         else print_char(s);       /* don't translate to hex */
192       }
193       else {                  /* not just a character */
194 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
195         j = str_start[s]; 
196         while(j < str_start[s + 1]){
197           print_char(str_pool[j]); 
198           incr(j); 
199         } 
200       }
201       eqtb[(hash_size + 3212)].cint = nl; /* restore eol */
202       return; 
203     }
204 /*  we get here with s > 256 - i.e. not a single character */
205   j = str_start[s]; 
206   while(j < str_start[s + 1]){
207     print_char(str_pool[j]); 
208     incr(j); 
209   }
210
211 void print_string_ (unsigned char *s)
212 {
213   // 2000 Jun 18
214   while (*s > 0) print_char(*s++);
215 }
216 /* sec 0060 */
217 // print string number s from string pool by calling print_
218 void slow_print_(integer s)
219
220   pool_pointer j; 
221   if((s >= str_ptr)||(s < 256)) print(s); 
222   else {
223     j = str_start[s]; 
224     while(j < str_start[s + 1]){
225 //      if (str_pool[j]>= 128) print(str_pool[j]-128); // debugging only
226 //      if (str_pool[j]== 0) print(36); // debugging only
227       print(str_pool[j]); 
228       incr(j); 
229     } 
230   } 
231
232 /* sec 0062 */
233 // print newline followed by string number s (unless at start of line)
234 void print_nl_(char * s)
235
236    if(((term_offset > 0) && (odd(selector)))||
237     ((file_offset > 0) && (selector >= log_only)))
238         print_ln (); 
239   print_string(s); 
240
241 /* sec 0063 */
242 // print string number s preceded by escape character
243 void print_esc_(char * s)
244
245   integer c; 
246   c = eqtb[(hash_size + 3208)].cint; 
247   if(c >= 0)
248     if(c < 256) print(c); 
249   //slow_print(s); 
250   print_string(s);
251
252 /* sec 0064 */
253 void print_the_digs_(eight_bits k)
254
255   while(k > 0){
256     decr(k); 
257     if(dig[k]< 10)
258       print_char(48 + dig[k]); 
259     else
260           print_char(55 + dig[k]); 
261   } 
262
263 /* sec 0065 */
264 void print_int_(integer n)
265 {
266   char k; 
267   integer m; 
268   k = 0; 
269   if(n < 0)
270   {
271     print_char(45);     /* - */
272     if(n > -100000000L)
273     n = - (integer) n; 
274     else {
275       m = -1 - n; 
276       n = m / 10; 
277       m =(m % 10)+ 1; 
278       k = 1; 
279       if(m < 10)
280 /*      dig[0]= m; */     /* keep compiler happy */
281       dig[0]= (char) m; 
282       else {
283       dig[0]= 0; 
284       incr(n); 
285       } 
286     } 
287   } 
288   do {
289 /*    dig[k]= n % 10;  */   /* keep compiler happy */
290     dig[k]= (char) (n % 10); 
291     n = n / 10; 
292     incr(k); 
293   } while(!(n == 0)); 
294   print_the_digs(k); 
295
296 /* sec 0262 */
297 void print_cs_(integer p)
298
299   if(p < 514)       /* if p < hash_base then ... p.262 */
300   if(p >= 257)        /* if p > single_base then ... p.262 */
301   if(p == 513)        /* if p = null_cs then ... p.262 */
302   {
303     print_esc("csname");
304     print_esc("endcsname");
305   } 
306   else {
307     //print_esc(p - 257);   /* p - single_base */
308           print_esc("");print(p-257);
309 /*  if cat_code(p - single_base) = letter then ... p.262 */
310     if(eqtb[(hash_size + 1883) + p - 257].hh.v.RH == 11)
311     print_char(32);     /*   */
312   } 
313   else if(p < 1)
314     print_esc("IMPOSSIBLE");
315   else print(p - 1); 
316   else if(p >= (hash_size + 781)) /* undefined_control_sequence */
317     print_esc("IMPOSSIBLE");
318   else if((hash[p].v.RH >= str_ptr)) 
319     print_esc("NONEXISTENT");
320   else {
321     //print_esc(hash[p].v.RH); 
322           print_esc(""); print(hash[p].v.RH);
323     print_char(32);     /*    */
324   } 
325
326 /* sec 0263 */
327 void sprint_cs_(halfword p)
328
329   if(p < 514)       /* if p < hash_base then ... p.263 */
330   if(p < 257)       /* if p < single_base then ... p.263 */
331     print(p - 1);     /* print (p - active_base); */
332   else if(p < 513)      /* else if p < null_cs then ... */
333     //print_esc(p - 257); /* print (p - single_base); */
334   {print_esc(""); print(p-257);}
335   else {
336     print_esc("csname");     /*  */
337     print_esc("endcsname");     /*  */
338   } 
339   else //print_esc(hash[p].v.RH); 
340   {
341           print_esc(""); print(hash[p].v.RH);
342   }
343
344 /* sec 0518 */
345 /* ! I can't find file `  c:/foo/  accents  .tex  '. */
346 void print_file_name_(integer n, integer a, integer e)
347
348 /*  sprintf(log_line, "\na %d n %d e %d\n", a, n, e); */
349 /*  show_line(log_line, 0); */
350 //  print_char(33);  // debugging only
351   slow_print(a); 
352 //  print_char(33);  // debugging only
353   slow_print(n); 
354 //  print_char(33);  // debugging only
355   slow_print(e); 
356 //  print_char(33);  // debugging only
357 }
358 /* sec 0699 */
359 void print_size_(integer s) 
360
361   if (s == 0)
362     print_esc("textfont");
363   else if (s == 16)
364     print_esc("scriptfont");
365   else
366     print_esc("scriptscriptfont");
367
368 /* sec 1355 */
369 void print_write_whatsit_(str_number s, halfword p)
370 {
371   //print_esc(s); 
372         print_esc(""); print(s);
373   if(mem[p + 1].hh.v.LH < 16)
374     print_int(mem[p + 1].hh.v.LH); 
375   else if(mem[p + 1].hh.v.LH == 16)
376     print_char(42);   /* * */
377   else print_char(45);    /* - */
378
379 #ifdef DEBUG
380 #endif /* DEBUG */
381 /* sec 0081 */
382 // called from itex.c and tex0.c only  NASTY NASTY!
383 // now uses uses non-local goto (longjmp) 1999/Nov/7
384 void jump_out (void) 
385 {
386   close_files_and_terminate (); 
387   {
388     int code;
389 #ifndef _WINDOWS
390     fflush(stdout); 
391 #endif
392     ready_already = 0; 
393
394     if (trace_flag) show_line("EXITING at JUMPOUT\n", 0);
395
396 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
397 //    if (endit(history) != 0) history = 2; /* 93/Dec/26 in local.c */
398 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
399
400 //    abort_flag++;       // TURN OFF THE POWER ???
401
402     if((history != 0)&&(history != 1))  code = 1;
403     else code = 0;
404     uexit(code); 
405 //    longjmp(jumpbuffer, code+1);
406   }
407 }
408 /* sec 0082 */
409 // deal with error by asking for user response 0-9, D, E, H, I, X, Q, R, S
410 // NOTE: this may JUMPOUT either via X, or because of too many errors
411 void error(void)
412 {/* 22 10 */ 
413   ASCII_code c; 
414   integer s1, s2, s3, s4; 
415   if(history < 2) history = 2;
416
417   print_char(46);   /* . */
418   show_context (); 
419
420   if(interaction == 3)
421     while(true){
422 lab22:          /* loop */
423       clear_for_error_prompt (); 
424       {
425         ; 
426         print(264);   /* ?  */
427         term_input(264, help_ptr); 
428       } 
429       if(last == first)return;    // no input
430       c = buffer[first];        // analyze first letter typed
431       if(c >= 97)           // uppercase letter first
432 /*        c = c - 32;  */       /* keep compiler happy */
433         c = (unsigned char) (c - 32); 
434       switch(c){
435         case 48 :       /* 0 */
436         case 49 :       /* 1 */
437         case 50 : 
438         case 51 : 
439         case 52 : 
440         case 53 : 
441         case 54 : 
442         case 55 : 
443         case 56 : 
444         case 57 :       /* 9 */
445           if(deletions_allowed) {
446             s1 = cur_tok; 
447             s2 = cur_cmd; 
448             s3 = cur_chr; 
449             s4 = align_state; 
450             align_state = 1000000L; 
451             OK_to_interrupt = false; 
452             if((last > first + 1)&&(buffer[first + 1]>= 48)&&
453               (buffer[first + 1]<= 57)) 
454               c = (unsigned char) (c * 10 + buffer[first + 1]- 48 * 11); 
455             else c = (unsigned char) (c - 48);
456             while(c > 0){
457               get_token (); 
458               decr(c); 
459             } 
460             cur_tok = s1; 
461             cur_cmd = s2; 
462             cur_chr = s3; 
463             align_state = s4; 
464             OK_to_interrupt = true;
465                         help2("I have just deleted some text, as you asked.",
466                                 "You can now delete more, or insert, or whatever.");
467             show_context (); 
468             goto lab22;     /* loop again */
469           } 
470           break; 
471           ;
472 #ifdef DEBUG
473         case 68 :     /* D */
474         {
475           debug_help (); 
476           goto lab22;       /* loop again */
477         } 
478         break; 
479 #endif /* DEBUG */
480         case 69 :     /* E */
481           if(base_ptr > 0){
482             edit_name_start = str_start[input_stack[base_ptr].name_field]; 
483             edit_name_length = str_start[input_stack[base_ptr].name_field + 1]- 
484                      str_start[input_stack[base_ptr].name_field]; 
485             edit_line = line; 
486             jump_out();
487 //            return;     // can drop through now 99/Oct/20
488           } 
489           break; 
490         case 72 :     /* H */
491         {
492           if(use_err_help)
493           {
494             give_err_help (); 
495             use_err_help = false; 
496           } 
497           else {
498             if(help_ptr == 0)
499                                 help2("Sorry, I don't know how to help in this situation.",
500                                 "Maybe you should try asking a human?");
501             do {
502               decr(help_ptr); 
503               print(help_line[help_ptr]); 
504               print_ln (); 
505             } while(!(help_ptr == 0)); 
506           }
507                   help4("Sorry, I already gave what help I could...",
508                           "Maybe you should try asking a human?",
509                           "An error might have occurred before I noticed any problems.",
510                           "``If all else fails, read the instructions.''");
511           goto lab22; /* loop again */
512         } 
513         break; 
514         case 73 :     /* I */
515         {
516           begin_file_reading (); 
517           if(last > first + 1)
518           {
519             cur_input.loc_field = first + 1; 
520             buffer[first]= 32; 
521           } 
522           else {
523             {
524               ; 
525               print(276); /* insert> */
526               term_input(276, 0); 
527             } 
528             cur_input.loc_field = first; 
529           } 
530           first = last; 
531           cur_input.limit_field = last - 1; 
532           return; 
533         } 
534         break; 
535         case 81 :     /* Q, R, S */
536         case 82 : 
537         case 83 : 
538         {
539           error_count = 0; 
540           interaction = 0 + c - 81; /* Q = 0, R = 1, S = 2, T = 3 */
541           print(271);     /* OK, entering  */
542           switch(c){
543             case 81 :       /* Q */
544             {
545               print_esc("batchmode"); /*  */
546               decr(selector); 
547             } 
548             break; 
549             case 82 :       /* R */
550               print_esc("nonstopmode"); /*  */
551               break; 
552             case 83 :       /* S */
553               print_esc("scrollmode"); /*   */
554               break; 
555           } 
556           print(275);     /* ... */
557           print_ln (); 
558 #ifndef _WINDOWS
559           fflush(stdout); 
560 #endif
561           return; 
562         } 
563         break; 
564         case 88 :       /* X */
565         {
566           interaction = 2; 
567           jump_out();
568 //          return;     // can drop through now 99/Oct/20   
569         } 
570         break; 
571         default: 
572           ; 
573           break; 
574       }           /* end of switch analysing response character */
575       {
576         print(265);   /* Type <return> to proceed, S to scroll future error messages, */
577         print_nl("R to run without stopping, Q to run quietly,");  /*  */
578         print_nl("I to insert something, ");  /*  */
579         if (base_ptr > 0) print(268); /*  E to edit your file,  */
580         if(deletions_allowed) print_nl("1 or ... or 9 to ignore the next 1 to 9 tokens of input,"); /*  */
581         print_nl("H for help, X to quit.");  /*  */
582       } 
583     }   /* end of while(true) loop */
584
585   incr(error_count); 
586   if(error_count == 100) {
587     print_nl("(That makes 100 errors; please try again.)");
588     history = 3; 
589     jump_out();
590 //    return;     // can drop through now 99/Oct/20   
591   } 
592   if(interaction > 0) decr(selector); 
593   if(use_err_help) {
594     print_ln (); 
595     give_err_help (); 
596   } 
597   else while(help_ptr > 0){
598     decr(help_ptr); 
599     print_nl(help_line[help_ptr]); 
600   } 
601   print_ln (); 
602   if(interaction > 0)incr(selector); 
603   print_ln (); 
604
605
606 void fatal_error_(char * s)
607 {
608   normalize_selector ();
609   print_err("Emergency stop");
610   help1(s); 
611   {
612     if(interaction == 3)interaction = 2; 
613     if(log_opened){
614       error ();
615     }
616     ;
617 #ifdef DEBUG
618     if(interaction > 0)debug_help (); 
619 #endif /* DEBUG */
620     history = 3; 
621     jump_out();
622 //    return;     // can drop through now 99/Oct/20   
623   } 
624 }
625 /* sec 0094 */
626 void overflow_(str_number s, integer n)
627 {
628    normalize_selector ();
629    print_err("TeX capacity exceeded, sorry[");
630   print(s); 
631   print_char(61); /* '=' */
632   print_int(n); 
633   print_char(93); /* ']' */
634   help2("If you really absolutely need more capacity,",
635           "you can ask a wizard to enlarge me."); 
636   if (! knuth_flag) {   /*  Additional comments 98/Jan/5 */
637     if (s == 945 && n == trie_size) {
638       sprintf(log_line, "\n  (Maybe use -h=... on command line in ini-TeX)\n");
639       show_line(log_line, 0);
640     }
641     else if (s == 942 && n == hyphen_prime) {
642       sprintf(log_line, "\n  (Maybe use -e=... on command line in ini-TeX)\n");
643       show_line(log_line, 0);
644     }
645   }
646   if(interaction == 3)interaction = 2; 
647   if(log_opened){
648     error ();
649   }
650   ;
651 #ifdef DEBUG
652     if(interaction > 0)debug_help (); 
653 #endif /* DEBUG */
654   history = 3; 
655   jump_out();
656 //  return;     // can drop through now 99/Oct/20   
657 }
658 /* sec 0095 */
659 void confusion_(str_number s)
660 {
661   normalize_selector (); 
662   if(history < 2) {
663           print_err("This can't happen(");
664     print(s); 
665     print_char(41); /*)*/
666         help1("I'm broken. Please show this to someone who can fix can fix");
667   } 
668   else {
669     print_err("I can't go on meeting you like this");
670         help2("One of your faux pas seems to have wounded me deeply...",
671                 "in fact, I'm barely conscious. Please fix it and try again.");
672   } 
673   {
674     if(interaction == 3)interaction = 2; 
675     if(log_opened){
676       error ();
677     }
678     ;
679 #ifdef DEBUG
680     if(interaction > 0)debug_help (); 
681 #endif /* DEBUG */
682     history = 3; 
683     jump_out();
684 //    return;     // can drop through now 99/Oct/20   
685   } 
686
687 /* sec 0037 */
688 bool init_terminal (void) 
689 {/* 10 */
690   register bool Result; 
691   int flag;
692   t_open_in (); 
693
694   if(last > first)  {
695     cur_input.loc_field = first; 
696     while((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' '))
697       incr(cur_input.loc_field);    // step over initial white space
698     if(cur_input.loc_field < last){
699       Result = true; 
700       return Result;    // there is an input file name
701     } 
702   } 
703
704 //  failed to find input file name
705   while(true){
706     ; 
707 #ifdef _WINDOWS
708     flag = ConsoleInput("**",
709               "Please type a file name or a control sequence\r\n(or ^z to exit)",
710               (char *) &buffer[first]);
711     last = first + strlen((char *) &buffer[first]); /* -1 ? */
712 //    may need to be more elaborate see input_line in texmf.c
713 #else
714     (void) fputs("**", stdout);     /* ** PROMPT */
715     fflush(stdout); 
716     flag = input_ln(stdin, true);
717 #endif
718     if(! flag){
719       show_char('\n');
720       show_line("! End of file on the terminal... why?\n", 1); 
721       Result = false; 
722       return Result; 
723     } 
724
725     cur_input.loc_field = first; 
726     while((cur_input.loc_field < last)&&
727         (buffer[cur_input.loc_field]== ' '))
728       incr(cur_input.loc_field);    // step over intial white space
729     if(cur_input.loc_field < last){
730       Result = true; 
731       return Result;    // there is an input file name
732     } 
733     sprintf(log_line, "%s\n",  "Please type the name of your input file."); 
734     show_line(log_line, 1);
735   }
736 //  return Result; 
737
738 /* sec 0043 */
739 // Make string from str_start[str_ptr]to pool_ptr
740 str_number make_string (void) 
741 {
742   register str_number Result; 
743 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
744 #ifdef ALLOCATESTRING
745   if(str_ptr == current_max_strings)
746     str_start = realloc_str_start(increment_max_strings);
747   if(str_ptr == current_max_strings){       /* 94/Jan/24 */
748 //    printf("**********MAKESTRING**********");   // debugging only
749     overflow(258, current_max_strings - init_str_ptr); /* 97/Mar/9 */
750     return 0;     // abort_flag set
751   }
752 #else
753 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
754   if(str_ptr == max_strings){
755     overflow(258, max_strings - init_str_ptr); /* number of strings */
756     return 0;     // abort_flag set
757   }
758 #endif
759   incr(str_ptr); 
760   str_start[str_ptr] = pool_ptr; 
761   Result = str_ptr - 1; 
762   return Result; 
763
764 /* sec 0044 */
765 bool str_eq_buf_(str_number s, integer k)
766 {/* 45 */
767   register bool Result; 
768   pool_pointer j; 
769   bool result; 
770   j = str_start[s]; 
771   while(j < str_start[s + 1]) {      
772     if(str_pool[j]!= buffer[k])
773     {
774       result = false; 
775       goto lab45; 
776     } 
777     incr(j); 
778     incr(k); 
779   } 
780   result = true; 
781   lab45: Result = result; 
782   return Result; 
783
784 /* sec 0045 */
785 bool str_eq_str_(str_number s, str_number t)
786 {/* 45 */
787   register bool Result; 
788   pool_pointer j, k; 
789   bool result; 
790   result = false; 
791   if((str_start[s + 1]- str_start[s])!=(str_start[t + 1]- 
792   str_start[t])) 
793   goto lab45; 
794   j = str_start[s]; 
795   k = str_start[t]; 
796   while(j < str_start[s + 1]){
797     if(str_pool[j]!= str_pool[k])
798     goto lab45; 
799     incr(j); 
800     incr(k); 
801   } 
802   result = true; 
803   lab45: Result = result; 
804   return Result; 
805
806 /* sec 0066 */
807 void print_two_(integer n)
808
809   n = abs(n) % 100; 
810   print_char(48 +(n / 10)); 
811   print_char(48 +(n % 10)); 
812
813 /* sec 0067 */
814 void print_hex_(integer n)
815 {
816   char k; 
817   k = 0; 
818   print_char(34);   /* " */
819   do {
820     dig[k]= (unsigned char) (n % 16);  
821     n = n / 16; 
822     incr(k); 
823   } while(!(n == 0)); 
824   print_the_digs(k); 
825
826 /* sec 0069 */
827 void print_roman_int_(integer n)
828 {/* 10 */
829   pool_pointer j, k; 
830   nonnegative_integer u, v; 
831   j = str_start[260]; /*  m2d5c2l5x2v5i */
832   v = 1000; 
833   while(true){
834     while(n >= v){
835       print_char(str_pool[j]); 
836       n = n - v; 
837     } 
838     if(n <= 0)
839     return; 
840     k = j + 2; 
841     u = v /(str_pool[k - 1]- 48); 
842     if(str_pool[k - 1]== 50)
843     {
844       k = k + 2; 
845       u = u /(str_pool[k - 1]- 48); 
846     } 
847     if(n + u >= v)
848     {
849       print_char(str_pool[k]); 
850       n = n + u; 
851     } 
852     else {
853       j = j + 2; 
854       v = v /(str_pool[j - 1]- 48); 
855     } 
856   } 
857
858 /* sec 0070 */
859 void print_current_string(void)
860 {
861   pool_pointer j;
862   j = str_start[str_ptr];
863   while(j < pool_ptr) {
864     print_char(str_pool[j]);
865     incr(j);
866   }
867 }
868
869 int stringlength (int str_ptr)
870 {
871   int nstart, nnext;
872   nstart = str_start[ str_ptr];
873   nnext = str_start[ str_ptr + 1];
874   return (nnext - nstart) + 2;
875 }
876
877 char * add_string (char *s, int str_ptr)
878 {
879   int nstart, nnext, n;
880   nstart = str_start[ str_ptr];
881   nnext = str_start[ str_ptr + 1];
882   n = nnext - nstart;
883   memcpy(s, &str_pool[nstart], n);
884   s += n;
885   strcpy(s, "\r\n");
886   s += 2;
887   return s;
888 }
889
890 int addextrahelp=1;
891
892 // make one long \r\n separated string out of help lines 
893 // str_pool is packed_ASCII_code *
894
895 char * make_up_help_string (int nhelplines)
896 {
897   char *helpstring, *s;
898   int k, nlen=0;
899   
900 //  get length of help for this specific message
901   for (k = nhelplines-1; k >= 0; k--) {
902     nlen += stringlength(help_line[k]);
903   }
904   nlen += 2;    // for blank line separator
905   if (addextrahelp) {
906     nlen += stringlength(265);
907     nlen += stringlength(266);
908     nlen += stringlength(267);
909     if(base_ptr > 0)nlen += stringlength(268);
910     if(deletions_allowed)nlen += stringlength(269);
911     nlen += stringlength(270);
912   }
913   helpstring = (char *) malloc(nlen+1);
914   s = helpstring;
915   for (k = nhelplines-1; k >= 0; k--) {
916     s = add_string(s, help_line[k]);
917   }
918   if (addextrahelp) {
919     strcpy(s, "\r\n");
920     s += 2;
921     s = add_string(s, 265);    /* Type <return> to proceed, S to scroll future error messages, */
922     s = add_string(s, 266);    /* R to run without stopping, Q to run quietly, */
923     s = add_string(s, 267);    /* I to insert something,  */
924     if(base_ptr > 0)s = add_string(s, 268);  /*  E to edit your file,  */
925     if(deletions_allowed)s = add_string(s,  269);  /* 1 or ... or 9 to ignore the next 1 to 9 tokens of input, */
926     s = add_string(s, 270);    /* H for help, X to quit. */
927   }
928   return helpstring;
929 }
930
931 char * make_up_query_string (int promptstr) 
932 {
933   char *querystr;
934   int nstart, nnext, n;
935   char *s;
936   nstart = str_start[ promptstr];
937   nnext = str_start[ promptstr + 1];
938   n = nnext - nstart;
939   querystr = (char *) malloc(n + 1);
940   s = querystr;
941   memcpy(s, &str_pool[nstart], n);  
942   s += n;
943   *s = '\0';
944   return querystr;  
945 }
946
947 // abort_flag set if input_line / ConsoleInput returns non-zero
948 // should set interrupt instead ???
949 // called from tex0.c, tex2.c, tex3.c
950
951 // void term_input(void)
952 void term_input (int promptstr, int nhelplines)
953
954   integer k;
955   int flag;
956   char *helpstring = NULL;
957   char *querystring = NULL;
958 //  if (nhelplines != 0) {
959 //    helpstring = make_up_help_string (nhelplines);
960 //    printf(helpstring);
961 //    free(helpstring);
962 //  }
963   show_line("\n", 0);    // force it to show what may be buffered up ???
964   helpstring = NULL;  
965 #ifdef _WINDOWS
966   if (promptstr != 0) querystring = make_up_query_string (promptstr);
967   if (nhelplines != 0) helpstring = make_up_help_string (nhelplines);
968   if (helpstring == NULL && querystring != NULL) {
969     if (strcmp(querystring, ": ") == 0)
970       helpstring = xstrdup("Please type another file name (or ^z to exit):");
971     else if (strcmp(querystring, "=>") == 0)    // from firm_up_the_line
972       helpstring = xstrdup("Please type <enter> to accept this line\r\nor type a replacement line");
973     else if (strcmp(querystring, "insert>") == 0) // from error() after "I"
974       helpstring = xstrdup("Please type something to insert here");
975     else if (strcmp(querystring, "") == 0)      // from read_toks
976       helpstring = xstrdup("Please type a control sequence");
977     else if (strcmp(querystring, "= ") == 0)    // from read_toks
978       helpstring = xstrdup("Please type a token");
979     else if (strcmp(querystring, "*") == 0)   // get_next
980       helpstring = xstrdup("Please type a control sequence\r\n(or ^z to exit)");
981 //    else if (strcmp(querystring, "**") == 0)  // init_terminal
982 //      helpstring = xstrdup("Please type a control sequence or a file name\r\n(or ^z to exit)");     
983 //    else if (strcmp(querystring, "? ") == 0)  // from error()
984 //      helpstring = xstrdup("Please type a character to select an action");
985   }
986   flag = ConsoleInput(querystring, helpstring, (char *) &buffer[first]);  // ???
987 //  flag == 0 means trouble --- EOF on terminal
988   if (querystring != NULL) free(querystring);
989   if (helpstring != NULL) free(helpstring);
990   helpstring = querystring = NULL;
991
992   last = first + strlen((char *) &buffer[first]); /* -1 ? */
993 //  flag = (last > first);
994 //  may need to be more elaborate see input_line in texmf.c ???
995 //  sprintf(log_line, "first %d last %d flag %d - %s",
996 //      first, last, flag, (char *) &buffer[first]);
997 //  winerror(log_line);
998 #else
999   fflush(stdout); 
1000   flag = input_ln(stdin, true);
1001 #endif
1002   if(! flag){
1003     fatal_error("End of file on the terminal!"); /*  */
1004     return;         // abort_flag set
1005   }
1006   term_offset = 0; 
1007 #ifdef _WINDOWS
1008 // echo what was typed into Console buffer also
1009   if(last != first)
1010     {register integer for_end; k = first; for_end = last - 1;
1011   if(k <=  for_end) do
1012     print(buffer[k]); 
1013   while(k++ < for_end);
1014     } 
1015   print_ln (); 
1016 #else
1017   decr(selector);     // shut off echo
1018   if(last != first)
1019     {register integer for_end; k = first; for_end = last - 1;
1020   if(k <=  for_end) do
1021     print(buffer[k]); 
1022   while(k++ < for_end);
1023     } 
1024   print_ln (); 
1025   incr(selector);     // reset selector again
1026 #endif
1027
1028
1029 void int_error_ (integer n) 
1030 {
1031   print(284);  /* (*/
1032   print_int(n); 
1033   print_char(41); /*)*/
1034   error (); 
1035
1036
1037 void normalize_selector (void) 
1038 {
1039   if (log_opened)
1040     selector = 19;
1041   else
1042     selector = 17;
1043   if (job_name == 0)
1044     open_log_file ();
1045   if (interaction == 0)
1046     decr(selector);
1047 }
1048
1049 void pause_for_instructions (void) 
1050 {
1051    if (OK_to_interrupt) {
1052     interaction = 3; 
1053     if((selector == 18)||(selector == 16))
1054       incr(selector);
1055         print_err("Interruption");
1056         help3("You rang?",
1057                 "Try to insert some instructions for me (e.g.,`I\\showlists'),",
1058                 "unless you just want to quit by typing `X'.");
1059     deletions_allowed = false; 
1060     error (); 
1061     deletions_allowed = true; 
1062     interrupt = 0; 
1063   } 
1064
1065
1066 integer half_(integer x)
1067 {
1068   register integer Result;
1069   if(odd(x)) 
1070   Result =(x + 1)/ 2; 
1071   else Result = x / 2; 
1072   return Result; 
1073
1074
1075 scaled round_decimals_(small_number k)
1076 {
1077   register scaled Result; 
1078   integer a; 
1079   a = 0; 
1080   while(k > 0){
1081     decr(k); 
1082     a =(a + dig[k]* 131072L)/ 10; /* 2^17 */
1083   } 
1084   Result =(a + 1)/ 2; 
1085   return Result; 
1086
1087
1088 /* This has some minor speedup changes - no real advantage probably ... */
1089 void print_scaled_(scaled s)
1090
1091   scaled delta;
1092   if(s < 0)
1093   {
1094     print_char(45);           /* '-' */
1095     s = - (integer) s; 
1096   } 
1097   print_int(s / 65536L); 
1098   print_char(46);           /* '.' */
1099   s = 10 *(s % 65536L)+ 5; 
1100   delta = 10; 
1101   do {
1102       if(delta > 65536L)
1103     s = s - 17232;              /* 2^15 - 50000 - rounding */
1104     print_char(48 +(s / 65536L));   /* '0' + */
1105     s = 10 *(s % 65536L); 
1106     delta = delta * 10; 
1107   } while(!(s <= delta)); 
1108
1109
1110 scaled mult_and_add_(integer n, scaled x, scaled y, scaled maxanswer)
1111 {
1112   register scaled Result;
1113   if(n < 0)
1114   {
1115     x = - (integer) x; 
1116     n = - (integer) n; 
1117   } 
1118   if(n == 0)
1119   Result = y; 
1120   else if(((x <=(maxanswer - y)/ n)&&(- (integer) x <=(maxanswer + y)/ n)))
1121   Result = n * x + y; 
1122   else {
1123     arith_error = true; 
1124     Result = 0; 
1125   } 
1126   return Result; 
1127
1128
1129 scaled x_over_n_(scaled x, integer n)
1130 {
1131   register scaled Result; 
1132   bool negative; 
1133   negative = false; 
1134   if(n == 0)
1135   {
1136     arith_error = true; 
1137     Result = 0; 
1138     tex_remainder = x; 
1139   } 
1140   else {
1141       
1142     if(n < 0)
1143     {
1144       x = - (integer) x; 
1145       n = - (integer) n; 
1146       negative = true; 
1147     } 
1148     if(x >= 0)
1149     {
1150       Result = x / n; 
1151       tex_remainder = x % n; 
1152     } 
1153     else {
1154   
1155       Result = - (integer)((- (integer) x)/ n); 
1156       tex_remainder = - (integer)((- (integer) x)% n); 
1157     } 
1158   } 
1159   if(negative)
1160   tex_remainder = - (integer) tex_remainder; 
1161   return Result; 
1162
1163
1164 scaled xn_over_d_(scaled x, integer n, integer d)
1165 {
1166   register scaled Result; 
1167   bool positive; 
1168   nonnegative_integer t, u, v; 
1169   if(x >= 0)
1170   positive = true; 
1171   else {
1172       
1173     x = - (integer) x; 
1174     positive = false; 
1175   } 
1176 /*  t =(x % 32768L)* n;  */
1177   t =(x & 32767L)* n; 
1178 /*  u =(x / 32768L)* n +(t / 32768L);  */
1179   u =(x >> 15)* n +(t >> 15); 
1180 /*  v =(u % d)* 32768L +(t % 32768L);  */
1181   v =((u % d)<< 15)+(t & 32767L); 
1182   if(u / d >= 32768L)
1183   arith_error = true; 
1184 /*  else u = 32768L *(u / d)+(v / d);  */ 
1185   else u =((u / d)<< 15)+(v / d); 
1186   if(positive)
1187   {
1188     Result = u; 
1189     tex_remainder = v % d; 
1190   } 
1191   else {
1192       
1193     Result = - (integer) u; 
1194     tex_remainder = - (integer)(v % d); 
1195   } 
1196   return Result; 
1197
1198
1199 halfword badness_(scaled t, scaled s)
1200 {
1201   register halfword Result;
1202   integer r; 
1203   if(t == 0)
1204   Result = 0; 
1205   else if(s <= 0)
1206   Result = 10000; 
1207   else {
1208     if(t <= 7230584L)
1209     r =(t * 297)/ s; 
1210     else if(s >= 1663497L)
1211     r = t /(s / 297); 
1212     else r = t; 
1213     if(r > 1290)
1214     Result = 10000; 
1215 /*    safe to assume that r is positive ? */
1216 /*    else Result =(r * r * r + 131072L)/ 262144L;  */
1217     else Result =(r * r * r + 131072L)>> 18;  /* 2^17 */
1218   } 
1219   return Result; 
1220
1221
1222 #ifdef DEBUG
1223 void print_word_(memory_word w)
1224
1225   print_int(w.cint); 
1226   print_char(32);     /*   */
1227   print_scaled(w.cint); 
1228   print_char(32);     /*   */
1229   print_scaled(round(65536L * w.gr)); 
1230   print_ln (); 
1231   print_int(w.hh.v.LH); 
1232   print_char(61);     /* = */
1233   print_int(w.hh.b0); 
1234   print_char(58);     /* : */
1235   print_int(w.hh.b1); 
1236   print_char(59);     /*; */
1237   print_int(w.hh.v.RH); 
1238   print_char(32);     /*   */
1239   print_int(w.qqqq.b0); 
1240   print_char(58);     /* : */
1241   print_int(w.qqqq.b1); 
1242   print_char(58);     /* : */
1243   print_int(w.qqqq.b2); 
1244   print_char(58);     /* : */
1245   print_int(w.qqqq.b3); 
1246
1247
1248 /* need this version only if SHORTFONTINFO defined */
1249
1250 void zprintfword(fmemoryword w)
1251 {
1252   print_int(w.cint);
1253   print_char(32);      /*   */
1254   print_scaled(w.cint); 
1255   print_char(32);     /*   */
1256   print_scaled(round(65536L * w.gr)); 
1257   print_ln (); 
1258   print_int(w.hh.v.LH); 
1259   print_char(61);     /* = */
1260   print_int(w.hh.b0); 
1261   print_char(58);     /* : */
1262   print_int(w .hh.b1); 
1263   print_char(59);     /*; */
1264   print_int(w.hh.v.RH); 
1265   print_char(32);     /*   */
1266   print_int(w.qqqq.b0); 
1267   print_char(58);     /* : */
1268   print_int(w.qqqq.b1); 
1269   print_char(58);     /* : */
1270   print_int(w.qqqq.b2); 
1271   print_char(58);     /* : */
1272   print_int(w.qqqq.b3); 
1273
1274 #endif /* DEBUG */
1275
1276 void show_token_list_(integer p, integer q, integer l)
1277 {/* 10 */
1278   integer m, c; 
1279   ASCII_code matchchr; 
1280   ASCII_code n; 
1281   matchchr = 35; 
1282   n = 48; 
1283   tally = 0; 
1284 /* while (p<>null) and (tally<l) do l.6239 */
1285   while((p != 0)&&(tally < l)) {
1286       
1287     if(p == q)
1288     {
1289       first_count = tally; 
1290       trick_count = tally + 1 + error_line - half_error_line; 
1291       if(trick_count < error_line)
1292       trick_count = error_line; 
1293     } 
1294     if((p < hi_mem_min)||(p > mem_end)) 
1295     {
1296       print_esc("CLOBBERED."); /*  */
1297       return; 
1298     } 
1299     if(mem[p].hh.v.LH >= 4095)
1300     print_cs(mem[p].hh.v.LH - 4095); 
1301     else {
1302   
1303       m = mem[p].hh.v.LH / 256; 
1304 /*      m = mem[p].hh.v.LH >> 8;  */
1305       c = mem[p].hh.v.LH % 256; 
1306 /*      c = mem[p].hh.v.LH & 255;  */
1307       if(mem[p].hh.v.LH < 0)
1308       print_esc("BAD.");     /*  */
1309       else switch(m)
1310       {case 1 : 
1311       case 2 : 
1312       case 3 : 
1313       case 4 : 
1314       case 7 : 
1315       case 8 : 
1316       case 10 : 
1317       case 11 : 
1318       case 12 : 
1319   print(c); 
1320   break; 
1321       case 6 : 
1322   {
1323     print(c); 
1324     print(c); 
1325   } 
1326   break; 
1327       case 5 : 
1328   {
1329     print(matchchr); 
1330     if(c <= 9)
1331     print_char(c + 48); 
1332     else {
1333       print_char(33);   /* ! */
1334       return; 
1335     } 
1336   } 
1337   break; 
1338       case 13 : 
1339   {
1340 /*    matchchr =  c; */   /* keep compiler happy */
1341     matchchr = (ASCII_code) c; 
1342     print(c); 
1343     incr(n); 
1344     print_char(n); 
1345     if(n > 57)
1346       return; 
1347   } 
1348   break; 
1349       case 14 : 
1350   print(553);     /* -> */
1351   break; 
1352   default: 
1353   print_esc("BAD. ");   /*  */
1354   break; 
1355       } 
1356     } 
1357     p = mem[p].hh.v.RH; 
1358   } 
1359 /* if p<>null then print_esc("ETC."); l.6244 */
1360   if(p != 0)
1361   print_esc("ETC.");     /*  */
1362
1363
1364 void runaway (void) 
1365 {
1366   halfword p; 
1367   if(scanner_status > 1)
1368   {
1369     print_nl("Runaway ");        /*  */
1370     switch(scanner_status)
1371     {case 2 : 
1372       {
1373   print(567);         /* definition */
1374   p = def_ref; 
1375       } 
1376       break; 
1377     case 3 : 
1378       {
1379   print(568);         /* argument */
1380   p = mem_top - 3; 
1381       } 
1382       break; 
1383     case 4 : 
1384       {
1385   print(569);         /* preamble */
1386   p = mem_top - 4; 
1387       } 
1388       break; 
1389     case 5 : 
1390       {
1391   print(570);         /* text */
1392   p = def_ref; 
1393       } 
1394       break; 
1395     } 
1396     print_char(63);       /* ? */
1397     print_ln (); 
1398 /*  p may be used without being initialized -- OK */
1399     show_token_list(mem[p].hh.v.RH, 0, error_line - 10); 
1400   } 
1401
1402
1403 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1404 /* first try list of available nodes (avail != NULL) */
1405 /* then see if can go upwards (mem_end < mem_max) */
1406 /* then see if can go downwards (hi_mem_min > lo_mem_max) */
1407 /* if not, extend memory at the top and grab from there --- new */
1408 /* else fail ! */ /* paragraph 120 */
1409 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1410 halfword get_avail (void) 
1411 {
1412   register halfword Result; 
1413   halfword p; 
1414   p = avail; 
1415   if(p != 0)                /* while p<>null do */
1416   avail = mem[avail].hh.v.RH; 
1417   else if(mem_end < mem_max)        /* mem_end + 1 < mem_max ? NO */
1418   {
1419     incr(mem_end); 
1420     p = mem_end; 
1421   } 
1422   else { 
1423     decr(hi_mem_min); 
1424     p = hi_mem_min; 
1425 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1426     if(hi_mem_min <= lo_mem_max){   /* have we run out in middle ? */
1427     incr(hi_mem_min);       /* undo the change */
1428 /*    realloc_main (0, mem_top/2); */ /* extend main memory at hi end */
1429     mem = realloc_main (0, mem_top/2);  /* zzzaa = zmem = mem */
1430     if (mem == NULL) {
1431       return 0;
1432     }
1433 /* presumably now mem_end < mem_max - but need test in case allocation fails */
1434     if (mem_end >= mem_max)    {
1435       runaway (); 
1436       overflow(298, mem_max + 1 - mem_min); /* main memory size */
1437       return 0;           // abort_flag set
1438     } 
1439     incr(mem_end);        /* then grab from new area */
1440     p = mem_end;          /* 1993/Dec/14 */
1441   }
1442 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1443   } 
1444   mem[p].hh.v.RH = 0;       /* link(p) = null !!! */
1445   ;
1446 #ifdef STAT
1447   incr(dyn_used); 
1448 #endif /* STAT */
1449   Result = p; 
1450   return Result; 
1451
1452
1453 void flush_list_(halfword p)          /* paragraph 123 */
1454
1455   halfword q, r; 
1456   if(p != 0)              /* null !!! */
1457   {
1458     r = p; 
1459     do {
1460   q = r; 
1461       r = mem[r].hh.v.RH; 
1462   ;
1463 #ifdef STAT
1464       decr(dyn_used); 
1465 #endif /* STAT */
1466     } while(!(r == 0));     /* r != null */
1467     mem[q].hh.v.RH = avail; 
1468     avail = p; 
1469   } 
1470
1471
1472 halfword get_node_(integer s) 
1473 {/* 40 10 20 */
1474   register halfword Result; 
1475   halfword p; 
1476   halfword q; 
1477   integer r; 
1478   integer t; 
1479   lab20: p = rover; 
1480   do {
1481       q = p + mem[p].hh.v.LH; 
1482 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1483 /*    while((mem[q].hh.v.RH == 262143L)) { */ /* NO! */
1484     while((mem[q].hh.v.RH == empty_flag)) {
1485 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1486
1487     if (q == 0) {
1488 /* should never happen, since this field is reference count for zeroglue */
1489     }  /* debugging code 93/DEC/15 */ /* eventually remove */
1490
1491 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1492       t = mem[q + 1].hh.v.RH; 
1493       if(q == rover)
1494       rover = t; 
1495       mem[t + 1].hh.v.LH = mem[q + 1].hh.v.LH; 
1496       mem[mem[q + 1].hh.v.LH + 1].hh.v.RH = t; 
1497       q = q + mem[q].hh.v.LH; 
1498     } 
1499     r = q - s; 
1500     if(r > toint(p + 1)) 
1501     {
1502       mem[p].hh.v.LH = r - p; 
1503       rover = p; 
1504       goto lab40; 
1505     } 
1506     if(r == p)
1507     if(mem[p + 1].hh.v.RH != p)
1508     {
1509       rover = mem[p + 1].hh.v.RH; 
1510       t = mem[p + 1].hh.v.LH; 
1511       mem[rover + 1].hh.v.LH = t; 
1512       mem[t + 1].hh.v.RH = rover; 
1513       goto lab40; 
1514     } 
1515     mem[p].hh.v.LH = q - p; 
1516     p = mem[p + 1].hh.v.RH; 
1517   } while(!(p == rover)); 
1518   if(s == 1073741824L)    /* 2^30 - special case - merge adjacent */
1519   {
1520 /*    Result = 262143L;  */ /* NO ! */
1521     Result = empty_flag; 
1522 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1523   if (trace_flag) show_line("Merged adjacent multi-word nodes\n", 0);
1524 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1525     return Result; 
1526   } 
1527 /*  maybe try downward epxansion first instead ? */
1528   if(lo_mem_max + 2 < hi_mem_min)
1529
1530 /*  if(lo_mem_max + 2 <= 262143L) */  /* NO! */
1531   if(lo_mem_max + 2 <= mem_bot + max_halfword)  /* silly ? flush 93/Dec/16 */
1532
1533   {
1534 /*    if(hi_mem_min - lo_mem_max >= 1998) */
1535     if(hi_mem_min - lo_mem_max >= (block_size + block_size - 2))
1536 /*    t = lo_mem_max + 1000;  */
1537     t = lo_mem_max + block_size; 
1538     else t = lo_mem_max + 1 +(hi_mem_min - lo_mem_max)/ 2; 
1539     p = mem[rover + 1].hh.v.LH; 
1540     q = lo_mem_max; 
1541     mem[p + 1].hh.v.RH = q; 
1542     mem[rover + 1].hh.v.LH = q; 
1543
1544 /*    if(t > 262143L)   t = 262143L;  */ /* NO! */
1545     if(t > mem_bot + max_halfword)
1546     t = mem_bot + max_halfword;     /* silly ? flush 93/Dec/16 */
1547
1548     mem[q + 1].hh.v.RH = rover; 
1549     mem[q + 1].hh.v.LH = p; 
1550 /*    mem[q].hh.v.RH = 262143L; */ /* NO! */
1551     mem[q].hh.v.RH = empty_flag; 
1552     mem[q].hh.v.LH = t - lo_mem_max; /* block size */
1553     lo_mem_max = t; 
1554     mem[lo_mem_max].hh.v.RH = 0; 
1555     mem[lo_mem_max].hh.v.LH = 0; 
1556     rover = q; 
1557     goto lab20; 
1558   } 
1559 /*  overflow(298, mem_max + 1 - mem_min);  */ /* what used to happen! */
1560 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1561 /* we've run out of space in the middle for variable length blocks */
1562 /* try and add new block from below mem_bot *//* first check if space ! */
1563   if (mem_min - (block_size + 1) <= mem_start) {/* extend lower memory downwards */
1564 /*    realloc_main (mem_top/2, 0); */
1565     mem = realloc_main (mem_top/2 + block_size, 0);  /* zzzaa = zmem = mem */
1566     if (mem == NULL) {
1567       return 0;
1568     }
1569   }
1570 /*  if (trace_flag) show_line("Extending downwards by %d\n", block_size, 0); */
1571   if (mem_min - (block_size + 1) <= mem_start) { /* check again */
1572     if (trace_flag) {
1573       sprintf(log_line, "mem_min %d, mem_start %d, block_size %d\n", mem_min, mem_start, block_size);
1574       show_line(log_line, 0);
1575     }
1576     overflow(298, mem_max + 1 - mem_min); /* darn: allocation failed ! */
1577     return 0;     // abort_flag set
1578   }
1579 /* avoid function call in following ? */
1580   add_variable_space (block_size); /* now to be found in itex.c */
1581   goto lab20;         /* go try get_node again */
1582 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1583
1584   lab40: mem[r].hh.v.RH = 0; 
1585   ;
1586 #ifdef STAT
1587   var_used = var_used + s; 
1588 #endif /* STAT */
1589
1590 /*  if (trace_flag) {
1591     if (r == 0) show_line("r IS ZERO in ZGETNODE!\n", 0);
1592   } */      /* debugging code 93/dec/15 */
1593
1594   Result = r; 
1595   return Result; 
1596
1597
1598 void free_node_(halfword p, halfword s)
1599
1600   halfword q; 
1601   mem[p].hh.v.LH = s; 
1602 /*  mem[p].hh.v.RH = 262143L;  */ /* NO! */
1603   mem[p].hh.v.RH = empty_flag; 
1604   q = mem[rover + 1].hh.v.LH; 
1605   mem[p + 1].hh.v.LH = q; 
1606   mem[p + 1].hh.v.RH = rover; 
1607   mem[rover + 1].hh.v.LH = p; 
1608   mem[q + 1].hh.v.RH = p; 
1609   ;
1610 #ifdef STAT
1611   var_used = var_used - s; 
1612 #endif /* STAT */
1613
1614
1615 halfword new_null_box (void) 
1616 {
1617   register halfword Result; 
1618   halfword p; 
1619   p = get_node(7); 
1620   mem[p].hh.b0 = 0; 
1621   mem[p].hh.b1 = 0; 
1622   mem[p + 1].cint = 0; 
1623   mem[p + 2].cint = 0; 
1624   mem[p + 3].cint = 0; 
1625   mem[p + 4].cint = 0; 
1626   mem[p + 5].hh.v.RH = 0; 
1627   mem[p + 5].hh.b0 = 0; 
1628   mem[p + 5].hh.b1 = 0; 
1629   mem[p + 6].gr = 0.0; 
1630   Result = p; 
1631   return Result; 
1632
1633
1634 // @ A new rule node is delivered by the |new_rule| function. It
1635 //   makes all the dimensions ``running,'' so you have to change the
1636 //   ones that are not allowed to run.
1637
1638 halfword new_rule (void) 
1639 {
1640   register halfword Result;
1641   halfword p; 
1642   p = get_node(4);          /* rule_node_size */
1643   mem[p].hh.b0 = 2;       /* rule_node type */
1644   mem[p].hh.b1 = 0;       /* sub_type zero */
1645   mem[p + 1].cint = -1073741824L; /* -2^30 null_flag width */
1646   mem[p + 2].cint = -1073741824L; /* -2^30 null_flag depth */
1647   mem[p + 3].cint = -1073741824L; /* -2^30 null_flag height */
1648   Result = p; 
1649   return Result; 
1650
1651
1652 // @ The |new_ligature| function creates a ligature node having given
1653 //   contents of the |font|, |character|, and |lig_ptr| fields.
1654
1655 halfword new_ligature_(quarterword f, quarterword c, halfword q)
1656 {
1657   register halfword Result; 
1658   halfword p; 
1659   p = get_node(2);      /* small_node_size */
1660   mem[p].hh.b0 = 6;   /* ligature_node type */
1661   mem[p + 1].hh.b0 = f; /* font */
1662   mem[p + 1].hh.b1 = c; /* character */
1663   mem[p + 1].hh.v.RH = q; /* pointer */
1664   mem[p].hh.b1 = 0;   /* subtype zero */
1665   Result = p; 
1666   return Result; 
1667
1668
1669 //  We also have a |new_lig_item| function, which returns a two-word
1670 //  node having a given |character| field. Such nodes are used for
1671 //  temporary processing as ligatures are being created.
1672
1673 halfword new_lig_item_(quarterword c)
1674 {
1675   register halfword Result;
1676   halfword p; 
1677   p = get_node(2);      /* small_node_size */
1678   mem[p].hh.b1 = c;   /* character */ 
1679   mem[p + 1].hh.v.RH = 0; /* lig_ptr(p):=null; */
1680   Result = p; 
1681   return Result; 
1682
1683
1684 halfword new_disc (void) 
1685 {
1686   register halfword Result; 
1687   halfword p; 
1688   p = get_node(2); 
1689   mem[p].hh.b0 = 7; 
1690   mem[p].hh.b1 = 0; 
1691   mem[p + 1].hh.v.LH = 0; /* pre_break(p):=null; */
1692   mem[p + 1].hh.v.RH = 0; /* post_break(p):=null; */
1693   Result = p; 
1694   return Result; 
1695
1696
1697 halfword new_math_(scaled w, small_number s)
1698 {
1699   register halfword Result;
1700   halfword p; 
1701   p = get_node(2); 
1702   mem[p].hh.b0 = 9; 
1703   mem[p].hh.b1 = s; 
1704   mem[p + 1].cint = w; 
1705   Result = p; 
1706   return Result; 
1707
1708
1709 halfword new_spec_(halfword p)
1710 {
1711   register halfword Result;
1712   halfword q; 
1713   q = get_node(4); 
1714   mem[q]= mem[p]; 
1715   mem[q].hh.v.RH = 0; 
1716   mem[q + 1].cint = mem[p + 1].cint; 
1717   mem[q + 2].cint = mem[p + 2].cint; 
1718   mem[q + 3].cint = mem[p + 3].cint; 
1719   Result = q; 
1720   return Result; 
1721
1722
1723 halfword new_param_glue_(small_number n)
1724 {
1725   register halfword Result; 
1726   halfword p; 
1727   halfword q; 
1728   p = get_node(2); 
1729   mem[p].hh.b0 = 10; 
1730   mem[p].hh.b1 = n + 1; /* conversion int to unsigned short */
1731   mem[p + 1].hh.v.RH = 0; 
1732   q = eqtb[(hash_size + 782) + n].hh.v.RH; /* gluebase + n */
1733   mem[p + 1].hh.v.LH = q; 
1734   incr(mem[q].hh.v.RH); 
1735   Result = p; 
1736   return Result; 
1737
1738
1739 halfword new_glue_(halfword q)
1740 {
1741   register halfword Result; 
1742   halfword p; 
1743   p = get_node(2); 
1744   mem[p].hh.b0 = 10; 
1745   mem[p].hh.b1 = 0; 
1746   mem[p + 1].hh.v.RH = 0; 
1747   mem[p + 1].hh.v.LH = q; 
1748   incr(mem[q].hh.v.RH); 
1749   Result = p; 
1750   return Result; 
1751
1752
1753 halfword new_skip_param_(small_number n)
1754 {
1755   register halfword Result; 
1756   halfword p; 
1757   temp_ptr = new_spec(eqtb[(hash_size + 782) + n].hh.v.RH); /* gluebase + n */
1758   p = new_glue(temp_ptr); 
1759   mem[temp_ptr].hh.v.RH = 0; 
1760   mem[p].hh.b1 = n + 1;   /* conversion int to unsigned short */
1761   Result = p; 
1762   return Result; 
1763
1764
1765 halfword new_kern_(scaled w)
1766 {
1767   register halfword Result;
1768   halfword p; 
1769   p = get_node(2); 
1770   mem[p].hh.b0 = 11; 
1771   mem[p].hh.b1 = 0; 
1772   mem[p + 1].cint = w; 
1773   Result = p; 
1774   return Result; 
1775
1776
1777 halfword new_penalty_(integer m)
1778 {
1779   register halfword Result; 
1780   halfword p; 
1781   p = get_node(2); 
1782   mem[p].hh.b0 = 12; 
1783   mem[p].hh.b1 = 0; 
1784   mem[p + 1].cint = m; 
1785   Result = p; 
1786   return Result; 
1787
1788
1789 #ifdef DEBUG
1790 void check_mem_(bool printlocs)
1791 {/* 31 32 */  
1792   halfword p, q; 
1793   bool clobbered; 
1794   {register integer for_end; p = mem_min; for_end = lo_mem_max; if(p <= 
1795   for_end) do 
1796     freearr[p]= false; 
1797   while(p++ < for_end); } 
1798   {register integer for_end; p = hi_mem_min; for_end = mem_end; if(p <= 
1799   for_end) do 
1800     freearr[p]= false; 
1801   while(p++ < for_end); } 
1802   p = avail; 
1803   q = 0; 
1804   clobbered = false; 
1805   while(p != 0){    /* while p<>null do */
1806       
1807     if((p > mem_end)||(p < hi_mem_min)) 
1808     clobbered = true; 
1809     else if(freearr[p])
1810     clobbered = true; 
1811     if(clobbered)
1812     {
1813       print_nl("AVAIL list clobbered at ");    /*  */
1814       print_int(q); 
1815       goto lab31; 
1816     } 
1817     freearr[p]= true; 
1818     q = p; 
1819     p = mem[q].hh.v.RH; 
1820   } 
1821   lab31:; 
1822   p = rover; 
1823   q = 0;        /* q:=null */
1824   clobbered = false; 
1825   do {
1826       if((p >= lo_mem_max)||(p < mem_min)) 
1827     clobbered = true; 
1828     else if((mem[p + 1].hh.v.RH >= lo_mem_max)||(mem[p + 1].hh 
1829    .v.RH < mem_min)) 
1830     clobbered = true; 
1831 /*    else if(!((mem[p].hh.v.RH == 262143L)) ||(mem[p].hh *//*NO!*/
1832     else if(!((mem[p].hh.v.RH == empty_flag)) ||(mem[p].hh 
1833    .v.LH < 2)||(p + mem[p].hh.v.LH > lo_mem_max)||(mem[mem[p + 
1834     1].hh.v.RH + 1].hh.v.LH != p)) 
1835     clobbered = true; 
1836     if(clobbered)
1837     {
1838       print_nl("Double-AVAIL list clobbered at ");    /*  */
1839       print_int(q); 
1840       goto lab32; 
1841     } 
1842     {register integer for_end; q = p; for_end = p + mem[p].hh.v.LH - 1 
1843  ; if(q <= for_end) do 
1844       {
1845   if(freearr[q])
1846   {
1847     print_nl("Doubly free location at ");    /*  */
1848     print_int(q); 
1849     goto lab32; 
1850   } 
1851   freearr[q]= true; 
1852       } 
1853     while(q++ < for_end); } 
1854     q = p; 
1855     p = mem[p + 1].hh.v.RH; 
1856   } while(!(p == rover)); 
1857   lab32:; 
1858   p = mem_min; 
1859   while(p <= lo_mem_max){
1860       
1861 /*    if((mem[p].hh.v.RH == 262143L))  */ /* NO! */
1862     if((mem[p].hh.v.RH == empty_flag)) 
1863     {
1864       print_nl("Bad flag at ");      /*  */
1865       print_int(p); 
1866     } 
1867     while((p <= lo_mem_max)&& ! freearr[p])incr(p); 
1868     while((p <= lo_mem_max)&& freearr[p])incr(p); 
1869   } 
1870   if(printlocs)
1871   {
1872     print_nl("New busy locs:");      /*  */
1873     {register integer for_end; p = mem_min; for_end = lo_mem_max; if(p <= 
1874     for_end) do 
1875       if(! freearr[p]&&((p > waslomax)|| wasfree[p])) 
1876       {
1877   print_char(32);     /*   */
1878   print_int(p); 
1879       } 
1880     while(p++ < for_end); } 
1881     {register integer for_end; p = hi_mem_min; for_end = mem_end; if(p <= 
1882     for_end) do 
1883       if(! freearr[p]&&((p < washimin)||(p > wasmemend)|| 
1884       wasfree[p])) 
1885       {
1886   print_char(32);     /*   */
1887   print_int(p); 
1888       } 
1889     while(p++ < for_end); } 
1890   } 
1891   {register integer for_end; p = mem_min; for_end = lo_mem_max; if(p <= 
1892   for_end) do 
1893     wasfree[p]= freearr[p]; 
1894   while(p++ < for_end); } 
1895   {register integer for_end; p = hi_mem_min; for_end = mem_end; if(p <= 
1896   for_end) do 
1897     wasfree[p]= freearr[p]; 
1898   while(p++ < for_end); } 
1899   wasmemend = mem_end; 
1900   waslomax = lo_mem_max; 
1901   washimin = hi_mem_min; 
1902
1903 #endif /* DEBUG */
1904
1905 #ifdef DEBUG
1906 void search_mem_(halfword p)
1907 {
1908   integer q; 
1909   {register integer for_end; q = mem_min; for_end = lo_mem_max; if(q <= 
1910   for_end) do 
1911     {
1912       if(mem[q].hh.v.RH == p)
1913       {
1914   print_nl("LINK(");  /* */
1915   print_int(q); 
1916   print_char(41); /*)*/
1917       } 
1918       if(mem[q].hh.v.LH == p)
1919       {
1920   print_nl("INFO(");  /* */
1921   print_int(q); 
1922   print_char(41); /*)*/
1923       } 
1924     } 
1925   while(q++ < for_end); } 
1926   {register integer for_end; q = hi_mem_min; for_end = mem_end; if(q <= 
1927   for_end) do 
1928     {
1929       if(mem[q].hh.v.RH == p)
1930       {
1931   print_nl("LINK(");  /* */
1932   print_int(q); 
1933   print_char(41); /*)*/
1934       } 
1935       if(mem[q].hh.v.LH == p)
1936       {
1937   print_nl("INFO(");  /* */
1938   print_int(q); 
1939   print_char(41); /*)*/
1940       } 
1941     } 
1942   while(q++ < for_end); } 
1943   {register integer for_end; q = 1; for_end = (hash_size + 1833); if(q <= for_end) do 
1944     {
1945       if(eqtb[q].hh.v.RH == p)
1946       {
1947   print_nl("EQUIV(");    /* */
1948   print_int(q); 
1949   print_char(41);   /*)*/
1950       } 
1951     } 
1952   while(q++ < for_end); } 
1953   if(save_ptr > 0)
1954   {register integer for_end; q = 0; for_end = save_ptr - 1; if(q <= 
1955   for_end) do 
1956     {
1957       if(save_stack[q].hh.v.RH == p)
1958       {
1959   print_nl("SAVE(");      /* */
1960   print_int(q); 
1961   print_char(41);     /*)*/
1962       } 
1963     } 
1964   while(q++ < for_end); } 
1965 /*  {register integer for_end; q = 0; for_end = 607; if(q <= for_end) do */
1966   {register integer for_end; q = 0; for_end = hyphen_prime; if(q <= for_end) do 
1967     {
1968       if(hyph_list[q]== p)
1969       {
1970   print_nl("HYPH(");
1971   print_int(q); 
1972   print_char(41);     /*)*/
1973       } 
1974     } 
1975   while(q++ < for_end); } 
1976
1977 #endif /* DEBUG */
1978
1979 void short_display_(integer p)
1980 {
1981   integer n; 
1982 /*  while(p > mem_min){ */
1983   while(p != 0){      /* want p != null here bkph 93/Dec/15 !!! */
1984                 /* NOTE: still not fixed in 3.14159 ! */
1985      if((p >= hi_mem_min))  /* is_char_node(p) */
1986     {
1987       if(p <= mem_end)
1988       {
1989   if(mem[p].hh.b0 != font_in_short_display) /* font(p) */
1990   {
1991     if((mem[p].hh.b0 > font_max)) 
1992     print_char(42);   /* * */
1993 /*    else print_esc(hash[(hash_size + 524) + mem[p].hh.b0].v.RH); */
1994     else //print_esc(hash[(hash_size + hash_extra + 524) + mem[p].hh.b0].v.RH);
1995                 print_esc("");print(hash[(hash_size + hash_extra + 524) + mem[p].hh.b0].v.RH);
1996                             /* 96/Jan/10 */
1997     print_char(32);   /*   */
1998     font_in_short_display = mem[p].hh.b0; 
1999   } 
2000   print(mem[p].hh.b1);          /* character(p) */
2001       } 
2002     } 
2003     else switch(mem[p].hh.b0)
2004     {case 0 : 
2005     case 1 : 
2006     case 3 : 
2007     case 8 : 
2008     case 4 : 
2009     case 5 : 
2010     case 13 : 
2011       print(306);   /* [] */
2012       break; 
2013     case 2 : 
2014       print_char(124);  /* | */
2015       break; 
2016     case 10 : 
2017       if(mem[p + 1].hh.v.LH != 0)
2018       print_char(32); /*   */
2019       break; 
2020     case 9 : 
2021       print_char(36); /* $ */
2022       break; 
2023     case 6 : 
2024       short_display(mem[p + 1].hh.v.RH); 
2025       break; 
2026     case 7 : 
2027       {
2028   short_display(mem[p + 1].hh.v.LH); 
2029   short_display(mem[p + 1].hh.v.RH); 
2030   n = mem[p].hh.b1; 
2031   while(n > 0){
2032       
2033     if(mem[p].hh.v.RH != 0) /* if link(p)<>null then */
2034     p = mem[p].hh.v.RH; 
2035     decr(n); 
2036   } 
2037       } 
2038       break; 
2039       default: 
2040    ; 
2041       break; 
2042     } 
2043     p = mem[p].hh.v.RH; 
2044   } 
2045
2046
2047 void print_font_and_char_ (integer p)
2048 {
2049   if(p > mem_end)
2050     print_esc("CLOBBERED.");
2051   else {
2052     if((mem[p].hh.b0 > font_max)) /* font(p) */
2053       print_char(42);   /* * */
2054 /*    else print_esc(hash[(hash_size + 524) + mem[p].hh.b0].v.RH); */
2055     else
2056       //print_esc(hash[(hash_size + hash_extra + 524) + mem[p].hh.b0].v.RH); /* 96/Jan/10 */
2057         {print_esc("");print(hash[(hash_size + hash_extra + 524) + mem[p].hh.b0].v.RH);}
2058     print_char(32);   /*   */
2059     print(mem[p].hh.b1);      /* character(p) */
2060   } 
2061
2062
2063 void print_mark_ (integer p)
2064
2065   print_char(123);    /* { */
2066   if((p < hi_mem_min)||(p > mem_end)) 
2067     print_esc("CLOBBERED.");
2068   else show_token_list(mem[p].hh.v.RH, 0, max_print_line - 10); 
2069   print_char(125);    /* } */
2070
2071
2072 void print_rule_dimen_ (scaled d)
2073 {
2074   if((d == -1073741824L)) /* - 2^30 */
2075     print_char(42);   /* * */
2076   else
2077     print_scaled(d); 
2078
2079
2080 void print_glue_(scaled d, integer order, str_number s)
2081 {
2082   print_scaled(d); 
2083   if((order < 0)||(order > 3)) 
2084     print(308); /* foul */
2085   else if(order > 0)
2086   {
2087     print(309); /* fil */
2088     while(order > 1){
2089   
2090       print_char(108); /* l */
2091       decr(order); 
2092     } 
2093   } 
2094   else if(s != 0)
2095   print(s); 
2096
2097
2098 void print_spec_(integer p, str_number s)
2099 {
2100   if((p < mem_min)||(p >= lo_mem_max)) 
2101   print_char(42);   /* * */
2102   else {
2103     print_scaled(mem[p + 1].cint); 
2104     if(s != 0)
2105     print(s); 
2106     if(mem[p + 2].cint != 0)
2107     {
2108       print(310); /*  plus */
2109       print_glue(mem[p + 2].cint, mem[p].hh.b0, s); 
2110     } 
2111     if(mem[p + 3].cint != 0)
2112     {
2113       print(311); /*  minus */
2114       print_glue(mem[p + 3].cint, mem[p].hh.b1, s); 
2115     } 
2116   } 
2117
2118
2119 void print_fam_and_char_(halfword p)
2120
2121   print_esc("fam");
2122   print_int(mem[p].hh.b0); 
2123   print_char(32);     /*    */
2124   print(mem[p].hh.b1); 
2125
2126
2127 void print_delimiter_(halfword p)
2128 {
2129   integer a; 
2130   a = mem[p].qqqq.b0 * 256 + mem[p].qqqq.b1; 
2131   a = a * 4096 + mem[p].qqqq.b2 * 256 + mem[p].qqqq.b3; 
2132   if(a < 0)
2133   print_int(a); 
2134   else print_hex(a); 
2135
2136
2137 void print_subsidiary_data_(halfword p, ASCII_code c)
2138 {
2139   if((pool_ptr - str_start[str_ptr]) >= depth_threshold)
2140   {
2141     if(mem[p].hh.v.RH != 0)
2142     print(312); /* [] */
2143   } 
2144   else {
2145       
2146     {
2147       str_pool[pool_ptr]= c; 
2148       incr(pool_ptr); 
2149     } 
2150     temp_ptr = p; 
2151     switch(mem[p].hh.v.RH)
2152     {case 1 : 
2153       {
2154   print_ln (); 
2155   print_current_string (); 
2156   print_fam_and_char(p); 
2157       } 
2158       break; 
2159     case 2 : 
2160       show_info (); 
2161       break; 
2162     case 3 : 
2163       if(mem[p].hh.v.LH == 0)
2164       {
2165   print_ln (); 
2166   print_current_string (); 
2167   print(854);       /* {} */
2168       } 
2169       else show_info (); 
2170       break; 
2171       default: 
2172    ; 
2173       break; 
2174     } 
2175     decr(pool_ptr); 
2176   } 
2177
2178
2179 void print_style_(integer c)
2180 {
2181   switch(c / 2)
2182   {case 0 : 
2183     print_esc("displaystyle");
2184     break; 
2185   case 1 : 
2186     print_esc("textstyle");
2187     break; 
2188   case 2 : 
2189     print_esc("scriptstyle");
2190     break; 
2191   case 3 : 
2192     print_esc("scriptscriptstyle");
2193     break; 
2194     default: 
2195     print(859);     /*  */
2196     break; 
2197   } 
2198
2199
2200 void print_skip_param_(integer n)
2201 {
2202   switch(n)
2203   {case 0 : 
2204     print_esc("lineskip");
2205     break; 
2206   case 1 : 
2207     print_esc("baselineskip");
2208     break; 
2209   case 2 : 
2210     print_esc("parskip");
2211     break; 
2212   case 3 : 
2213     print_esc("abovedisplayskip");
2214     break; 
2215   case 4 : 
2216     print_esc("belowdisplayskip");
2217     break; 
2218   case 5 : 
2219     print_esc("abovedisplayshortskip");
2220     break; 
2221   case 6 : 
2222     print_esc("belowdisplayshortskip");
2223     break; 
2224   case 7 : 
2225     print_esc("leftskip");
2226     break; 
2227   case 8 : 
2228     print_esc("rightskip");
2229     break; 
2230   case 9 : 
2231     print_esc("topskip");
2232     break; 
2233   case 10 : 
2234     print_esc("splittopskip");
2235     break; 
2236   case 11 : 
2237     print_esc("tabskip");
2238     break; 
2239   case 12 : 
2240     print_esc("spaceskip");
2241     break; 
2242   case 13 : 
2243     print_esc("xspaceskip");
2244     break; 
2245   case 14 : 
2246     print_esc("parfillskip");
2247     break; 
2248   case 15 : 
2249     print_esc("thinmuskip");
2250     break; 
2251   case 16 : 
2252     print_esc("medmuskip");
2253     break; 
2254   case 17 : 
2255     print_esc("thickmuskip");
2256     break; 
2257     default: 
2258     print(391);     /* [unknown glue parameter!] */
2259     break; 
2260   } 
2261
2262
2263 void show_node_list_(integer p)
2264 {/* 10 */ 
2265   integer n; 
2266   real g; 
2267 /* begin if cur_length>depth_threshold then */
2268   if((pool_ptr - str_start[str_ptr])> depth_threshold)
2269   {
2270 /*    if(p > 0) */  /* was p>null !!! line 3662 in tex.web */
2271     if(p != 0)    /* fixed 94/Mar/23 BUG FIX */
2272             /* NOTE: still not fixed in 3.14159 ! */
2273     print(312);   /* [] */
2274     return; 
2275   } 
2276   n = 0; 
2277 /*  while(p > mem_min){ */  /* was p>mem_min !!! line 3667 in tex.web */
2278   while(p != 0){      /* want p != null - bkph 93/Dec/15 */
2279                 /* NOTE: still not fixed in 3.14159 ! */
2280     print_ln (); 
2281     print_current_string (); 
2282     if(p > mem_end)
2283     {
2284       print(313); /* Bad link, display aborted. */
2285       return; 
2286     } 
2287     incr(n); 
2288     if(n > breadth_max)
2289     {
2290       print(314); /* etc. */
2291       return; 
2292     } 
2293     if((p >= hi_mem_min)) 
2294     print_font_and_char(p); 
2295     else switch(mem[p].hh.b0)
2296     {case 0 : 
2297     case 1 : 
2298     case 13 : 
2299       {
2300   if(mem[p].hh.b0 == 0)
2301     print_esc("h");
2302   else if(mem[p].hh.b0 == 1)
2303     print_esc("v");
2304   else print_esc("unset");
2305   print(317);       /* box(*/
2306   print_scaled(mem[p + 3].cint); 
2307   print_char(43);     /* + */
2308   print_scaled(mem[p + 2].cint); 
2309   print(318);       /*, shifted  */
2310   print_scaled(mem[p + 1].cint); 
2311   if(mem[p].hh.b0 == 13)
2312   {
2313     if(mem[p].hh.b1 != 0)
2314     {
2315       print(284);     /* (*/
2316       print_int(mem[p].hh.b1 + 1); 
2317       print(320);     /*  columns) */
2318     } 
2319     if(mem[p + 6].cint != 0)
2320     {
2321       print(321);     /*, stretch */
2322       print_glue(mem[p + 6].cint, mem[p + 5].hh.b1, 0); 
2323     } 
2324     if(mem[p + 4].cint != 0)
2325     {
2326       print(322);     /*, shrink */
2327       print_glue(mem[p + 4].cint, mem[p + 5].hh.b0, 0); 
2328     } 
2329   } 
2330   else {
2331       
2332     g = mem[p + 6].gr; 
2333     if((g != 0.0)&&(mem[p + 5].hh.b0 != 0)) 
2334     {
2335       print(323);   /*, glue set */
2336       if(mem[p + 5].hh.b0 == 2)
2337       print(324);   /* -  */
2338       if(fabs(g)> 20000.0)
2339       {
2340         if(g > 0.0)
2341         print_char(62); /* '>' */
2342         else print(325);  /* < - */
2343         print_glue(20000 * 65536L, mem[p + 5].hh.b1, 0); 
2344       } 
2345       else print_glue(round(65536L * g), mem[p + 5].hh.b1, 0)
2346    ; 
2347     } 
2348     if(mem[p + 4].cint != 0)
2349     {
2350       print(319);   /* shifted */
2351       print_scaled(mem[p + 4].cint); 
2352     } 
2353   } 
2354   {
2355     {
2356       str_pool[pool_ptr]= 46; 
2357       incr(pool_ptr); 
2358     } 
2359     show_node_list(mem[p + 5].hh.v.RH); 
2360     decr(pool_ptr); 
2361   } 
2362       } 
2363       break; 
2364     case 2 : 
2365       {
2366   print_esc("rule(");
2367   print_rule_dimen(mem[p + 3].cint); 
2368   print_char(43); /* '+' */
2369   print_rule_dimen(mem[p + 2].cint); 
2370   print(318);   /*)x */
2371   print_rule_dimen(mem[p + 1].cint); 
2372       } 
2373       break; 
2374     case 3 : 
2375       {
2376   print_esc("insert");
2377   print_int(mem[p].hh.b1); 
2378   print(328);   /*, natural size */
2379   print_scaled(mem[p + 3].cint); 
2380   print(329);   /*; split(*/
2381   print_spec(mem[p + 4].hh.v.RH, 0); 
2382   print_char(44); /* ',' */
2383   print_scaled(mem[p + 2].cint); 
2384   print(330);   /* (; float cost */
2385   print_int(mem[p + 1].cint); 
2386   {
2387     {
2388       str_pool[pool_ptr]= 46; 
2389       incr(pool_ptr); 
2390     } 
2391     show_node_list(mem[p + 4].hh.v.LH); 
2392     decr(pool_ptr); 
2393   } 
2394       } 
2395       break; 
2396     case 8 : 
2397       switch(mem[p].hh.b1)
2398       {case 0 : 
2399   {
2400     print_write_whatsit(1279, p);   /* debug # (-1 to exit): */
2401     print_char(61); /* = */
2402     print_file_name(mem[p + 1].hh.v.RH, mem[p + 2].hh.v.LH, 
2403     mem[p + 2].hh.v.RH); 
2404   } 
2405   break; 
2406       case 1 : 
2407   {
2408     print_write_whatsit(591, p);  /* write */
2409     print_mark(mem[p + 1].hh.v.RH); 
2410   } 
2411   break; 
2412       case 2 : 
2413   print_write_whatsit(1280, p); /* closeout */
2414   break; 
2415       case 3 : 
2416   {
2417     print_esc("special");
2418     print_mark(mem[p + 1].hh.v.RH); 
2419   } 
2420   break; 
2421       case 4 : 
2422   {
2423     print_esc("setlanguage");
2424     print_int(mem[p + 1].hh.v.RH); 
2425     print(1286);      /*  (hyphenmin */
2426     print_int(mem[p + 1].hh.b0); 
2427     print_char(44);   /*, */
2428     print_int(mem[p + 1].hh.b1); 
2429     print_char(41);   /*)*/
2430   } 
2431   break; 
2432   default: 
2433   print(1287);    /* whatsit */
2434   break; 
2435       } 
2436       break; 
2437     case 10 : 
2438       if(mem[p].hh.b1 >= 100)
2439       {
2440   print_esc("");
2441   if(mem[p].hh.b1 == 101)
2442   print_char(99); /* c */
2443   else if(mem[p].hh.b1 == 102)
2444   print_char(120); /* x */
2445   print(336);   /* leaders  */
2446   print_spec(mem[p + 1].hh.v.LH, 0); 
2447   {
2448     {
2449       str_pool[pool_ptr]= 46; 
2450       incr(pool_ptr); 
2451     } 
2452     show_node_list(mem[p + 1].hh.v.RH); 
2453     decr(pool_ptr); 
2454   } 
2455       } 
2456       else {
2457     
2458   print_esc("glue");
2459   if(mem[p].hh.b1 != 0)
2460   {
2461     print_char(40); /*(*/
2462     if(mem[p].hh.b1 < 98)
2463       print_skip_param(mem[p].hh.b1 - 1); 
2464     else if(mem[p].hh.b1 == 98)
2465       print_esc("nonscript");
2466     else print_esc("mskip");
2467     print_char(41); /*)*/
2468   } 
2469   if(mem[p].hh.b1 != 98)
2470   {
2471     print_char(32); /*   */
2472     if(mem[p].hh.b1 < 98)
2473     print_spec(mem[p + 1].hh.v.LH, 0); 
2474     else print_spec(mem[p + 1].hh.v.LH, 334); /* mu */
2475   } 
2476       } 
2477       break; 
2478     case 11 : 
2479       if(mem[p].hh.b1 != 99)
2480       {
2481   print_esc("kern");
2482   if(mem[p].hh.b1 != 0)
2483   print_char(32);   /*   */
2484   print_scaled(mem[p + 1].cint); 
2485   if(mem[p].hh.b1 == 2)
2486   print(338);   /*  (for accent) */
2487       } 
2488       else {
2489   print_esc("mkern");
2490   print_scaled(mem[p + 1].cint); 
2491   print(334);   /* mu */
2492       } 
2493       break; 
2494     case 9 : 
2495       {
2496   print_esc("math");
2497   if(mem[p].hh.b1 == 0)
2498     print(341);   /* on */
2499   else print(342);  /* off */ 
2500   if(mem[p + 1].cint != 0)
2501   {
2502     print(343); /*, surrounded */
2503     print_scaled(mem[p + 1].cint); 
2504   } 
2505       } 
2506       break; 
2507     case 6 : 
2508       {
2509   print_font_and_char(p + 1); 
2510   print(344);   /* (ligature */
2511   if(mem[p].hh.b1 > 1)
2512   print_char(124); /* | */
2513   font_in_short_display = mem[p + 1].hh.b0; 
2514   short_display(mem[p + 1].hh.v.RH); 
2515   if(odd(mem[p].hh.b1)) 
2516   print_char(124); /* | */
2517   print_char(41); /*)*/
2518       } 
2519       break; 
2520     case 12 : 
2521       {
2522   print_esc("penalty ");
2523   print_int(mem[p + 1].cint); 
2524       } 
2525       break; 
2526     case 7 : 
2527       {
2528   print_esc("discretionary");
2529   if(mem[p].hh.b1 > 0)
2530   {
2531     print(347); /*  replacing  */
2532     print_int(mem[p].hh.b1); 
2533   } 
2534   {
2535     {
2536       str_pool[pool_ptr]= 46; 
2537       incr(pool_ptr); 
2538     } 
2539     show_node_list(mem[p + 1].hh.v.LH); 
2540     decr(pool_ptr); 
2541   } 
2542   {
2543     str_pool[pool_ptr]= 124; 
2544     incr(pool_ptr); 
2545   } 
2546   show_node_list(mem[p + 1].hh.v.RH); 
2547   decr(pool_ptr); 
2548       } 
2549       break; 
2550     case 4 : 
2551       {
2552   print_esc("mark");
2553   print_mark(mem[p + 1].cint); 
2554       } 
2555       break; 
2556     case 5 : 
2557       {
2558   print_esc("vadjust");
2559   {
2560     {
2561       str_pool[pool_ptr]= 46; 
2562       incr(pool_ptr); 
2563     } 
2564     show_node_list(mem[p + 1].cint); 
2565     decr(pool_ptr); 
2566   } 
2567       } 
2568       break; 
2569     case 14 : 
2570       print_style(mem[p].hh.b1); 
2571       break; 
2572     case 15 : 
2573       {
2574   print_esc("mathchoice");
2575   {
2576     str_pool[pool_ptr]= 68; 
2577     incr(pool_ptr); 
2578   } 
2579   show_node_list(mem[p + 1].hh.v.LH); 
2580   decr(pool_ptr); 
2581   {
2582     str_pool[pool_ptr]= 84; 
2583     incr(pool_ptr); 
2584   } 
2585   show_node_list(mem[p + 1].hh.v.RH); 
2586   decr(pool_ptr); 
2587   {
2588     str_pool[pool_ptr]= 83; 
2589     incr(pool_ptr); 
2590   } 
2591   show_node_list(mem[p + 2].hh.v.LH); 
2592   decr(pool_ptr); 
2593   {
2594     str_pool[pool_ptr]= 115; 
2595     incr(pool_ptr); 
2596   } 
2597   show_node_list(mem[p + 2].hh.v.RH); 
2598   decr(pool_ptr); 
2599       } 
2600       break; 
2601     case 16 : 
2602     case 17 : 
2603     case 18 : 
2604     case 19 : 
2605     case 20 : 
2606     case 21 : 
2607     case 22 : 
2608     case 23 : 
2609     case 24 : 
2610     case 27 : 
2611     case 26 : 
2612     case 29 : 
2613     case 28 : 
2614     case 30 : 
2615     case 31 : 
2616       {
2617   switch(mem[p].hh.b0)
2618   {case 16 : 
2619     print_esc("mathord");
2620     break; 
2621   case 17 : 
2622     print_esc("mathop");
2623     break; 
2624   case 18 : 
2625     print_esc("mathbin");
2626     break; 
2627   case 19 : 
2628     print_esc("mathrel");
2629     break; 
2630   case 20 : 
2631     print_esc("mathopen");
2632     break; 
2633   case 21 : 
2634     print_esc("mathclose");
2635     break; 
2636   case 22 : 
2637     print_esc("mathpunct");
2638     break; 
2639   case 23 : 
2640     print_esc("mathinner");
2641     break; 
2642   case 27 : 
2643     print_esc("overline");
2644     break; 
2645   case 26 : 
2646     print_esc("underline");
2647     break; 
2648   case 29 : 
2649     print_esc("vcenter");
2650     break; 
2651   case 24 : 
2652     {
2653       print_esc("radical");
2654       print_delimiter(p + 4); 
2655     } 
2656     break; 
2657   case 28 : 
2658     {
2659       print_esc("accent");
2660       print_fam_and_char(p + 4); 
2661     } 
2662     break; 
2663   case 30 : 
2664     {
2665       print_esc("left");
2666       print_delimiter(p + 1); 
2667     } 
2668     break; 
2669   case 31 : 
2670     {
2671       print_esc("right");
2672       print_delimiter(p + 1); 
2673     } 
2674     break; 
2675   } 
2676   if(mem[p].hh.b1 != 0)
2677   if(mem[p].hh.b1 == 1)
2678     print_esc("limits");
2679   else print_esc("nolimits");
2680   if(mem[p].hh.b0 < 30)
2681   print_subsidiary_data(p + 1, 46); 
2682   print_subsidiary_data(p + 2, 94); 
2683   print_subsidiary_data(p + 3, 95); 
2684       } 
2685       break; 
2686     case 25 : 
2687       {
2688   print_esc("fraction");
2689   if(mem[p + 1].cint == 1073741824L)  /* 2^30 */
2690   print(875);     /* = default */
2691   else print_scaled(mem[p + 1].cint); 
2692   if((mem[p + 4].qqqq.b0 != 0)||(mem[p + 4].qqqq.b1 != 
2693   0)||(mem[p + 4].qqqq.b2 != 0)||(mem[p + 4].qqqq.b3 
2694   != 0)) 
2695   {
2696     print(876);   /*, left */
2697     print_delimiter(p + 4); 
2698   } 
2699   if((mem[p + 5].qqqq.b0 != 0)||(mem[p + 5].qqqq.b1 != 
2700   0)||(mem[p + 5].qqqq.b2 != 0)||(mem[p + 5].qqqq.b3 
2701   != 0)) 
2702   {
2703     print(877);   /*, right */
2704     print_delimiter(p + 5); 
2705   } 
2706   print_subsidiary_data(p + 2, 92); 
2707   print_subsidiary_data(p + 3, 47); 
2708       } 
2709       break; 
2710       default: 
2711       print(315); /* Unknown node type! */
2712       break; 
2713     } 
2714     p = mem[p].hh.v.RH; 
2715   } 
2716
2717
2718 /* NOTE: 262143L should be empty_flag */