2 #pragma warning(disable:4996)
3 #pragma warning(disable:4131) // old style declarator
4 #pragma warning(disable:4135) // conversion between different integral types
5 #pragma warning(disable:4127) // conditional expression is constant
11 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
16 movement(cur_h - dvi_h, right1);
24 movement(cur_v - dvi_v, down1);
28 void set_cur_lang(void)
32 else if (language > 255)
37 INLINE void free_avail_(halfword p)
45 INLINE void dvi_out_(ASCII_code op)
47 dvi_buf[dvi_ptr] = op;
49 if (dvi_ptr == dvi_limit)
52 INLINE void succumb (void)
54 if (interaction == error_stop_mode)
55 interaction = scroll_mode;
68 INLINE void flush_string (void)
71 pool_ptr = str_start[str_ptr];
73 INLINE void append_char (ASCII_code c)
75 str_pool[pool_ptr] = c;
78 INLINE void append_lc_hex (ASCII_code c)
83 append_char(c - 10 + 'a');
85 INLINE void print_err (const char * s)
87 if (interaction == error_stop_mode);
91 INLINE void tex_help (unsigned int n, ...)
100 va_start(help_arg, n);
102 for (i = n - 1; i > -1; --i)
103 help_line[i] = va_arg(help_arg, char *);
107 INLINE void str_room_ (int val)
109 #ifdef ALLOCATESTRING
110 if (pool_ptr + val > current_pool_size)
111 str_pool = realloc_str_pool(increment_pool_size);
113 if (pool_ptr + val > current_pool_size)
115 overflow("pool size", current_pool_size - init_pool_ptr);
118 if (pool_ptr + val > pool_size)
120 overflow("pool size", pool_size - init_pool_ptr);
124 INLINE void tail_append_ (pointer val)
129 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
131 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
140 (void) putc ('\n', log_file);
145 (void) putc ('\n', log_file);
160 (void) putc ('\n', write_file[selector]);
165 void print_char_ (ASCII_code s)
167 if (s == new_line_char)
169 if (selector < pseudo)
179 (void) show_char(Xchr(s));
181 (void) putc(Xchr(s), log_file);
184 if (term_offset == max_print_line)
190 if (file_offset == max_print_line)
192 (void) putc ('\n', log_file);
199 (void) putc(Xchr(s), log_file);
202 if (file_offset == max_print_line)
208 (void) show_char(Xchr(s));
211 if (term_offset == max_print_line)
220 if (tally < trick_count)
221 trick_buf[tally % error_line] = s;
226 #ifdef ALLOCATESTRING
227 if (pool_ptr + 1 > current_pool_size)
229 str_pool = realloc_str_pool (increment_pool_size);
232 if (pool_ptr < current_pool_size)
234 str_pool[pool_ptr]= s;
238 if (pool_ptr < pool_size)
240 str_pool[pool_ptr]= s;
247 (void) putc(Xchr(s), write_file[selector]);
254 void print_ (integer s)
269 if (selector > pseudo)
275 if ((s == new_line_char))
276 if (selector < pseudo)
284 /* translate ansi to dos 850 */
285 if (!show_in_hex && s < 256 && s >= 32)
287 if (show_in_dos && s > 127)
289 if (wintodos[s - 128] > 0)
291 print_char (wintodos[s - 128]);
297 while (j < str_start[s + 1])
299 print_char(str_pool[j]);
306 print_char(s); /* don't translate to hex */
310 { /* not just a character */
313 while (j < str_start[s + 1])
315 print_char(str_pool[j]);
319 new_line_char = nl; /* restore eol */
324 /* we get here with s > 256 - i.e. not a single character */
327 while (j < str_start[s + 1])
329 print_char(str_pool[j]);
333 /* string version print. */
334 void print_string_ (unsigned char *s)
340 // print string number s from string pool by calling print_
341 void slow_print_ (integer s)
345 if ((s >= str_ptr) || (s < 256))
353 while (j < str_start[s + 1])
361 // print newline followed by string number s (unless at start of line)
362 void print_nl_ (const char * s)
364 if (((term_offset > 0) && (odd(selector))) ||
365 ((file_offset > 0) && (selector >= log_only)))
371 // print string number s preceded by escape character
372 void print_esc_ (const char * s)
385 void print_the_digs_ (eight_bits k)
392 print_char('0' + dig[k]);
394 print_char('A' + dig[k]);
398 void print_int_ (integer n)
430 dig[k] = (char) (n % 10);
439 void print_cs_ (integer p)
442 if (p >= single_base)
446 print_esc("endcsname");
451 print_esc(""); print(p - single_base);
453 if (cat_code(p - single_base) == letter)
456 else if (p < active_base)
457 print_esc("IMPOSSIBLE.");
458 else print(p - active_base);
459 else if (p >= undefined_control_sequence)
460 print_esc("IMPOSSIBLE.");
461 else if ((text(p) >= str_ptr))
462 print_esc("NONEXISTENT.");
465 print_esc(""); print(text(p));
470 void sprint_cs_(halfword p)
474 print(p - active_base);
475 else if (p < null_cs)
477 print_esc(""); print(p - single_base);
482 print_esc("endcsname");
486 print_esc(""); print(text(p));
490 /* ! I can't find file ` c:/foo/ accents .tex '. */
491 void print_file_name_(integer n, integer a, integer e)
498 void print_size_ (integer s)
501 print_esc("textfont");
503 print_esc("scriptfont");
505 print_esc("scriptscriptfont");
508 void print_write_whatsit_(str_number s, halfword p)
510 print_esc(""); print(s);
511 if (write_stream(p) < 16)
512 print_int(write_stream(p));
513 else if (write_stream(p) == 16)
515 else print_char('-');
518 // called from itex.c and tex0.c only NASTY NASTY!
519 // now uses uses non-local goto (longjmp) 1999/Nov/7
522 close_files_and_terminate();
534 show_line("EXITING at JUMPOUT\n", 0);
536 if ((history != 0) && (history != 1))
545 // deal with error by asking for user response 0-9, D, E, H, I, X, Q, R, S
546 // NOTE: this may JUMPOUT either via X, or because of too many errors
550 integer s1, s2, s3, s4;
552 if (history < error_message_issued)
553 history = error_message_issued;
558 if (interaction == error_stop_mode)
562 clear_for_error_prompt();
566 term_input("? ", help_ptr);
572 c = buffer[first]; // analyze first letter typed
574 if (c >= 'a') // uppercase letter first
575 c = (unsigned char) (c + 'A' - 'a');
589 if (deletions_allowed)
595 align_state = 1000000L;
596 OK_to_interrupt = false;
598 if ((last > first + 1) && (buffer[first + 1] >= '0') && (buffer[first + 1] <= '9'))
599 c = (unsigned char) (c * 10 + buffer[first + 1] - '0' * 11);
601 c = (unsigned char) (c - 48);
613 OK_to_interrupt = true;
614 help2("I have just deleted some text, as you asked.",
615 "You can now delete more, or insert, or whatever.");
617 goto lab22; /* loop again */
625 goto lab22; /* loop again */
632 edit_name_start = str_start[input_stack[base_ptr].name_field];
633 edit_name_length = length(input_stack[base_ptr].name_field);
644 use_err_help = false;
649 help2("Sorry, I don't know how to help in this situation.",
650 "Maybe you should try asking a human?");
653 print_string(help_line[help_ptr]);
655 } while (!(help_ptr == 0));
658 help4("Sorry, I already gave what help I could...",
659 "Maybe you should try asking a human?",
660 "An error might have occurred before I noticed any problems.",
661 "``If all else fails, read the instructions.''");
662 goto lab22; /* loop again */
668 begin_file_reading();
670 if (last > first + 1)
672 cur_input.loc_field = first + 1;
678 print_string("insert>");
679 term_input("insert>", 0);
681 cur_input.loc_field = first;
684 cur_input.limit_field = last - 1;
694 interaction = 0 + c - 81; /* Q = 0, R = 1, S = 2, T = 3 */
695 print_string("OK, entering ");
700 print_esc("batchmode");
704 print_esc("nonstopmode");
707 print_esc("scrollmode");
729 } /* end of switch analysing response character */
732 print_string("Type <return> to proceed, S to scroll future error messages,");
733 print_nl("R to run without stopping, Q to run quietly,");
734 print_nl("I to insert something, ");
737 print_string("E to edit your file,");
739 if (deletions_allowed)
740 print_nl("1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
742 print_nl("H for help, X to quit.");
744 } /* end of while(true) loop */
748 if (error_count == 100)
750 print_nl("(That makes 100 errors; please try again.)");
755 if (interaction > batch_mode)
763 else while(help_ptr > 0)
766 print_nl(help_line[help_ptr] == NULL ? "" : help_line[help_ptr]);
771 if (interaction > batch_mode)
777 void fatal_error_(char * s)
779 normalize_selector();
780 print_err("Emergency stop");
785 void overflow_(char * s, integer n)
787 normalize_selector();
788 print_err("TeX capacity exceeded, sorry [");
793 help2("If you really absolutely need more capacity,",
794 "you can ask a wizard to enlarge me.");
798 if (!strcmp(s, "pattern memory") && n == trie_size)
800 sprintf(log_line, "\n (Maybe use -h=... on command line in ini-TeX)\n");
801 show_line(log_line, 0);
803 else if (!strcmp(s, "exception dictionary") && n == hyphen_prime)
805 sprintf(log_line, "\n (Maybe use -e=... on command line in ini-TeX)\n");
806 show_line(log_line, 0);
813 void confusion_(char * s)
815 normalize_selector();
817 if (history < error_message_issued)
819 print_err("This can't happen (");
822 help1("I'm broken. Please show this to someone who can fix can fix");
826 print_err("I can't go on meeting you like this");
827 help2("One of your faux pas seems to have wounded me deeply...",
828 "in fact, I'm barely conscious. Please fix it and try again.");
834 bool init_terminal (void)
842 cur_input.loc_field = first;
844 while((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' '))
845 incr(cur_input.loc_field); // step over initial white space
847 if (cur_input.loc_field < last)
851 // failed to find input file name
855 flag = ConsoleInput("**", "Please type a file name or a control sequence\r\n(or ^z to exit)", (char *) &buffer[first]);
856 last = first + strlen((char *) &buffer[first]); /* -1 ? */
857 // may need to be more elaborate see input_line in texmf.c
859 (void) fputs("**", stdout);
861 flag = input_ln(stdin, true);
867 show_line("! End of file on the terminal... why?\n", 1);
871 cur_input.loc_field = first;
873 while ((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' '))
874 incr(cur_input.loc_field); // step over intial white space
876 if (cur_input.loc_field < last)
879 sprintf(log_line, "%s\n", "Please type the name of your input file.");
880 show_line(log_line, 1);
884 // Make string from str_start[str_ptr] to pool_ptr
885 str_number make_string (void)
887 #ifdef ALLOCATESTRING
888 if (str_ptr == current_max_strings)
889 str_start = realloc_str_start(increment_max_strings);
891 if (str_ptr == current_max_strings)
893 overflow("number of strings", current_max_strings - init_str_ptr); /* 97/Mar/9 */
894 return 0; // abort_flag set
897 if (str_ptr == max_strings)
899 overflow("number of strings", max_strings - init_str_ptr);
900 return 0; // abort_flag set
904 str_start[str_ptr] = pool_ptr;
906 return (str_ptr - 1);
909 bool str_eq_buf_ (str_number s, integer k)
911 register bool Result;
917 while (j < str_start[s + 1])
919 if (str_pool[j] != buffer[k])
934 bool str_eq_str_ (str_number s, str_number t)
936 register bool Result;
942 if (length(s) != length(t))
948 while (j < str_start[s + 1])
950 if (str_pool[j] != str_pool[k])
962 void print_two_(integer n)
965 print_char('0' + (n / 10));
966 print_char('0' + (n % 10));
969 void print_hex_(integer n)
978 dig[k] = (unsigned char) (n % 16);
987 void print_roman_int_(integer n)
990 nonnegative_integer u, v;
992 j = str_start[260]; /* m2d5c2l5x2v5i */
999 print_char(str_pool[j]);
1007 u = v / (str_pool[k - 1] - '0');
1009 if (str_pool[k - 1] == 50)
1012 u = u / (str_pool[k - 1] - '0');
1017 print_char(str_pool[k]);
1023 v = v / (str_pool[j - 1] - '0');
1028 void print_current_string (void)
1032 j = str_start[str_ptr];
1034 while (j < pool_ptr)
1036 print_char(str_pool[j]);
1041 int stringlength (int str_ptr)
1043 return (str_start[str_ptr + 1] - str_start[str_ptr]) + 2;
1046 char * add_string (char *s, char * str_string)
1050 n = strlen(str_string);
1051 memcpy(s, &str_string, n);
1058 int addextrahelp = 1;
1060 // make one long \r\n separated string out of help lines
1061 // str_pool is packed_ASCII_code *
1063 char * make_up_help_string (int nhelplines)
1065 char * helpstring, *s;
1068 // get length of help for this specific message
1069 for (k = nhelplines - 1; k >= 0; k--)
1071 nlen += strlen(help_line[k]);
1074 nlen += 2; // for blank line separator: "\r\n"
1078 nlen += stringlength(265);
1079 nlen += stringlength(266);
1080 nlen += stringlength(267);
1083 nlen += stringlength(268);
1085 if (deletions_allowed)
1086 nlen += stringlength(269);
1088 nlen += stringlength(270);
1091 helpstring = (char *) malloc(nlen + 1); // +1 = '\0'
1094 for (k = nhelplines-1; k >= 0; k--)
1096 s = add_string(s, help_line[k]);
1103 s = add_string(s, "Type <return> to proceed, S to scroll future error messages,");
1104 s = add_string(s, "R to run without stopping, Q to run quietly,");
1105 s = add_string(s, "I to insert something, ");
1108 s = add_string(s, "E to edit your file, ");
1110 if (deletions_allowed)
1111 s = add_string(s, "1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
1113 s = add_string(s, "H for help, X to quit.");
1119 char * make_up_query_string (int promptstr)
1122 int nstart, nnext, n;
1125 nstart = str_start[ promptstr];
1126 nnext = str_start[ promptstr + 1];
1128 querystr = (char *) malloc(n + 1);
1130 memcpy(s, &str_pool[nstart], n);
1137 // abort_flag set if input_line / ConsoleInput returns non-zero
1138 // should set interrupt instead ???
1139 // called from tex0.c, tex2.c, tex3.c
1141 // void term_input(void)
1142 void term_input (char * term_str, int term_help_lines)
1146 char * helpstring = NULL;
1148 char * querystring = NULL;
1150 // if (nhelplines != 0) {
1151 // helpstring = make_up_help_string (nhelplines);
1152 // printf(helpstring);
1153 // free(helpstring);
1155 show_line("\n", 0); // force it to show what may be buffered up ???
1159 if (term_str != NULL)
1160 querystring = term_str;
1162 if (term_help_lines != NULL)
1163 helpstring = make_up_help_string(term_help_lines);
1165 if (helpstring == NULL && querystring != NULL)
1167 if (strcmp(querystring, ": ") == 0)
1168 helpstring = xstrdup("Please type another file name (or ^z to exit):");
1169 else if (strcmp(querystring, "=>") == 0) // from firm_up_the_line
1170 helpstring = xstrdup("Please type <enter> to accept this line\r\nor type a replacement line");
1171 else if (strcmp(querystring, "insert>") == 0) // from error() after "I"
1172 helpstring = xstrdup("Please type something to insert here");
1173 else if (strcmp(querystring, "") == 0) // from read_toks
1174 helpstring = xstrdup("Please type a control sequence");
1175 else if (strcmp(querystring, "= ") == 0) // from read_toks
1176 helpstring = xstrdup("Please type a token");
1177 else if (strcmp(querystring, "*") == 0) // get_next
1178 helpstring = xstrdup("Please type a control sequence\r\n(or ^z to exit)");
1181 flag = ConsoleInput(querystring, helpstring, (char *) &buffer[first]); // ???
1182 // flag == 0 means trouble --- EOF on terminal
1183 if (querystring != NULL)
1186 if (helpstring != NULL)
1189 helpstring = querystring = NULL;
1191 last = first + strlen((char *) &buffer[first]); /* -1 ? */
1192 // flag = (last > first);
1193 // may need to be more elaborate see input_line in texmf.c ???
1194 // sprintf(log_line, "first %d last %d flag %d - %s",
1195 // first, last, flag, (char *) &buffer[first]);
1196 // winerror(log_line);
1199 flag = input_ln(stdin, true);
1203 fatal_error("End of file on the terminal!");
1204 return; // abort_flag set
1208 // echo what was typed into Console buffer also
1210 for (k = first; k <= last - 1; k++)
1214 decr(selector); // shut off echo
1217 for (k = first; k <= last - 1; k++)
1221 incr(selector); // reset selector again
1225 void int_error_ (integer n)
1233 void normalize_selector (void)
1236 selector = term_and_log;
1238 selector = term_only;
1243 if (interaction == batch_mode)
1247 void pause_for_instructions (void)
1249 if (OK_to_interrupt)
1251 interaction = error_stop_mode;
1253 if ((selector == log_only) || (selector == no_print))
1256 print_err("Interruption");
1258 "Try to insert some instructions for me (e.g.,`I\\showlists'),",
1259 "unless you just want to quit by typing `X'.");
1260 deletions_allowed = false;
1262 deletions_allowed = true;
1267 integer half_(integer x)
1270 return ((x + 1) / 2);
1275 scaled round_decimals_(small_number k)
1284 a = (a + dig[k] * 131072L) / 10; /* 2^17 */
1287 return ((a + 1) / 2);
1290 /* This has some minor speedup changes - no real advantage probably ... */
1291 void print_scaled_(scaled s)
1301 print_int(s / 65536L);
1303 s = 10 * (s % 65536L) + 5;
1309 s = s - 17232; /* 2^15 - 50000 - rounding */
1310 print_char('0' + (s / 65536L));
1311 s = 10 * (s % 65536L);
1314 while (!(s <= delta));
1317 scaled mult_and_add_(integer n, scaled x, scaled y, scaled maxanswer)
1327 else if (((x <= (maxanswer - y) / n) && (- (integer) x <= (maxanswer + y) / n)))
1336 scaled x_over_n_(scaled x, integer n)
1338 register scaled Result;
1361 tex_remainder = x % n;
1365 Result = - (integer) ((- (integer) x)/ n);
1366 tex_remainder = - (integer) ((- (integer) x)% n);
1371 tex_remainder = - (integer) tex_remainder;
1376 scaled xn_over_d_(scaled x, integer n, integer d)
1378 register scaled Result;
1380 nonnegative_integer t, u, v;
1390 t =(x % 32767L) * n;
1391 u =(x / 32768L)* n +(t / 32768L);
1392 v =(u % d)* 32768L +(t % 32768L);
1394 if (u / d >= 32768L)
1397 u = 32768L * (u / d) + (v / d);
1402 tex_remainder = v % d;
1406 Result = - (integer) u;
1407 tex_remainder = - (integer)(v % d);
1413 halfword badness_(scaled t, scaled s)
1425 else if (s >= 1663497L)
1433 return (r * r * r + 131072L) / 262144L; /* 2^17 */
1438 void print_word_(memory_word w)
1442 print_scaled(w.cint);
1444 print_scaled(round(65536L * w.gr));
1446 print_int(w.hh.v.LH);
1452 print_int(w.hh.v.RH);
1454 print_int(w.qqqq.b0);
1456 print_int(w.qqqq.b1);
1458 print_int(w.qqqq.b2);
1460 print_int(w.qqqq.b3);
1462 /* need this version only if SHORTFONTINFO defined */
1463 void zprintfword(fmemoryword w)
1467 print_scaled(w.cint);
1469 print_scaled(round(65536L * w.gr));
1471 print_int(w.hh.v.LH);
1475 print_int(w .hh.b1);
1477 print_int(w.hh.v.RH);
1479 print_int(w.qqqq.b0);
1481 print_int(w.qqqq.b1);
1483 print_int(w.qqqq.b2);
1485 print_int(w.qqqq.b3);
1489 void show_token_list_(integer p, integer q, integer l)
1492 ASCII_code match_chr;
1499 while ((p != 0) && (tally < l))
1503 first_count = tally;
1504 trick_count = tally + 1 + error_line - half_error_line;
1506 if (trick_count < error_line)
1507 trick_count = error_line;
1510 if ((p < hi_mem_min) || (p > mem_end))
1512 print_esc("CLOBBERED.");
1516 if (info(p) >= cs_token_flag)
1517 print_cs(info(p) - cs_token_flag);
1549 print_char(c + '0');
1558 match_chr = (ASCII_code) c;
1587 if (scanner_status > 1)
1589 print_nl("Runaway ");
1591 switch (scanner_status)
1594 print_string("definition");
1599 print_string("argument");
1604 print_string("preamble");
1609 print_string("text");
1616 show_token_list(link(p), 0, error_line - 10);
1620 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1621 /* first try list of available nodes (avail != NULL) */
1622 /* then see if can go upwards (mem_end < mem_max) */
1623 /* then see if can go downwards (hi_mem_min > lo_mem_max) */
1624 /* if not, extend memory at the top and grab from there --- new */
1625 /* else fail ! paragraph 120 */
1626 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1627 halfword get_avail (void)
1634 avail = link(avail);
1635 else if (mem_end < mem_max)
1645 if (hi_mem_min <= lo_mem_max) /* have we run out in middle ? */
1648 mem = realloc_main (0, mem_top / 2); /* zzzaa = zmem = mem */
1653 if (mem_end >= mem_max)
1656 overflow("main memory size", mem_max + 1 - mem_min);
1657 return 0; // abort_flag set
1659 incr(mem_end); /* then grab from new area */
1660 p = mem_end; /* 1993/Dec/14 */
1664 link(p) = 0; /* link(p) = null !!! */
1673 void flush_list_(halfword p) /* paragraph 123 */
1677 if (p != 0) /* null !!! */
1689 while (!(r == 0)); /* r != null */
1696 halfword get_node_(integer s)
1698 register halfword Result;
1709 q = p + node_size(p);
1711 while ((mem[q].hh.v.RH == empty_flag))
1718 llink(t) = llink(q);
1719 rlink(llink(q)) = t;
1720 q = q + node_size(q);
1725 if (r > toint(p + 1))
1727 node_size(p) = r - p;
1742 node_size(p) = q - p;
1745 while (!(p == rover));
1747 if (s == 1073741824L) /* 2^30 - special case - merge adjacent */
1749 Result = max_halfword;
1752 show_line("Merged adjacent multi-word nodes\n", 0);
1757 /* maybe try downward epxansion first instead ? */
1758 if (lo_mem_max + 2 < hi_mem_min)
1759 if (lo_mem_max + 2 <= mem_bot + max_halfword) /* silly ? flush 93/Dec/16 */
1761 /* if (hi_mem_min - lo_mem_max >= 1998) */
1762 if (hi_mem_min - lo_mem_max >= (block_size + block_size - 2))
1763 /* t = lo_mem_max + 1000; */
1764 t = lo_mem_max + block_size;
1766 t = lo_mem_max + 1 + (hi_mem_min - lo_mem_max) / 2;
1773 if (t > mem_bot + max_halfword)
1774 t = mem_bot + max_halfword; /* silly ? flush 93/Dec/16 */
1778 link(q) = empty_flag;
1779 node_size(q) = t - lo_mem_max; /* block size */
1781 link(lo_mem_max) = 0;
1782 info(lo_mem_max) = 0;
1787 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1788 /* we've run out of space in the middle for variable length blocks */
1789 /* try and add new block from below mem_bot *//* first check if space ! */
1790 if (mem_min - (block_size + 1) <= mem_start) /* extend lower memory downwards */
1792 mem = realloc_main (mem_top/2 + block_size, 0); /* zzzaa = zmem = mem */
1800 if (mem_min - (block_size + 1) <= mem_start) /* check again */
1804 sprintf(log_line, "mem_min %d, mem_start %d, block_size %d\n", mem_min, mem_start, block_size);
1805 show_line(log_line, 0);
1808 overflow("main memory size", mem_max + 1 - mem_min); /* darn: allocation failed ! */
1809 return 0; // abort_flag set
1811 /* avoid function call in following ? */
1812 add_variable_space (block_size); /* now to be found in itex.c */
1813 goto lab20; /* go try get_node again */
1819 var_used = var_used + s;
1826 void free_node_(halfword p, halfword s)
1831 link(p) = empty_flag;
1838 var_used = var_used - s;
1842 halfword new_null_box (void)
1846 p = get_node(box_node_size);
1847 type(p) = hlist_node;
1848 subtype(p) = min_quarterword;
1852 shift_amount(p) = 0;
1854 glue_sign(p) = normal;
1855 glue_order(p) = normal;
1861 halfword new_rule (void)
1865 p = get_node(rule_node_size);
1866 type(p) = rule_node;
1868 width(p) = null_flag;
1869 depth(p) = null_flag;
1870 height(p) = null_flag;
1875 halfword new_ligature_(quarterword f, quarterword c, halfword q)
1879 p = get_node(small_node_size);
1880 type(p) = ligature_node;
1881 font(lig_char(p)) = f;
1882 character(lig_char(p)) = c;
1889 halfword new_lig_item_(quarterword c)
1893 p = get_node(small_node_size);
1900 halfword new_disc (void)
1904 p = get_node(small_node_size);
1905 type(p) = disc_node;
1906 replace_count(p) = 0;
1913 halfword new_math_(scaled w, small_number s)
1917 p = get_node(small_node_size);
1918 type(p) = math_node;
1925 halfword new_spec_(halfword p)
1929 q = get_node(glue_spec_size);
1931 glue_ref_count(q) = 0;
1932 width(q) = width(p);
1933 stretch(q) = stretch(p);
1934 shrink(q) = shrink(p);
1939 halfword new_param_glue_(small_number n)
1944 p = get_node(small_node_size);
1945 type(p) = glue_node;
1950 incr(glue_ref_count(q));
1955 halfword new_glue_(halfword q)
1959 p = get_node(small_node_size);
1960 type(p) = glue_node;
1961 subtype(p) = normal;
1964 incr(glue_ref_count(q));
1969 halfword new_skip_param_(small_number n)
1973 temp_ptr = new_spec(glue_par(n));
1974 p = new_glue(temp_ptr);
1975 glue_ref_count(temp_ptr) = 0;
1981 halfword new_kern_(scaled w)
1985 p = get_node(small_node_size);
1986 type(p) = kern_node;
1987 subtype(p) = normal;
1993 halfword new_penalty_(integer m)
1997 p = get_node(small_node_size);
1998 type(p) = penalty_node;
2007 void check_mem_(bool printlocs)
2012 for (p = mem_min; p <= lo_mem_max; p++) freearr[p] = false;
2013 for (p = hi_mem_min; p <= mem_end; p++) freearr[p] = false;
2018 if ((p > mem_end) || (p < hi_mem_min))
2020 else if (freearr[p])
2025 print_nl("AVAIL list clobbered at ");
2038 if ((p >= lo_mem_max) || (p < mem_min))
2040 else if ((rlink(p) >= lo_mem_max) || (rlink(p) < mem_min))
2042 else if (!(is_empty(p)) || (node_size(p) < 2) ||
2043 (p + node_size(p) > lo_mem_max) || (llink(rlink(p)) != p))
2048 print_nl("Double-AVAIL list clobbered at ");
2053 for (q = p; q <= p + node_size(p) - 1; q++)
2057 print_nl("Doubly free location at ");
2065 } while (!(p == rover));
2068 while (p <= lo_mem_max) {
2071 print_nl("Bad flag at ");
2074 while ((p <= lo_mem_max) && !freearr[p]) incr(p);
2075 while ((p <= lo_mem_max) && freearr[p]) incr(p);
2080 print_nl("New busy locs:");
2082 for (p = mem_min; p <= lo_mem_max; p++)
2083 if (!freearr[p] && ((p > was_lo_max) || wasfree[p]))
2089 for (p = hi_mem_min; p <= mem_end; p++)
2090 if (!freearr[p] && ((p < was_hi_min) || (p > was_mem_end) || wasfree[p]))
2097 for (p = mem_min; p <= lo_mem_max; p++) wasfree[p] = freearr[p];
2098 for (p = hi_mem_min; p <= mem_end; p++) wasfree[p] = freearr[p];
2100 was_mem_end = mem_end;
2101 was_lo_max = lo_mem_max;
2102 was_hi_min = hi_mem_min;
2108 void search_mem_(halfword p)
2112 for (q = mem_min; q <= lo_mem_max; q++)
2128 for (q = hi_mem_min; q <= mem_end; q++)
2144 for (q = active_base; q <= box_base + 255; q++)
2153 for (q = 0; q <= save_ptr - 1; q++)
2155 if (equiv_field(save_stack[q]) == p)
2163 for (q = 0; q <= hyphen_prime; q++)
2164 if (hyph_list[q] == p)
2173 void short_display_(integer p)
2177 while (p != 0) { /* want p != null here bkph 93/Dec/15 !!! NOTE: still not fixed in 3.14159 ! */
2178 if (is_char_node(p))
2182 if (font(p) != font_in_short_display)
2184 if ((font(p) > font_max))
2189 print(font_id_text(font(p)));
2192 font_in_short_display = font(p);
2194 print(character(p));
2197 else switch (mem[p].hh.b0)
2212 if (glue_ptr(p) != 0)
2219 short_display(lig_ptr(p));
2222 short_display(pre_break(p));
2223 short_display(post_break(p));
2224 n = replace_count(p);
2227 if (link(p) != 0) /* if link(p)<>null then */
2239 void print_font_and_char_ (integer p)
2242 print_esc("CLOBBERED.");
2245 if ((font(p) > font_max))
2250 print(font_id_text(font(p)));
2254 print(character(p));
2258 void print_mark_ (integer p)
2262 if ((p < hi_mem_min)||(p > mem_end))
2263 print_esc("CLOBBERED.");
2265 show_token_list(link(p), 0, max_print_line - 10);
2270 void print_rule_dimen_ (scaled d)
2272 if ((d == -1073741824L)) /* - 2^30 */
2278 void print_glue_(scaled d, integer order, char * s)
2282 if ((order < normal) || (order > filll))
2283 print_string("foul");
2286 print_string("fil");
2292 } else if (*s != '\0')
2296 void print_spec_(integer p, char * s)
2298 if ((p < mem_min)||(p >= lo_mem_max))
2302 print_scaled(width(p));
2307 if (stretch(p) != 0)
2309 print_string("plus");
2310 print_glue(stretch(p), stretch_order(p), s);
2315 print_string("minus");
2316 print_glue(shrink(p), shrink_order(p), s);
2321 void print_fam_and_char_(halfword p)
2326 print(character(p));
2329 void print_delimiter_(halfword p)
2333 a = small_fam(p) * 256 + small_char(p);
2334 a = a * 4096 + large_fam(p) * 256 + large_char(p);
2342 void print_subsidiary_data_(halfword p, ASCII_code c)
2344 if ((pool_ptr - str_start[str_ptr]) >= depth_threshold)
2346 if (math_type(p) != 0)
2347 print_string(" []");
2354 switch (math_type(p))
2358 print_current_string();
2359 print_fam_and_char(p);
2370 print_current_string();
2385 void print_style_(integer c)
2390 print_esc("displaystyle");
2393 print_esc("textstyle");
2396 print_esc("scriptstyle");
2399 print_esc("scriptscriptstyle");
2402 print_string("Unknown style!");
2407 void print_skip_param_(integer n)
2411 case line_skip_code:
2412 print_esc("lineskip");
2415 case baseline_skip_code:
2416 print_esc("baselineskip");
2420 print_esc("parskip");
2423 case above_display_skip_code:
2424 print_esc("abovedisplayskip");
2427 case below_display_skip_code:
2428 print_esc("belowdisplayskip");
2431 case above_display_short_skip_code:
2432 print_esc("abovedisplayshortskip");
2435 case below_display_short_skip_code:
2436 print_esc("belowdisplayshortskip");
2439 case left_skip_code:
2440 print_esc("leftskip");
2443 case right_skip_code:
2444 print_esc("rightskip");
2448 print_esc("topskip");
2451 case split_top_skip_code:
2452 print_esc("splittopskip");
2456 print_esc("tabskip");
2459 case space_skip_code:
2460 print_esc("spaceskip");
2463 case xspace_skip_code:
2464 print_esc("xspaceskip");
2467 case par_fill_skip_code:
2468 print_esc("parfillskip");
2471 case thin_mu_skip_code:
2472 print_esc("thinmuskip");
2475 case med_mu_skip_code:
2476 print_esc("medmuskip");
2479 case thick_mu_skip_code:
2480 print_esc("thickmuskip");
2484 print_string("[unknown glue parameter!]");
2489 void show_node_list_(integer p)
2494 if (cur_length > depth_threshold)
2496 /* if (p > 0) */ /* was p>null !!! line 3662 in tex.web */
2497 if (p != 0) /* fixed 94/Mar/23 BUG FIX NOTE: still not fixed in 3.14159 ! */
2498 print_string(" []");
2504 while (p != 0) { /* want p != null - bkph 93/Dec/15 NOTE: still not fixed in 3.14159 ! */
2506 print_current_string();
2510 print_string("Bad link, display aborted.");
2516 if (n > breadth_max)
2518 print_string("etc.");
2522 if ((p >= hi_mem_min))
2523 print_font_and_char(p);
2524 else switch (type(p))
2530 if (type(p) == hlist_node)
2532 else if (type(p) == vlist_node)
2534 else print_esc("unset");
2536 print_string("box(");
2537 print_scaled(height(p));
2539 print_scaled(depth(p));
2541 print_scaled(width(p));
2543 if (type(p) == unset_node)
2545 if (span_count(p) != 0)
2548 print_int(span_count(p) + 1);
2549 print_string(" columns)");
2552 if (glue_stretch(p) != 0)
2554 print_string(", stretch ");
2555 print_glue(glue_stretch(p), glue_order(p), "");
2558 if (glue_shrink(p) != 0)
2560 print_string(", shrink ");
2561 print_glue(glue_shrink(p), glue_sign(p), "");
2568 if ((g != 0.0) && (glue_sign(p) != 0))
2570 print_string(", glue set ");
2572 if (glue_sign(p) == shrinking)
2575 if (fabs(g)> 20000.0)
2580 print_string("< -");
2582 print_glue(20000 * 65536L, glue_order(p), "");
2585 print_glue(round(65536L * g), glue_order(p), "");
2588 if (shift_amount(p) != 0)
2590 print_string(", shifted ");
2591 print_scaled(shift_amount(p));
2597 str_pool[pool_ptr] = 46;
2600 show_node_list(mem[p + 5].hh.v.RH);
2609 print_rule_dimen(height(p));
2611 print_rule_dimen(depth(p));
2613 print_rule_dimen(width(p));
2619 print_esc("insert");
2620 print_int(subtype(p));
2621 print_string(", natural size ");
2622 print_scaled(height(p));
2623 print_string("; split(");
2624 print_spec(split_top_ptr(p), "");
2626 print_scaled(depth(p));
2627 print_string("); float cost ");
2628 print_int(float_cost(p));
2631 str_pool[pool_ptr] = 46;
2634 show_node_list(mem[p + 4].hh.v.LH);
2644 print_write_whatsit(1279, p); /* debug # (-1 to exit): */
2646 print_file_name(open_name(p), open_area(p), open_ext(p));
2652 print_write_whatsit(591, p); /* write */
2653 print_mark(write_tokens(p));
2658 print_write_whatsit(1280, p); /* closeout */
2663 print_esc("special");
2664 print_mark(write_tokens(p));
2670 print_esc("setlanguage");
2671 print_int(what_lang(p));
2672 print_string(" (hyphenmin ");
2673 print_int(what_lhm(p));
2675 print_int(what_rhm(p));
2681 print_string("whatsit?");
2687 if (subtype(p) >= a_leaders)
2691 if (subtype(p) == c_leaders)
2693 else if (subtype(p) == x_leaders)
2696 print_string("leaders ");
2698 print_spec(glue_ptr(p), "");
2701 str_pool[pool_ptr] = 46;
2704 show_node_list(mem[p + 1].hh.v.RH);
2712 if (subtype(p) != normal)
2716 if (subtype(p) < cond_math_glue)
2717 print_skip_param(subtype(p) - 1);
2718 else if (subtype(p) == cond_math_glue)
2719 print_esc("nonscript");
2720 else print_esc("mskip");
2725 if (subtype(p) != cond_math_glue)
2729 if (subtype(p) < cond_math_glue)
2730 print_spec(glue_ptr(p), "");
2732 print_spec(glue_ptr(p), "mu");
2738 if (subtype(p) != mu_glue)
2742 if (subtype(p) != normal)
2745 print_scaled(width(p));
2747 if (subtype(p) == acc_kern)
2748 print_string(" (for accent)");
2753 print_scaled(width(p));
2762 if (subtype(p) == before)
2765 print_string("off");
2769 print_string(", surrounded ");
2770 print_scaled(width(p));
2777 print_font_and_char(lig_char(p));
2778 print_string("(ligature ");
2783 font_in_short_display = font(lig_char(p));
2784 short_display(lig_ptr(p));
2786 if (odd(subtype(p)))
2795 print_esc("penalty ");
2796 print_int(penalty(p));
2802 print_esc("discretionary");
2804 if (replace_count(p) > 0)
2806 print_string(" replacing ");
2807 print_int(replace_count(p));
2812 str_pool[pool_ptr] = 46;
2815 show_node_list(mem[p + 1].hh.v.LH);
2819 str_pool[pool_ptr]= 124;
2822 show_node_list(mem[p + 1].hh.v.RH);
2830 print_mark(mark_ptr(p));
2836 print_esc("vadjust");
2839 str_pool[pool_ptr] = 46;
2842 show_node_list(mem[p + 1].cint);
2849 print_style(subtype(p));
2854 print_esc("mathchoice");
2856 show_node_list(display_mlist(p));
2859 show_node_list(text_mlist(p));
2862 show_node_list(script_mlist(p));
2865 show_node_list(script_script_mlist(p));
2889 print_esc("mathord");
2893 print_esc("mathop");
2897 print_esc("mathbin");
2901 print_esc("mathrel");
2905 print_esc("mathopen");
2909 print_esc("mathclose");
2913 print_esc("mathpunct");
2917 print_esc("mathinner");
2921 print_esc("overline");
2925 print_esc("underline");
2929 print_esc("vcenter");
2934 print_esc("radical");
2935 print_delimiter(left_delimiter(p));
2941 print_esc("accent");
2942 print_fam_and_char(accent_chr(p));
2949 print_delimiter(delimiter(p));
2956 print_delimiter(delimiter(p));
2961 if (subtype(p) != normal)
2962 if (subtype(p) == limits)
2963 print_esc("limits");
2965 print_esc("nolimits");
2967 if (type(p) < left_noad)
2968 print_subsidiary_data(nucleus(p), '.');
2970 print_subsidiary_data(supscr(p), '^');
2971 print_subsidiary_data(subscr(p), '_');
2977 print_esc("fraction, thickness ");
2979 if (thickness(p) == 1073741824L) /* 2^30 */
2980 print_string("= default");
2982 print_scaled(thickness(p));
2984 if ((small_fam(left_delimiter(p)) != 0) || (small_char(left_delimiter(p)) != 0) ||
2985 (large_fam(left_delimiter(p)) != 0) || (large_char(left_delimiter(p)) != 0))
2987 print_string(", left-delimiter ");
2988 print_delimiter(left_delimiter(p));
2991 if ((small_fam(right_delimiter(p)) != 0) || (small_char(right_delimiter(p)) != 0) ||
2992 (large_fam(right_delimiter(p)) != 0)||(large_char(right_delimiter(p)) != 0))
2994 print_string(", right-delimiter ");
2995 print_delimiter(right_delimiter(p));
2998 print_subsidiary_data(numerator(p), '\\');
2999 print_subsidiary_data(denominator(p), '/');
3004 print_string("Unknown node type!");