2 Copyright 2014 Clerk Ma
\r
4 This program is free software; you can redistribute it and/or modify
\r
5 it under the terms of the GNU General Public License as published by
\r
6 the Free Software Foundation; either version 2 of the License, or
\r
7 (at your option) any later version.
\r
9 This program is distributed in the hope that it will be useful, but
\r
10 WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
12 General Public License for more details.
\r
14 You should have received a copy of the GNU General Public License
\r
15 along with this program; if not, write to the Free Software
\r
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
\r
20 #define EXTERN extern
\r
21 #include "yandytex.h"
\r
24 void print_ln (void)
\r
52 putc('\n', write_file[selector]);
\r
57 void print_char_ (ASCII_code s)
\r
59 if (s == new_line_char)
\r
60 if (selector < pseudo)
\r
74 if (term_offset == max_print_line)
\r
80 if (file_offset == max_print_line)
\r
92 if (file_offset == max_print_line)
\r
101 if (term_offset == max_print_line)
\r
111 if (tally < trick_count)
\r
112 trick_buf[tally % error_line] = s;
\r
117 #ifdef ALLOCATESTRING
\r
118 if (pool_ptr + 1 > current_pool_size)
\r
119 str_pool = realloc_str_pool(increment_pool_size);
\r
121 if (pool_ptr < current_pool_size)
\r
124 if (pool_ptr < pool_size)
\r
130 putc(xchr[s], write_file[selector]);
\r
137 void print_ (integer s)
\r
152 if (selector > pseudo)
\r
158 if (s == new_line_char)
\r
159 if (selector < pseudo)
\r
165 nl = new_line_char;
\r
166 new_line_char = -1;
\r
168 if (!show_in_hex && s < 256 && s >= 32)
\r
170 print_char(s); /* don't translate to hex */
\r
173 { /* not just a character */
\r
176 while (j < str_start[s + 1])
\r
178 print_char(str_pool[j]);
\r
183 new_line_char = nl; /* restore eol */
\r
188 /* we get here with s > 256 - i.e. not a single character */
\r
191 while (j < str_start[s + 1])
\r
193 print_char(str_pool[j]);
\r
197 /* string version print. */
\r
198 void prints_ (const char * s)
\r
204 void slow_print_ (integer s)
\r
208 if ((s >= str_ptr) || (s < 256))
\r
214 while (j < str_start[s + 1])
\r
216 print(str_pool[j]);
\r
222 void print_nl (const char * s)
\r
224 if (((term_offset > 0) && (odd(selector))) ||
\r
225 ((file_offset > 0) && (selector >= log_only)))
\r
231 void print_esc (const char * s)
\r
244 void print_the_digs (eight_bits k)
\r
251 print_char('0' + dig[k]);
\r
253 print_char('A' + dig[k]);
\r
257 void print_int_ (integer n)
\r
268 if (n > -100000000L)
\r
289 dig[k] = (char) (n % 10);
\r
298 void print_cs_ (integer p)
\r
301 if (p >= single_base)
\r
304 print_esc("csname");
\r
305 print_esc("endcsname");
\r
310 print_esc(""); print(p - single_base);
\r
312 if (cat_code(p - single_base) == letter)
\r
315 else if (p < active_base)
\r
316 print_esc("IMPOSSIBLE.");
\r
318 print(p - active_base);
\r
319 else if (p >= undefined_control_sequence)
\r
320 print_esc("IMPOSSIBLE.");
\r
321 else if ((text(p) >= str_ptr))
\r
322 print_esc("NONEXISTENT.");
\r
331 void sprint_cs (pointer p)
\r
334 if (p < single_base)
\r
335 print(p - active_base);
\r
336 else if (p < null_cs)
\r
339 print(p - single_base);
\r
343 print_esc("csname");
\r
344 print_esc("endcsname");
\r
348 print_esc(""); print(text(p));
\r
352 void print_file_name (integer n, integer a, integer e)
\r
359 void print_size_ (integer s)
\r
362 print_esc("textfont");
\r
364 print_esc("scriptfont");
\r
366 print_esc("scriptscriptfont");
\r
369 void print_write_whatsit_(const char * s, pointer p)
\r
373 if (write_stream(p) < 16)
\r
374 print_int(write_stream(p));
\r
375 else if (write_stream(p) == 16)
\r
381 void jump_out (void)
\r
383 close_files_and_terminate();
\r
392 puts("EXITING at JUMPOUT");
\r
394 if ((history != 0) && (history != 1))
\r
406 integer s1, s2, s3, s4;
\r
408 if (history < error_message_issued)
\r
409 history = error_message_issued;
\r
414 if (interaction == error_stop_mode)
\r
418 clear_for_error_prompt();
\r
419 prompt_input("? ");
\r
422 return; // no input
\r
427 c = (c + 'A' - 'a');
\r
441 if (deletions_allowed)
\r
447 align_state = 1000000L;
\r
448 OK_to_interrupt = false;
\r
450 if ((last > first + 1) && (buffer[first + 1] >= '0') && (buffer[first + 1] <= '9'))
\r
451 c = (c * 10 + buffer[first + 1] - '0' * 11);
\r
465 OK_to_interrupt = true;
\r
466 help2("I have just deleted some text, as you asked.",
\r
467 "You can now delete more, or insert, or whatever.");
\r
485 edit_name_start = str_start[input_stack[base_ptr].name_field];
\r
486 edit_name_length = length(input_stack[base_ptr].name_field);
\r
497 use_err_help = false;
\r
502 help2("Sorry, I don't know how to help in this situation.",
\r
503 "Maybe you should try asking a human?");
\r
507 prints(help_line[help_ptr]);
\r
510 while (!(help_ptr == 0));
\r
513 help4("Sorry, I already gave what help I could...",
\r
514 "Maybe you should try asking a human?",
\r
515 "An error might have occurred before I noticed any problems.",
\r
516 "``If all else fails, read the instructions.''");
\r
523 begin_file_reading();
\r
525 if (last > first + 1)
\r
528 buffer[first] = 32;
\r
532 prompt_input("insert>");
\r
548 interaction = 0 + c - 'Q';
\r
549 prints("OK, entering ");
\r
554 print_esc("batchmode");
\r
559 print_esc("nonstopmode");
\r
563 print_esc("scrollmode");
\r
576 interaction = scroll_mode;
\r
586 prints("Type <return> to proceed, S to scroll future error messages,");
\r
587 print_nl("R to run without stopping, Q to run quietly,");
\r
588 print_nl("I to insert something, ");
\r
591 prints("E to edit your file,");
\r
593 if (deletions_allowed)
\r
594 print_nl("1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
\r
596 print_nl("H for help, X to quit.");
\r
602 if (error_count == 100)
\r
604 print_nl("(That makes 100 errors; please try again.)");
\r
605 history = fatal_error_stop;
\r
609 if (interaction > batch_mode)
\r
617 else while (help_ptr > 0)
\r
620 print_nl(help_line[help_ptr] == NULL ? "" : help_line[help_ptr]);
\r
625 if (interaction > batch_mode)
\r
631 void fatal_error (const char * s)
\r
633 normalize_selector();
\r
634 print_err("Emergency stop");
\r
639 void overflow_(const char * s, integer n)
\r
641 normalize_selector();
\r
642 print_err("TeX capacity exceeded, sorry [");
\r
647 help2("If you really absolutely need more capacity,",
\r
648 "you can ask a wizard to enlarge me.");
\r
652 if (!strcmp(s, "pattern memory") && (n == trie_size))
\r
653 printf("\n (Maybe use -h=... on command line in initex)\n");
\r
654 else if (!strcmp(s, "exception dictionary") && (n == hyphen_prime))
\r
655 printf("\n (Maybe use -e=... on command line in initex)\n");
\r
661 void confusion (const char * s)
\r
663 normalize_selector();
\r
665 if (history < error_message_issued)
\r
667 print_err("This can't happen (");
\r
670 help1("I'm broken. Please show this to someone who can fix can fix");
\r
674 print_err("I can't go on meeting you like this");
\r
675 help2("One of your faux pas seems to have wounded me deeply...",
\r
676 "in fact, I'm barely conscious. Please fix it and try again.");
\r
682 boolean init_terminal (void)
\r
692 while ((loc < last) && (buffer[loc]== ' '))
\r
699 // failed to find input file name
\r
702 wake_up_terminal();
\r
703 fputs("**", stdout);
\r
705 flag = input_ln(stdin, true);
\r
710 puts("! End of file on the terminal... why?\n");
\r
716 while ((loc < last) && (buffer[loc]== ' '))
\r
717 incr(loc); // step over intial white space
\r
722 printf("%s\n", "Please type the name of your input file.");
\r
726 str_number make_string (void)
\r
728 #ifdef ALLOCATESTRING
\r
729 if (str_ptr == current_max_strings)
\r
730 str_start = realloc_str_start(increment_max_strings);
\r
732 if (str_ptr == current_max_strings)
\r
734 overflow("number of strings", current_max_strings - init_str_ptr);
\r
738 if (str_ptr == max_strings)
\r
740 overflow("number of strings", max_strings - init_str_ptr);
\r
746 str_start[str_ptr] = pool_ptr;
\r
748 return (str_ptr - 1);
\r
751 boolean str_eq_buf_ (str_number s, integer k)
\r
758 while (j < str_start[s + 1])
\r
760 if (str_pool[j] != buffer[k])
\r
776 boolean str_eq_str_ (str_number s, str_number t)
\r
783 if (length(s) != length(t))
\r
789 while (j < str_start[s + 1])
\r
791 if (str_pool[j] != str_pool[k])
\r
804 void print_two_(integer n)
\r
807 print_char('0' + (n / 10));
\r
808 print_char('0' + (n % 10));
\r
811 void print_hex_(integer n)
\r
820 dig[k] = (unsigned char) (n % 16);
\r
829 void print_roman_int_(integer n)
\r
832 nonnegative_integer u, v;
\r
834 j = str_start[260]; /* m2d5c2l5x2v5i */
\r
841 print_char(str_pool[j]);
\r
849 u = v / (str_pool[k - 1] - '0');
\r
851 if (str_pool[k - 1] == 50)
\r
854 u = u / (str_pool[k - 1] - '0');
\r
859 print_char(str_pool[k]);
\r
865 v = v / (str_pool[j - 1] - '0');
\r
870 void print_current_string (void)
\r
874 j = str_start[str_ptr];
\r
876 while (j < pool_ptr)
\r
878 print_char(str_pool[j]);
\r
884 void term_input (void)
\r
890 show_line("\n", 0);
\r
893 flag = input_ln(stdin, true);
\r
897 fatal_error("End of file on the terminal!");
\r
905 for (k = first; k <= last - 1; k++)
\r
912 void int_error_ (integer n)
\r
920 void normalize_selector (void)
\r
923 selector = term_and_log;
\r
925 selector = term_only;
\r
930 if (interaction == batch_mode)
\r
934 void pause_for_instructions (void)
\r
936 if (OK_to_interrupt)
\r
938 interaction = error_stop_mode;
\r
940 if ((selector == log_only) || (selector == no_print))
\r
943 print_err("Interruption");
\r
945 "Try to insert some instructions for me (e.g.,`I\\showlists'),",
\r
946 "unless you just want to quit by typing `X'.");
\r
947 deletions_allowed = false;
\r
949 deletions_allowed = true;
\r
954 integer half_(integer x)
\r
957 return ((x + 1) / 2);
\r
962 scaled round_decimals_(small_number k)
\r
971 a = (a + dig[k] * 131072L) / 10; /* 2^17 */
\r
974 return ((a + 1) / 2);
\r
977 void print_scaled_(scaled s)
\r
987 print_int(s / 65536L);
\r
989 s = 10 * (s % 65536L) + 5;
\r
994 if (delta > 65536L)
\r
995 s = s - 17232; /* 2^15 - 50000 - rounding */
\r
997 print_char('0' + (s / 65536L));
\r
998 s = 10 * (s % 65536L);
\r
999 delta = delta * 10;
\r
1001 while (!(s <= delta));
\r
1004 scaled mult_and_add_(integer n, scaled x, scaled y, scaled max_answer)
\r
1008 x = - (integer) x;
\r
1009 n = - (integer) n;
\r
1014 else if (((x <= (max_answer - y) / n) && (- (integer) x <= (max_answer + y) / n)))
\r
1015 return (n * x + y);
\r
1018 arith_error = true;
\r
1023 scaled x_over_n_(scaled x, integer n)
\r
1025 register scaled Result;
\r
1032 arith_error = true;
\r
1034 tex_remainder = x;
\r
1040 x = - (integer) x;
\r
1041 n = - (integer) n;
\r
1048 tex_remainder = x % n;
\r
1052 Result = - (integer) ((- (integer) x)/ n);
\r
1053 tex_remainder = - (integer) ((- (integer) x)% n);
\r
1058 tex_remainder = - (integer) tex_remainder;
\r
1063 scaled xn_over_d_(scaled x, integer n, integer d)
\r
1065 register scaled Result;
\r
1067 nonnegative_integer t, u, v;
\r
1073 x = - (integer) x;
\r
1077 t = (x % 32767L) * n;
\r
1078 u = (x / 32768L) * n + (t / 32768L);
\r
1079 v = (u % d) * 32768L + (t % 32768L);
\r
1081 if (u / d >= 32768L)
\r
1082 arith_error = true;
\r
1084 u = 32768L * (u / d) + (v / d);
\r
1089 tex_remainder = v % d;
\r
1093 Result = - (integer) u;
\r
1094 tex_remainder = - (integer)(v % d);
\r
1100 halfword badness_(scaled t, scaled s)
\r
1110 if (t <= 7230584L)
\r
1111 r = (t * 297) / s;
\r
1112 else if (s >= 1663497L)
\r
1113 r = t / (s / 297);
\r
1120 return (r * r * r + 131072L) / 262144L; /* 2^17 */
\r
1125 void print_word (memory_word w)
\r
1127 print_int(w.cint);
\r
1129 print_scaled(w.cint);
\r
1131 print_scaled(round(unity * w.gr));
\r
1133 print_int(w.hh.lh);
\r
1135 print_int(w.hh.b0);
\r
1137 print_int(w.hh.b1);
\r
1139 print_int(w.hh.rh);
\r
1141 print_int(w.qqqq.b0);
\r
1143 print_int(w.qqqq.b1);
\r
1145 print_int(w.qqqq.b2);
\r
1147 print_int(w.qqqq.b3);
\r
1151 void show_token_list_(integer p, integer q, integer l)
\r
1154 ASCII_code match_chr;
\r
1161 while ((p != 0) && (tally < l))
\r
1165 first_count = tally;
\r
1166 trick_count = tally + 1 + error_line - half_error_line;
\r
1168 if (trick_count < error_line)
\r
1169 trick_count = error_line;
\r
1172 if ((p < hi_mem_min) || (p > mem_end))
\r
1174 print_esc("CLOBBERED.");
\r
1178 if (info(p) >= cs_token_flag)
\r
1179 print_cs(info(p) - cs_token_flag);
\r
1182 m = info(p) / 256;
\r
1183 c = info(p) % 256;
\r
1186 print_esc("BAD.");
\r
1210 print_char(c + '0');
\r
1219 match_chr = (ASCII_code) c;
\r
1233 print_esc("BAD.");
\r
1241 print_esc("ETC.");
\r
1244 void runaway (void)
\r
1248 if (scanner_status > 1)
\r
1250 print_nl("Runaway ");
\r
1252 switch (scanner_status)
\r
1255 prints("definition");
\r
1260 prints("argument");
\r
1265 prints("preamble");
\r
1277 show_token_list(link(p), 0, error_line - 10);
\r
1281 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
\r
1282 /* first try list of available nodes (avail != NULL) */
\r
1283 /* then see if can go upwards (mem_end < mem_max) */
\r
1284 /* then see if can go downwards (hi_mem_min > lo_mem_max) */
\r
1285 /* if not, extend memory at the top and grab from there --- new */
\r
1286 /* else fail ! paragraph 120 */
\r
1287 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
\r
1288 pointer get_avail (void)
\r
1295 avail = link(avail);
\r
1296 else if (mem_end < mem_max)
\r
1306 if (hi_mem_min <= lo_mem_max) /* have we run out in middle ? */
\r
1309 mem = realloc_main (0, mem_top / 2); /* zzzaa = zmem = mem */
\r
1314 if (mem_end >= mem_max)
\r
1317 overflow("main memory size", mem_max + 1 - mem_min);
\r
1321 incr(mem_end); /* then grab from new area */
\r
1322 p = mem_end; /* 1993/Dec/14 */
\r
1326 link(p) = 0; /* link(p) = null !!! */
\r
1335 void flush_list_(pointer p)
\r
1351 while (!(r == 0));
\r
1358 pointer get_node (integer s)
\r
1370 q = p + node_size(p);
\r
1372 while (is_empty(q))
\r
1379 llink(t) = llink(q);
\r
1380 rlink(llink(q)) = t;
\r
1381 q = q + node_size(q);
\r
1386 if (r > toint(p + 1))
\r
1388 node_size(p) = r - p;
\r
1394 if (rlink(p) != p)
\r
1403 node_size(p) = q - p;
\r
1406 while (!(p == rover));
\r
1408 if (s == 1073741824L) /* 2^30 - special case - merge adjacent */
\r
1411 puts("Merged adjacent multi-word nodes");
\r
1413 return max_halfword;
\r
1416 /* maybe try downward epxansion first instead ? */
\r
1417 if (lo_mem_max + 2 < hi_mem_min)
\r
1418 if (lo_mem_max + 2 <= mem_bot + max_halfword) /* silly ? flush 93/Dec/16 */
\r
1420 if (hi_mem_min - lo_mem_max >= (block_size + block_size - 2))
\r
1421 t = lo_mem_max + block_size;
\r
1423 t = lo_mem_max + 1 + (hi_mem_min - lo_mem_max) / 2;
\r
1430 if (t > mem_bot + max_halfword)
\r
1431 t = mem_bot + max_halfword; /* silly ? flush 93/Dec/16 */
\r
1435 link(q) = empty_flag;
\r
1436 node_size(q) = t - lo_mem_max; /* block size */
\r
1438 link(lo_mem_max) = 0;
\r
1439 info(lo_mem_max) = 0;
\r
1444 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
\r
1445 /* we've run out of space in the middle for variable length blocks */
\r
1446 /* try and add new block from below mem_bot *//* first check if space ! */
\r
1447 if (mem_min - (block_size + 1) <= mem_start) /* extend lower memory downwards */
\r
1449 mem = realloc_main (mem_top / 2 + block_size, 0); /* zzzaa = zmem = mem */
\r
1457 if (mem_min - (block_size + 1) <= mem_start) /* check again */
\r
1460 printf("mem_min %lld, mem_start %d, block_size %d\n", mem_min, mem_start, block_size);
\r
1462 overflow("main memory size", mem_max + 1 - mem_min); /* darn: allocation failed ! */
\r
1466 add_variable_space(block_size);
\r
1467 goto restart; /* go try get_node again */
\r
1473 var_used = var_used + s;
\r
1479 void free_node (pointer p, halfword s)
\r
1484 link(p) = empty_flag;
\r
1492 var_used = var_used - s;
\r
1496 pointer new_null_box (void)
\r
1500 p = get_node(box_node_size);
\r
1501 type(p) = hlist_node;
\r
1502 subtype(p) = min_quarterword;
\r
1506 shift_amount(p) = 0;
\r
1508 glue_sign(p) = normal;
\r
1509 glue_order(p) = normal;
\r
1510 glue_set(p) = 0.0;
\r
1515 pointer new_rule (void)
\r
1519 p = get_node(rule_node_size);
\r
1520 type(p) = rule_node;
\r
1522 width(p) = null_flag;
\r
1523 depth(p) = null_flag;
\r
1524 height(p) = null_flag;
\r
1529 pointer new_ligature_(quarterword f, quarterword c, pointer q)
\r
1533 p = get_node(small_node_size);
\r
1534 type(p) = ligature_node;
\r
1535 font(lig_char(p)) = f;
\r
1536 character(lig_char(p)) = c;
\r
1543 pointer new_lig_item_(quarterword c)
\r
1547 p = get_node(small_node_size);
\r
1554 pointer new_disc (void)
\r
1558 p = get_node(small_node_size);
\r
1559 type(p) = disc_node;
\r
1560 replace_count(p) = 0;
\r
1562 post_break(p) = 0;
\r
1567 pointer new_math (scaled w, small_number s)
\r
1571 p = get_node(small_node_size);
\r
1572 type(p) = math_node;
\r
1579 pointer new_spec_(pointer p)
\r
1583 q = get_node(glue_spec_size);
\r
1585 glue_ref_count(q) = 0;
\r
1586 width(q) = width(p);
\r
1587 stretch(q) = stretch(p);
\r
1588 shrink(q) = shrink(p);
\r
1593 pointer new_param_glue (small_number n)
\r
1598 p = get_node(small_node_size);
\r
1599 type(p) = glue_node;
\r
1600 subtype(p) = n + 1;
\r
1601 leader_ptr(p) = 0;
\r
1604 incr(glue_ref_count(q));
\r
1609 pointer new_glue (pointer q)
\r
1613 p = get_node(small_node_size);
\r
1614 type(p) = glue_node;
\r
1615 subtype(p) = normal;
\r
1616 leader_ptr(p) = 0;
\r
1618 incr(glue_ref_count(q));
\r
1623 pointer new_skip_param (small_number n)
\r
1627 temp_ptr = new_spec(glue_par(n));
\r
1628 p = new_glue(temp_ptr);
\r
1629 glue_ref_count(temp_ptr) = 0;
\r
1630 subtype(p) = n + 1;
\r
1635 pointer new_kern(scaled w)
\r
1639 p = get_node(small_node_size);
\r
1640 type(p) = kern_node;
\r
1641 subtype(p) = normal;
\r
1647 pointer new_penalty(integer m)
\r
1651 p = get_node(small_node_size);
\r
1652 type(p) = penalty_node;
\r
1661 void check_mem (boolean print_locs)
\r
1664 boolean clobbered;
\r
1666 for (p = mem_min; p <= lo_mem_max; p++)
\r
1667 freearr[p] = false;
\r
1669 for (p = hi_mem_min; p <= mem_end; p++)
\r
1670 freearr[p] = false;
\r
1674 clobbered = false;
\r
1678 if ((p > mem_end) || (p < hi_mem_min))
\r
1680 else if (freearr[p])
\r
1685 print_nl("AVAIL list clobbered at ");
\r
1690 freearr[p] = true;
\r
1698 clobbered = false;
\r
1702 if ((p >= lo_mem_max) || (p < mem_min))
\r
1704 else if ((rlink(p) >= lo_mem_max) || (rlink(p) < mem_min))
\r
1706 else if (!(is_empty(p)) || (node_size(p) < 2) ||
\r
1707 (p + node_size(p) > lo_mem_max) || (llink(rlink(p)) != p))
\r
1712 print_nl("Double-AVAIL list clobbered at ");
\r
1717 for (q = p; q <= p + node_size(p) - 1; q++)
\r
1721 print_nl("Doubly free location at ");
\r
1726 freearr[q] = true;
\r
1732 while (!(p == rover));
\r
1737 while (p <= lo_mem_max)
\r
1741 print_nl("Bad flag at ");
\r
1745 while ((p <= lo_mem_max) && !freearr[p])
\r
1748 while ((p <= lo_mem_max) && freearr[p])
\r
1754 print_nl("New busy locs:");
\r
1756 for (p = mem_min; p <= lo_mem_max; p++)
\r
1757 if (!freearr[p] && ((p > was_lo_max) || wasfree[p]))
\r
1763 for (p = hi_mem_min; p <= mem_end; p++)
\r
1764 if (!freearr[p] && ((p < was_hi_min) || (p > was_mem_end) || wasfree[p]))
\r
1771 for (p = mem_min; p <= lo_mem_max; p++)
\r
1772 wasfree[p] = freearr[p];
\r
1774 for (p = hi_mem_min; p <= mem_end; p++)
\r
1775 wasfree[p] = freearr[p];
\r
1777 was_mem_end = mem_end;
\r
1778 was_lo_max = lo_mem_max;
\r
1779 was_hi_min = hi_mem_min;
\r
1781 #endif /* DEBUG */
\r
1785 void search_mem_(pointer p)
\r
1789 for (q = mem_min; q <= lo_mem_max; q++)
\r
1793 print_nl("LINK(");
\r
1800 print_nl("INFO(");
\r
1806 for (q = hi_mem_min; q <= mem_end; q++)
\r
1810 print_nl("LINK(");
\r
1817 print_nl("INFO(");
\r
1823 for (q = active_base; q <= box_base + 255; q++)
\r
1824 if (equiv(q) == p)
\r
1826 print_nl("EQUIV(");
\r
1832 for (q = 0; q <= save_ptr - 1; q++)
\r
1834 if (equiv_field(save_stack[q]) == p)
\r
1836 print_nl("SAVE(");
\r
1842 for (q = 0; q <= hyphen_prime; q++)
\r
1843 if (hyph_list[q] == p)
\r
1845 print_nl("HYPH(");
\r
1852 void short_display_(integer p)
\r
1856 while (p != 0) /* want p != null here ! */
\r
1858 if (is_char_node(p))
\r
1862 if (font(p) != font_in_short_display)
\r
1864 if ((font(p) > font_max))
\r
1869 print(font_id_text(font(p)));
\r
1873 font_in_short_display = font(p);
\r
1876 print(character(p));
\r
1879 else switch (type(p))
\r
1884 case whatsit_node:
\r
1896 if (glue_ptr(p) != 0)
\r
1904 case ligature_node:
\r
1905 short_display(lig_ptr(p));
\r
1909 short_display(pre_break(p));
\r
1910 short_display(post_break(p));
\r
1911 n = replace_count(p);
\r
1930 void print_font_and_char (integer p)
\r
1933 print_esc("CLOBBERED.");
\r
1936 if ((font(p) > font_max))
\r
1941 print(font_id_text(font(p)));
\r
1945 print(character(p));
\r
1949 void print_mark (integer p)
\r
1953 if ((p < hi_mem_min) || (p > mem_end))
\r
1954 print_esc("CLOBBERED.");
\r
1956 show_token_list(link(p), 0, max_print_line - 10);
\r
1961 void print_rule_dimen(scaled d)
\r
1963 if (is_running(d))
\r
1969 void print_glue_(scaled d, integer order, const char * s)
\r
1973 if ((order < normal) || (order > filll))
\r
1975 else if (order > 0)
\r
1985 else if (*s != '\0')
\r
1989 void print_spec_(integer p, const char * s)
\r
1991 if ((p < mem_min) || (p >= lo_mem_max))
\r
1995 print_scaled(width(p));
\r
2000 if (stretch(p) != 0)
\r
2003 print_glue(stretch(p), stretch_order(p), s);
\r
2006 if (shrink(p) != 0)
\r
2009 print_glue(shrink(p), shrink_order(p), s);
\r
2014 void print_fam_and_char_(pointer p)
\r
2017 print_int(fam(p));
\r
2019 print(character(p));
\r
2022 void print_delimiter_(pointer p)
\r
2026 a = small_fam(p) * 256 + small_char(p);
\r
2027 a = a * 0x1000 + large_fam(p) * 256 + large_char(p);
\r
2035 void print_subsidiary_data_(pointer p, ASCII_code c)
\r
2037 if ((pool_ptr - str_start[str_ptr]) >= depth_threshold)
\r
2039 if (math_type(p) != 0)
\r
2047 switch (math_type(p))
\r
2051 print_current_string();
\r
2052 print_fam_and_char(p);
\r
2063 print_current_string();
\r
2078 void print_style_(integer c)
\r
2083 print_esc("displaystyle");
\r
2086 print_esc("textstyle");
\r
2089 print_esc("scriptstyle");
\r
2092 print_esc("scriptscriptstyle");
\r
2095 prints("Unknown style!");
\r
2100 void print_skip_param_(integer n)
\r
2104 case line_skip_code:
\r
2105 print_esc("lineskip");
\r
2108 case baseline_skip_code:
\r
2109 print_esc("baselineskip");
\r
2112 case par_skip_code:
\r
2113 print_esc("parskip");
\r
2116 case above_display_skip_code:
\r
2117 print_esc("abovedisplayskip");
\r
2120 case below_display_skip_code:
\r
2121 print_esc("belowdisplayskip");
\r
2124 case above_display_short_skip_code:
\r
2125 print_esc("abovedisplayshortskip");
\r
2128 case below_display_short_skip_code:
\r
2129 print_esc("belowdisplayshortskip");
\r
2132 case left_skip_code:
\r
2133 print_esc("leftskip");
\r
2136 case right_skip_code:
\r
2137 print_esc("rightskip");
\r
2140 case top_skip_code:
\r
2141 print_esc("topskip");
\r
2144 case split_top_skip_code:
\r
2145 print_esc("splittopskip");
\r
2148 case tab_skip_code:
\r
2149 print_esc("tabskip");
\r
2152 case space_skip_code:
\r
2153 print_esc("spaceskip");
\r
2156 case xspace_skip_code:
\r
2157 print_esc("xspaceskip");
\r
2160 case par_fill_skip_code:
\r
2161 print_esc("parfillskip");
\r
2164 case thin_mu_skip_code:
\r
2165 print_esc("thinmuskip");
\r
2168 case med_mu_skip_code:
\r
2169 print_esc("medmuskip");
\r
2172 case thick_mu_skip_code:
\r
2173 print_esc("thickmuskip");
\r
2177 prints("[unknown glue parameter!]");
\r
2182 void show_node_list_(integer p)
\r
2187 if (cur_length > depth_threshold)
\r
2189 if (p != 0) /* fixed 94/Mar/23 BUG FIX NOTE: still not fixed in 3.14159 ! */
\r
2200 print_current_string();
\r
2204 prints("Bad link, display aborted.");
\r
2210 if (n > breadth_max)
\r
2216 if (is_char_node(p))
\r
2217 print_font_and_char(p);
\r
2218 else switch (type(p))
\r
2224 if (type(p) == hlist_node)
\r
2226 else if (type(p) == vlist_node)
\r
2229 print_esc("unset");
\r
2232 print_scaled(height(p));
\r
2234 print_scaled(depth(p));
\r
2236 print_scaled(width(p));
\r
2238 if (type(p) == unset_node)
\r
2240 if (span_count(p) != 0)
\r
2243 print_int(span_count(p) + 1);
\r
2244 prints(" columns)");
\r
2247 if (glue_stretch(p) != 0)
\r
2249 prints(", stretch ");
\r
2250 print_glue(glue_stretch(p), glue_order(p), "");
\r
2253 if (glue_shrink(p) != 0)
\r
2255 prints(", shrink ");
\r
2256 print_glue(glue_shrink(p), glue_sign(p), "");
\r
2263 if ((g != 0.0) && (glue_sign(p) != 0))
\r
2265 prints(", glue set ");
\r
2267 if (glue_sign(p) == shrinking)
\r
2270 if (fabs(g) > 20000.0)
\r
2277 print_glue(20000 * unity, glue_order(p), "");
\r
2280 print_glue(round(unity * g), glue_order(p), "");
\r
2283 if (shift_amount(p) != 0)
\r
2285 prints(", shifted ");
\r
2286 print_scaled(shift_amount(p));
\r
2290 node_list_display(list_ptr(p));
\r
2296 print_esc("rule(");
\r
2297 print_rule_dimen(height(p));
\r
2299 print_rule_dimen(depth(p));
\r
2301 print_rule_dimen(width(p));
\r
2307 print_esc("insert");
\r
2308 print_int(subtype(p));
\r
2309 prints(", natural size ");
\r
2310 print_scaled(height(p));
\r
2311 prints("; split(");
\r
2312 print_spec(split_top_ptr(p), "");
\r
2314 print_scaled(depth(p));
\r
2315 prints("); float cost ");
\r
2316 print_int(float_cost(p));
\r
2317 node_list_display(ins_ptr(p));
\r
2321 case whatsit_node:
\r
2322 switch (subtype(p))
\r
2326 print_write_whatsit("openout", p);
\r
2328 print_file_name(open_name(p), open_area(p), open_ext(p));
\r
2334 print_write_whatsit("write", p);
\r
2335 print_mark(write_tokens(p));
\r
2340 print_write_whatsit("closeout", p);
\r
2343 case special_node:
\r
2345 print_esc("special");
\r
2346 print_mark(write_tokens(p));
\r
2350 case language_node:
\r
2352 print_esc("setlanguage");
\r
2353 print_int(what_lang(p));
\r
2354 prints(" (hyphenmin ");
\r
2355 print_int(what_lhm(p));
\r
2357 print_int(what_rhm(p));
\r
2363 prints("whatsit?");
\r
2369 if (subtype(p) >= a_leaders)
\r
2373 if (subtype(p) == c_leaders)
\r
2375 else if (subtype(p) == x_leaders)
\r
2378 prints("leaders ");
\r
2379 print_spec(glue_ptr(p), "");
\r
2380 node_list_display(leader_ptr(p));
\r
2384 print_esc("glue");
\r
2386 if (subtype(p) != normal)
\r
2390 if (subtype(p) < cond_math_glue)
\r
2391 print_skip_param(subtype(p) - 1);
\r
2392 else if (subtype(p) == cond_math_glue)
\r
2393 print_esc("nonscript");
\r
2394 else print_esc("mskip");
\r
2399 if (subtype(p) != cond_math_glue)
\r
2403 if (subtype(p) < cond_math_glue)
\r
2404 print_spec(glue_ptr(p), "");
\r
2406 print_spec(glue_ptr(p), "mu");
\r
2412 if (subtype(p) != mu_glue)
\r
2414 print_esc("kern");
\r
2416 if (subtype(p) != normal)
\r
2419 print_scaled(width(p));
\r
2421 if (subtype(p) == acc_kern)
\r
2422 prints(" (for accent)");
\r
2426 print_esc("mkern");
\r
2427 print_scaled(width(p));
\r
2434 print_esc("math");
\r
2436 if (subtype(p) == before)
\r
2441 if (width(p) != 0)
\r
2443 prints(", surrounded ");
\r
2444 print_scaled(width(p));
\r
2449 case ligature_node:
\r
2451 print_font_and_char(lig_char(p));
\r
2452 prints("(ligature ");
\r
2454 if (subtype(p) > 1)
\r
2457 font_in_short_display = font(lig_char(p));
\r
2458 short_display(lig_ptr(p));
\r
2460 if (odd(subtype(p)))
\r
2467 case penalty_node:
\r
2469 print_esc("penalty ");
\r
2470 print_int(penalty(p));
\r
2476 print_esc("discretionary");
\r
2478 if (replace_count(p) > 0)
\r
2480 prints(" replacing ");
\r
2481 print_int(replace_count(p));
\r
2484 node_list_display(pre_break(p));
\r
2486 show_node_list(post_break(p));
\r
2493 print_esc("mark");
\r
2494 print_mark(mark_ptr(p));
\r
2500 print_esc("vadjust");
\r
2501 node_list_display(adjust_ptr(p));
\r
2506 print_style(subtype(p));
\r
2511 print_esc("mathchoice");
\r
2513 show_node_list(display_mlist(p));
\r
2516 show_node_list(text_mlist(p));
\r
2519 show_node_list(script_mlist(p));
\r
2522 show_node_list(script_script_mlist(p));
\r
2535 case radical_noad:
\r
2538 case vcenter_noad:
\r
2546 print_esc("mathord");
\r
2550 print_esc("mathop");
\r
2554 print_esc("mathbin");
\r
2558 print_esc("mathrel");
\r
2562 print_esc("mathopen");
\r
2566 print_esc("mathclose");
\r
2570 print_esc("mathpunct");
\r
2574 print_esc("mathinner");
\r
2578 print_esc("overline");
\r
2582 print_esc("underline");
\r
2585 case vcenter_noad:
\r
2586 print_esc("vcenter");
\r
2589 case radical_noad:
\r
2591 print_esc("radical");
\r
2592 print_delimiter(left_delimiter(p));
\r
2598 print_esc("accent");
\r
2599 print_fam_and_char(accent_chr(p));
\r
2605 print_esc("left");
\r
2606 print_delimiter(delimiter(p));
\r
2612 print_esc("right");
\r
2613 print_delimiter(delimiter(p));
\r
2618 if (subtype(p) != normal)
\r
2619 if (subtype(p) == limits)
\r
2620 print_esc("limits");
\r
2622 print_esc("nolimits");
\r
2624 if (type(p) < left_noad)
\r
2625 print_subsidiary_data(nucleus(p), '.');
\r
2627 print_subsidiary_data(supscr(p), '^');
\r
2628 print_subsidiary_data(subscr(p), '_');
\r
2632 case fraction_noad:
\r
2634 print_esc("fraction, thickness ");
\r
2636 if (thickness(p) == 1073741824L) /* 2^30 */
\r
2637 prints("= default");
\r
2639 print_scaled(thickness(p));
\r
2641 if ((small_fam(left_delimiter(p)) != 0) || (small_char(left_delimiter(p)) != 0) ||
\r
2642 (large_fam(left_delimiter(p)) != 0) || (large_char(left_delimiter(p)) != 0))
\r
2644 prints(", left-delimiter ");
\r
2645 print_delimiter(left_delimiter(p));
\r
2648 if ((small_fam(right_delimiter(p)) != 0) || (small_char(right_delimiter(p)) != 0) ||
\r
2649 (large_fam(right_delimiter(p)) != 0) || (large_char(right_delimiter(p)) != 0))
\r
2651 prints(", right-delimiter ");
\r
2652 print_delimiter(right_delimiter(p));
\r
2655 print_subsidiary_data(numerator(p), '\\');
\r
2656 print_subsidiary_data(denominator(p), '/');
\r
2661 prints("Unknown node type!");
\r