/* xetex-xetex0.c: bulk of the WEB code translated to C Copyright 2016-2022 The Tectonic Project Licensed under the MIT License. */ #include "xetex-core.h" #include "xetex-xetexd.h" #include "xetex-synctex.h" #include /* for EOF */ #define IS_LC_HEX(c) (((c) >= '0' && (c) <= '9' ) || ((c) >= 'a' && (c) <= 'f' )) static void int_error(int32_t n) { print_cstr(" ("); print_int(n); print_char(')'); error(); } int32_t badness(scaled_t t, scaled_t s) { int32_t r; if (t == 0) return 0; if (s <= 0) return INF_BAD; if (t <= 7230584L) /* magic constant */ r = (t * 297) / s; else if (s >= 1663497L) /* magic constant */ r = t / (s / 297); else r = t; if (r > 1290) /* magic constant */ return INF_BAD; return (r * r * r + 0x20000) / 0x40000; } /*:112*/ /*118:*/ void show_token_list(int32_t p, int32_t q, int32_t l) { int32_t m, c; int32_t match_chr; UTF16_code n; match_chr = '#' ; n = '0' ; tally = 0; while (p != TEX_NULL && tally < l) { /*332:*/ if (p == q) { first_count = tally; trick_count = tally + 1 + error_line - half_error_line; if (trick_count < error_line) trick_count = error_line; } if (p < hi_mem_min || p > mem_end) { print_esc_cstr("CLOBBERED."); return; } if (mem[p].b32.s0 >= CS_TOKEN_FLAG) { print_cs(mem[p].b32.s0 - CS_TOKEN_FLAG); } else { m = mem[p].b32.s0 / MAX_CHAR_VAL; c = mem[p].b32.s0 % MAX_CHAR_VAL; if (mem[p].b32.s0 < 0) { print_esc_cstr("BAD."); } else { /*306:*/ switch (m) { case LEFT_BRACE: case RIGHT_BRACE: case MATH_SHIFT: case TAB_MARK: case SUP_MARK: case SUB_MARK: case SPACER: case LETTER: case OTHER_CHAR: print_char(c); break; case MAC_PARAM: print_char(c); print_char(c); break; case OUT_PARAM: print_char(match_chr); if (c <= 9) { print_char(c + 48); } else { print_char('!'); return; } break; case MATCH: match_chr = c; print_char(c); n++; print_char(n); if (n > '9' ) return; break; case END_MATCH: if (c == 0) print_cstr("->"); break; default: print_esc_cstr("BAD."); break; } } } p = LLIST_link(p); } if (p != TEX_NULL) print_esc_cstr("ETC."); } void runaway(void) { int32_t p = TEX_NULL; if (scanner_status > SKIPPING) { switch (scanner_status) { case DEFINING: print_nl_cstr("Runaway definition"); p = def_ref; break; case MATCHING: print_nl_cstr("Runaway argument"); p = TEMP_HEAD; break; case ALIGNING: print_nl_cstr("Runaway preamble"); p = HOLD_HEAD; break; case ABSORBING: print_nl_cstr("Runaway text"); p = def_ref; break; } print_char('?'); print_ln(); show_token_list(mem[p].b32.s1, TEX_NULL, error_line - 10); } } int32_t get_avail(void) { int32_t p; p = avail; if (p != TEX_NULL) avail = LLIST_link(avail); else if (mem_end < MEM_TOP) { mem_end++; p = mem_end; } else { hi_mem_min--; p = hi_mem_min; if (is_char_node(lo_mem_max)) { runaway(); overflow("main memory size", MEM_TOP + 1); } } mem[p].b32.s1 = TEX_NULL; return p; } void flush_list(int32_t p) { int32_t q, r; if (p != TEX_NULL) { r = p; do { q = r; r = LLIST_link(r); } while (!(r == TEX_NULL)); mem[q].b32.s1 = avail; avail = p; } } int32_t get_node(int32_t s) { int32_t p; int32_t q; int32_t r; int32_t t; restart: p = rover; do { /*131: */ q = p + mem[p].b32.s0; while (mem[q].b32.s1 == MAX_HALFWORD) { t = mem[q + 1].b32.s1; if (q == rover) rover = t; mem[t + 1].b32.s0 = mem[q + 1].b32.s0; mem[mem[q + 1].b32.s0 + 1].b32.s1 = t; q = q + mem[q].b32.s0; } r = q - s; if (r > p + 1) { /*132: */ mem[p].b32.s0 = r - p; rover = p; goto found; } if (r == p) { if (mem[p + 1].b32.s1 != p) { /*133: */ rover = mem[p + 1].b32.s1; t = mem[p + 1].b32.s0; mem[rover + 1].b32.s0 = t; mem[t + 1].b32.s1 = rover; goto found; } } mem[p].b32.s0 = q - /*:131 */ p; p = mem[p + 1].b32.s1; } while (!(p == rover)); if (s == 0x40000000) { return MAX_HALFWORD; } if (lo_mem_max + 2 < hi_mem_min) { if (lo_mem_max + 2 <= MAX_HALFWORD) { /*130: */ if (hi_mem_min - lo_mem_max >= 1998) t = lo_mem_max + 1000; else t = lo_mem_max + 1 + (hi_mem_min - lo_mem_max) / 2; p = mem[rover + 1].b32.s0; q = lo_mem_max; mem[p + 1].b32.s1 = q; mem[rover + 1].b32.s0 = q; if (t > MAX_HALFWORD) t = MAX_HALFWORD; mem[q + 1].b32.s1 = rover; mem[q + 1].b32.s0 = p; mem[q].b32.s1 = MAX_HALFWORD; mem[q].b32.s0 = t - lo_mem_max; lo_mem_max = t; mem[lo_mem_max].b32.s1 = TEX_NULL; mem[lo_mem_max].b32.s0 = TEX_NULL; rover = q; goto restart; } } overflow("main memory size", MEM_TOP + 1); found: mem[r].b32.s1 = TEX_NULL; if (s >= MEDIUM_NODE_SIZE) { mem[r + s - 1].b32.s0 = cur_input.synctex_tag; mem[r + s - 1].b32.s1 = line; } return r; } void free_node(int32_t p, int32_t s) { int32_t q; mem[p].b32.s0 = s; mem[p].b32.s1 = MAX_HALFWORD; q = mem[rover + 1].b32.s0; mem[p + 1].b32.s0 = q; mem[p + 1].b32.s1 = rover; mem[rover + 1].b32.s0 = p; mem[q + 1].b32.s1 = p; } int32_t new_null_box(void) { int32_t p; p = get_node(BOX_NODE_SIZE); NODE_type(p) = HLIST_NODE; mem[p].b16.s0 = 0; mem[p + 1].b32.s1 = 0; mem[p + 2].b32.s1 = 0; mem[p + 3].b32.s1 = 0; mem[p + 4].b32.s1 = 0; mem[p + 5].b32.s1 = TEX_NULL; mem[p + 5].b16.s1 = NORMAL; mem[p + 5].b16.s0 = NORMAL; BOX_glue_set(p) = 0.0; return p; } int32_t new_rule(void) { int32_t p; p = get_node(RULE_NODE_SIZE); NODE_type(p) = RULE_NODE; mem[p].b16.s0 = 0; mem[p + 1].b32.s1 = NULL_FLAG; mem[p + 2].b32.s1 = NULL_FLAG; mem[p + 3].b32.s1 = NULL_FLAG; return p; } int32_t new_ligature(internal_font_number f, uint16_t c, int32_t q) { int32_t p; p = get_node(SMALL_NODE_SIZE); NODE_type(p) = LIGATURE_NODE; mem[p + 1].b16.s1 = f; mem[p + 1].b16.s0 = c; mem[p + 1].b32.s1 = q; mem[p].b16.s0 = 0; return p; } int32_t new_lig_item(uint16_t c) { int32_t p; p = get_node(SMALL_NODE_SIZE); mem[p].b16.s0 = c; mem[p + 1].b32.s1 = TEX_NULL; return p; } int32_t new_disc(void) { int32_t p; p = get_node(SMALL_NODE_SIZE); NODE_type(p) = DISC_NODE; mem[p].b16.s0 = 0; mem[p + 1].b32.s0 = TEX_NULL; mem[p + 1].b32.s1 = TEX_NULL; return p; } void copy_native_glyph_info(int32_t src, int32_t dest) { int32_t glyph_count; if (NATIVE_NODE_glyph_info_ptr(src) != NULL) { glyph_count = NATIVE_NODE_glyph_count(src); NATIVE_NODE_glyph_info_ptr(dest) = xmalloc_array(char, glyph_count * NATIVE_GLYPH_INFO_SIZE); memcpy(NATIVE_NODE_glyph_info_ptr(dest), NATIVE_NODE_glyph_info_ptr(src), glyph_count * NATIVE_GLYPH_INFO_SIZE); NATIVE_NODE_glyph_count(dest) = glyph_count; } } int32_t new_math(scaled_t w, small_number s) { int32_t p; p = get_node(MEDIUM_NODE_SIZE); NODE_type(p) = MATH_NODE; mem[p].b16.s0 = s; mem[p + 1].b32.s1 = w; return p; } int32_t new_spec(int32_t p) { int32_t q; q = get_node(GLUE_SPEC_SIZE); mem[q] = mem[p]; mem[q].b32.s1 = TEX_NULL; mem[q + 1].b32.s1 = mem[p + 1].b32.s1; mem[q + 2].b32.s1 = mem[p + 2].b32.s1; mem[q + 3].b32.s1 = mem[p + 3].b32.s1; return q; } int32_t new_param_glue(small_number n) { int32_t p; int32_t q; p = get_node(MEDIUM_NODE_SIZE); NODE_type(p) = GLUE_NODE; mem[p].b16.s0 = n + 1; mem[p + 1].b32.s1 = TEX_NULL; q = /*232: */ eqtb[GLUE_BASE + n].b32.s1 /*:232 */ ; mem[p + 1].b32.s0 = q; GLUE_SPEC_ref_count(q)++; return p; } int32_t new_glue(int32_t q) { int32_t p; p = get_node(MEDIUM_NODE_SIZE); NODE_type(p) = GLUE_NODE; GLUE_SPEC_shrink_order(p) = NORMAL; mem[p + 1].b32.s1 = TEX_NULL; mem[p + 1].b32.s0 = q; GLUE_SPEC_ref_count(q)++; return p; } int32_t new_skip_param(small_number n) { int32_t p; temp_ptr = new_spec( /*232: */ eqtb[GLUE_BASE + n].b32.s1 /*:232 */ ); p = new_glue(temp_ptr); mem[temp_ptr].b32.s1 = TEX_NULL; mem[p].b16.s0 = n + 1; return p; } int32_t new_kern(scaled_t w) { int32_t p; p = get_node(MEDIUM_NODE_SIZE); NODE_type(p) = KERN_NODE; mem[p].b16.s0 = NORMAL; mem[p + 1].b32.s1 = w; return p; } int32_t new_penalty(int32_t m) { int32_t p; p = get_node(MEDIUM_NODE_SIZE); NODE_type(p) = PENALTY_NODE; mem[p].b16.s0 = 0; mem[p + 1].b32.s1 = m; return p; } /*:165*/ int32_t prev_rightmost(int32_t s, int32_t e) { int32_t p; p = s; if (p == TEX_NULL) return TEX_NULL; while (mem[p].b32.s1 != e) { p = LLIST_link(p); if (p == TEX_NULL) return TEX_NULL; } return p; } int32_t get_microinterval(void) { int32_t s, m; get_seconds_and_micros(&s, &m); if ((s - epochseconds) > 0x7FFF) return -1; else if (microseconds > m) return ((s - 1 - epochseconds) * 65536) + (((m + 1000000L - microseconds) / 100.0) * 65536) / 10000.0; else return ((s - epochseconds) * 65536) + (((m - microseconds) / 100.0) * 65536) / 10000.0; } void short_display(int32_t p) { int32_t n; while (p > 0) { if (is_char_node(p)) { if (p <= mem_end) { if (mem[p].b16.s1 != font_in_short_display) { if (mem[p].b16.s1 > font_max) print_char('*'); else /*279:*/ print_esc(hash[FONT_ID_BASE + mem[p].b16.s1].s1); print_char(' '); font_in_short_display = mem[p].b16.s1; } print(mem[p].b16.s0); } } else { /*183:*/ switch (mem[p].b16.s1) { case HLIST_NODE: case VLIST_NODE: case INS_NODE: case MARK_NODE: case ADJUST_NODE: case UNSET_NODE: print_cstr("[]"); break; case WHATSIT_NODE: switch (mem[p].b16.s0) { case NATIVE_WORD_NODE: case NATIVE_WORD_NODE_AT: if (mem[p + 4].b16.s2 != font_in_short_display) { print_esc(hash[FONT_ID_BASE + mem[p + 4].b16.s2].s1); print_char(' '); font_in_short_display = mem[p + 4].b16.s2; } print_native_word(p); break; default: print_cstr("[]"); break; } break; case RULE_NODE: print_char('|'); break; case GLUE_NODE: if (mem[p + 1].b32.s0 != 0) print_char(' '); break; case MATH_NODE: if (mem[p].b16.s0 >= L_CODE) print_cstr("[]"); else print_char('$'); break; case LIGATURE_NODE: short_display(mem[p + 1].b32.s1); break; case DISC_NODE: short_display(mem[p + 1].b32.s0); short_display(mem[p + 1].b32.s1); n = mem[p].b16.s0; while (n > 0) { if (mem[p].b32.s1 != TEX_NULL) p = LLIST_link(p); n--; } break; default: break; } } p = LLIST_link(p); } } void print_font_and_char(int32_t p) { if (p > mem_end) print_esc_cstr("CLOBBERED."); else { if ((mem[p].b16.s1 > font_max)) print_char('*'); else /*279: */ print_esc(hash[FONT_ID_BASE + mem[p].b16.s1].s1); print_char(' '); print(mem[p].b16.s0); } } void print_mark(int32_t p) { print_char('{'); if ((p < hi_mem_min) || (p > mem_end)) print_esc_cstr("CLOBBERED."); else show_token_list(mem[p].b32.s1, TEX_NULL, max_print_line - 10); print_char('}'); } void print_rule_dimen(scaled_t d) { if (d == NULL_FLAG) print_char('*'); else print_scaled(d); } void print_glue(scaled_t d, int32_t order, const char* s) { print_scaled(d); if ((order < NORMAL) || (order > FILLL)) print_cstr("foul"); else if (order > NORMAL) { print_cstr("fil"); while (order > FIL) { print_char('l'); order--; } } else if (s != 0) print_cstr(s); } void print_spec(int32_t p, const char* s) { if (p < 0 || p >= lo_mem_max) print_char('*'); else { print_scaled(mem[p + 1].b32.s1); if (s != NULL) print_cstr(s); if (mem[p + 2].b32.s1 != 0) { print_cstr(" plus "); print_glue(mem[p + 2].b32.s1, mem[p].b16.s1, s); } if (mem[p + 3].b32.s1 != 0) { print_cstr(" minus "); print_glue(mem[p + 3].b32.s1, mem[p].b16.s0, s); } } } void print_fam_and_char(int32_t p) { int32_t c; print_esc_cstr("fam"); print_int((mem[p].b16.s1 % 256) % 256); print_char(' '); c = ((unsigned short) mem[p].b16.s0 + ((mem[p].b16.s1 / 256) * 65536L)); if (c < 65536L) print(c); else print_char(c); } void print_delimiter(int32_t p) { int32_t a; a = (mem[p].b16.s3 % 256) * 256 + (mem[p].b16.s2 + (mem[p].b16.s3 / 256) * 65536L); a = a * 4096 + (mem[p].b16.s1 % 256) * 256 + (mem[p].b16.s0 + (mem[p].b16.s1 / 256) * 65536L); if (a < 0) print_int(a); else print_hex(a); } void print_subsidiary_data(int32_t p, UTF16_code c) { if (cur_length() >= depth_threshold) { if (mem[p].b32.s1 != EMPTY) print_cstr(" []"); } else { str_pool[pool_ptr] = c; pool_ptr++; temp_ptr = p; switch (mem[p].b32.s1) { case MATH_CHAR: print_ln(); print_current_string(); print_fam_and_char(p); break; case SUB_BOX: show_info(); break; case SUB_MLIST: if (mem[p].b32.s0 == TEX_NULL) { print_ln(); print_current_string(); print_cstr("{}"); } else { show_info(); } break; default: break; } pool_ptr--; } } void print_style(int32_t c) { switch (c / 2) { case DISPLAY_STYLE / 2: print_esc_cstr("displaystyle"); break; case TEXT_STYLE / 2: print_esc_cstr("textstyle"); break; case SCRIPT_STYLE / 2: print_esc_cstr("scriptstyle"); break; case SCRIPT_SCRIPT_STYLE / 2: print_esc_cstr("scriptscriptstyle"); break; default: print_cstr("Unknown style!"); break; } } void print_skip_param(int32_t n) { switch (n) { case GLUE_PAR__line_skip: print_esc_cstr("lineskip"); break; case GLUE_PAR__baseline_skip: print_esc_cstr("baselineskip"); break; case GLUE_PAR__par_skip: print_esc_cstr("parskip"); break; case GLUE_PAR__above_display_skip: print_esc_cstr("abovedisplayskip"); break; case GLUE_PAR__below_display_skip: print_esc_cstr("belowdisplayskip"); break; case GLUE_PAR__above_display_short_skip: print_esc_cstr("abovedisplayshortskip"); break; case GLUE_PAR__below_display_short_skip: print_esc_cstr("belowdisplayshortskip"); break; case GLUE_PAR__left_skip: print_esc_cstr("leftskip"); break; case GLUE_PAR__right_skip: print_esc_cstr("rightskip"); break; case GLUE_PAR__top_skip: print_esc_cstr("topskip"); break; case GLUE_PAR__split_top_skip: print_esc_cstr("splittopskip"); break; case GLUE_PAR__tab_skip: print_esc_cstr("tabskip"); break; case GLUE_PAR__space_skip: print_esc_cstr("spaceskip"); break; case GLUE_PAR__xspace_skip: print_esc_cstr("xspaceskip"); break; case GLUE_PAR__par_fill_skip: print_esc_cstr("parfillskip"); break; case GLUE_PAR__xetex_linebreak_skip: print_esc_cstr("XeTeXlinebreakskip"); break; case GLUE_PAR__thin_mu_skip: print_esc_cstr("thinmuskip"); break; case GLUE_PAR__med_mu_skip: print_esc_cstr("medmuskip"); break; case GLUE_PAR__thick_mu_skip: print_esc_cstr("thickmuskip"); break; default: print_cstr("[unknown glue parameter!]"); break; } } void show_node_list(int32_t p) { int32_t n; int32_t i; double g; if (cur_length() > depth_threshold) { if (p > TEX_NULL) print_cstr(" []"); return; } n = 0; while (p > 0) { print_ln(); print_current_string(); if (p > mem_end) { print_cstr("Bad link, display aborted."); return; } n++; if (n > breadth_max) { print_cstr("etc."); return; } if (is_char_node(p)) { print_font_and_char(p); } else { switch (mem[p].b16.s1) { case HLIST_NODE: case VLIST_NODE: case UNSET_NODE: if (NODE_type(p) == HLIST_NODE) print_esc('h' ); else if (NODE_type(p) == VLIST_NODE) print_esc('v' ); else print_esc_cstr("unset"); print_cstr("box("); print_scaled(mem[p + 3].b32.s1); print_char('+'); print_scaled(mem[p + 2].b32.s1); print_cstr(")x"); print_scaled(mem[p + 1].b32.s1); if (NODE_type(p) == UNSET_NODE) { /*193:*/ if (mem[p].b16.s0 != 0) { print_cstr(" ("); print_int(mem[p].b16.s0 + 1); print_cstr(" columns)"); } if (mem[p + 6].b32.s1 != 0) { print_cstr(", stretch "); print_glue(mem[p + 6].b32.s1, mem[p + 5].b16.s0, NULL); } if (mem[p + 4].b32.s1 != 0) { print_cstr(", shrink "); print_glue(mem[p + 4].b32.s1, mem[p + 5].b16.s1, NULL); } } else { g = BOX_glue_set(p); if (g != 0.0 && mem[p + 5].b16.s1 != NORMAL) { print_cstr(", glue set "); if (mem[p + 5].b16.s1 == SHRINKING) print_cstr("- "); if (fabs(g) > 20000.0) { if (g > 0.0) print_char('>'); else print_cstr("< -"); print_glue(20000 * 65536L, mem[p + 5].b16.s0, NULL); } else { print_glue(tex_round(65536L * g), mem[p + 5].b16.s0, NULL); } } if (mem[p + 4].b32.s1 != 0) { print_cstr(", shifted "); print_scaled(mem[p + 4].b32.s1); } /*1491:*/ if (NODE_type(p) == HLIST_NODE && mem[p].b16.s0 == DLIST) print_cstr(", display"); } str_pool[pool_ptr] = '.' ; pool_ptr++; show_node_list(mem[p + 5].b32.s1); pool_ptr--; break; case RULE_NODE: print_esc_cstr("rule("); print_rule_dimen(mem[p + 3].b32.s1); print_char('+'); print_rule_dimen(mem[p + 2].b32.s1); print_cstr(")x"); print_rule_dimen(mem[p + 1].b32.s1); break; case INS_NODE: print_esc_cstr("insert"); print_int(mem[p].b16.s0); print_cstr(", natural size "); print_scaled(mem[p + 3].b32.s1); print_cstr("; split("); print_spec(mem[p + 4].b32.s1, NULL); print_char(','); print_scaled(mem[p + 2].b32.s1); print_cstr("); float cost "); print_int(mem[p + 1].b32.s1); str_pool[pool_ptr] = '.' ; pool_ptr++; show_node_list(mem[p + 4].b32.s0); pool_ptr--; break; case WHATSIT_NODE: switch (mem[p].b16.s0) { case OPEN_NODE: print_write_whatsit("openout", p); print_char('='); print_file_name(mem[p + 1].b32.s1, mem[p + 2].b32.s0, mem[p + 2].b32.s1); break; case WRITE_NODE: print_write_whatsit("write", p); print_mark(mem[p + 1].b32.s1); break; case CLOSE_NODE: print_write_whatsit("closeout", p); break; case SPECIAL_NODE: print_esc_cstr("special"); print_mark(mem[p + 1].b32.s1); break; case LANGUAGE_NODE: print_esc_cstr("setlanguage"); print_int(mem[p + 1].b32.s1); print_cstr(" (hyphenmin "); print_int(mem[p + 1].b16.s1); print_char(','); print_int(mem[p + 1].b16.s0); print_char(')'); break; case PDF_SAVE_POS_NODE: print_esc_cstr("pdfsavepos"); break; case NATIVE_WORD_NODE: case NATIVE_WORD_NODE_AT: print_esc(hash[FONT_ID_BASE + mem[p + 4].b16.s2].s1); print_char(' '); print_native_word(p); break; case GLYPH_NODE: print_esc(hash[FONT_ID_BASE + mem[p + 4].b16.s2].s1); print_cstr(" glyph#"); print_int(mem[p + 4].b16.s1); break; case PIC_NODE: case PDF_NODE: if (mem[p].b16.s0 == PIC_NODE) print_esc_cstr("XeTeXpicfile"); else print_esc_cstr("XeTeXpdffile"); print_cstr("( "); for (i = 0; i < PIC_NODE_path_len(p); i++) print_raw_char(PIC_NODE_path(p)[i], true); print('"'); break; default: print_cstr("whatsit?"); break; } break; /* WHATSIT_NODE */ case GLUE_NODE: if (mem[p].b16.s0 >= A_LEADERS) { /*198: */ print_esc_cstr(""); if (mem[p].b16.s0 == C_LEADERS) print_char('c'); else if (mem[p].b16.s0 == X_LEADERS) print_char('x'); print_cstr("leaders "); print_spec(mem[p + 1].b32.s0, NULL); str_pool[pool_ptr] = '.' ; pool_ptr++; show_node_list(mem[p + 1].b32.s1); pool_ptr--; } else { print_esc_cstr("glue"); if (GLUE_SPEC_shrink_order(p) != NORMAL) { print_char('('); if (mem[p].b16.s0 < COND_MATH_GLUE) print_skip_param(mem[p].b16.s0 - 1); else if (mem[p].b16.s0 == COND_MATH_GLUE) print_esc_cstr("nonscript"); else print_esc_cstr("mskip"); print_char(')'); } if (mem[p].b16.s0 != COND_MATH_GLUE) { print_char(' '); if (mem[p].b16.s0 < COND_MATH_GLUE) print_spec(mem[p + 1].b32.s0, NULL); else print_spec(mem[p + 1].b32.s0, "mu"); } } break; case KERN_NODE: if (mem[p].b16.s0 != MU_GLUE) { print_esc_cstr("kern"); if (mem[p].b16.s0 != NORMAL) print_char(' '); print_scaled(mem[p + 1].b32.s1); if (NODE_subtype(p) == ACC_KERN) print_cstr(" (for accent)"); else if (NODE_subtype(p) == SPACE_ADJUSTMENT) print_cstr(" (space adjustment)"); } else { print_esc_cstr("mkern"); print_scaled(mem[p + 1].b32.s1); print_cstr("mu"); } break; case MARGIN_KERN_NODE: print_esc_cstr("kern"); print_scaled(mem[p + 1].b32.s1); if (mem[p].b16.s0 == 0) print_cstr(" (left margin)"); else print_cstr(" (right margin)"); break; case MATH_NODE: if (mem[p].b16.s0 > AFTER) { if (odd(mem[p].b16.s0)) print_esc_cstr("end"); else print_esc_cstr("begin"); if (mem[p].b16.s0 > R_CODE) print_char('R'); else if (mem[p].b16.s0 > L_CODE) print_char('L'); else print_char('M'); } else { print_esc_cstr("math"); if (mem[p].b16.s0 == BEFORE) print_cstr("on"); else print_cstr("off"); if (mem[p + 1].b32.s1 != 0) { print_cstr(", surrounded "); print_scaled(mem[p + 1].b32.s1); } } break; case LIGATURE_NODE: print_font_and_char(p + 1); print_cstr(" (ligature "); if (mem[p].b16.s0 > 1) print_char('|'); font_in_short_display = mem[p + 1].b16.s1; short_display(mem[p + 1].b32.s1); if (odd(mem[p].b16.s0)) print_char('|'); print_char(')'); break; case PENALTY_NODE: print_esc_cstr("penalty "); print_int(mem[p + 1].b32.s1); break; case DISC_NODE: print_esc_cstr("discretionary"); if (mem[p].b16.s0 > 0) { print_cstr(" replacing "); print_int(mem[p].b16.s0); } str_pool[pool_ptr] = '.' ; pool_ptr++; show_node_list(mem[p + 1].b32.s0); pool_ptr--; str_pool[pool_ptr] = '|' ; pool_ptr++; show_node_list(mem[p + 1].b32.s1); pool_ptr--; break; case MARK_NODE: print_esc_cstr("mark"); if (mem[p + 1].b32.s0 != 0) { print_char('s'); print_int(mem[p + 1].b32.s0); } print_mark(mem[p + 1].b32.s1); break; case ADJUST_NODE: print_esc_cstr("vadjust"); if (mem[p].b16.s0 != 0) print_cstr(" pre "); str_pool[pool_ptr] = '.' ; pool_ptr++; show_node_list(mem[p + 1].b32.s1); pool_ptr--; break; case STYLE_NODE: print_style(mem[p].b16.s0); break; case CHOICE_NODE: print_esc_cstr("mathchoice"); str_pool[pool_ptr] = 'D' ; pool_ptr++; show_node_list(mem[p + 1].b32.s0); pool_ptr--; str_pool[pool_ptr] = 'T' ; pool_ptr++; show_node_list(mem[p + 1].b32.s1); pool_ptr--; str_pool[pool_ptr] = 'S' ; pool_ptr++; show_node_list(mem[p + 2].b32.s0); pool_ptr--; str_pool[pool_ptr] = 's' ; pool_ptr++; show_node_list(mem[p + 2].b32.s1); pool_ptr--; break; case ORD_NOAD: case OP_NOAD: case BIN_NOAD: case REL_NOAD: case OPEN_NOAD: case CLOSE_NOAD: case PUNCT_NOAD: case INNER_NOAD: case RADICAL_NOAD: case OVER_NOAD: case UNDER_NOAD: case VCENTER_NOAD: case ACCENT_NOAD: case LEFT_NOAD: case RIGHT_NOAD: { switch (mem[p].b16.s1) { case ORD_NOAD: print_esc_cstr("mathord"); break; case OP_NOAD: print_esc_cstr("mathop"); break; case BIN_NOAD: print_esc_cstr("mathbin"); break; case REL_NOAD: print_esc_cstr("mathrel"); break; case OPEN_NOAD: print_esc_cstr("mathopen"); break; case CLOSE_NOAD: print_esc_cstr("mathclose"); break; case PUNCT_NOAD: print_esc_cstr("mathpunct"); break; case INNER_NOAD: print_esc_cstr("mathinner"); break; case OVER_NOAD: print_esc_cstr("overline"); break; case UNDER_NOAD: print_esc_cstr("underline"); break; case VCENTER_NOAD: print_esc_cstr("vcenter"); break; case RADICAL_NOAD: print_esc_cstr("radical"); print_delimiter(p + 4); break; case ACCENT_NOAD: print_esc_cstr("accent"); print_fam_and_char(p + 4); break; case LEFT_NOAD: print_esc_cstr("left"); print_delimiter(p + 1); break; case RIGHT_NOAD: if (mem[p].b16.s0 == NORMAL) print_esc_cstr("right"); else print_esc_cstr("middle"); print_delimiter(p + 1); break; } if (mem[p].b16.s1 < LEFT_NOAD) { if (mem[p].b16.s0 != NORMAL) { if (mem[p].b16.s0 == LIMITS) print_esc_cstr("limits"); else print_esc_cstr("nolimits"); } print_subsidiary_data(p + 1, '.' ); } print_subsidiary_data(p + 2, '^' ); print_subsidiary_data(p + 3, '_' ); } break; /* many math noads */ case FRACTION_NOAD: print_esc_cstr("fraction, thickness "); if (mem[p + 1].b32.s1 == DEFAULT_CODE) print_cstr("= default"); else print_scaled(mem[p + 1].b32.s1); if (mem[p + 4].b16.s3 % 256 != 0 || (mem[p + 4].b16.s2 + (mem[p + 4].b16.s3 / 256) * 65536L) != 0 || mem[p + 4].b16.s1 % 256 != 0 || (mem[p + 4].b16.s0 + (mem[p + 4].b16.s1 / 256) * 65536L) != 0) { print_cstr(", left-delimiter "); print_delimiter(p + 4); } if (mem[p + 5].b16.s3 % 256 != 0 || (mem[p + 5].b16.s2 + (mem[p + 5].b16.s3 / 256) * 65536L) != 0 || mem[p + 5].b16.s1 % 256 != 0 || (mem[p + 5].b16.s0 + (mem[p + 5].b16.s1 / 256) * 65536L) != 0) { print_cstr(", right-delimiter "); print_delimiter(p + 5); } print_subsidiary_data(p + 2, '\\' ); print_subsidiary_data(p + 3, '/' ); break; default: print_cstr("Unknown node type!"); break; } } p = LLIST_link(p); } } void show_box(int32_t p) { depth_threshold = INTPAR(show_box_depth); breadth_max = INTPAR(show_box_breadth) /*:244 */ ; if (breadth_max <= 0) breadth_max = 5; if (pool_ptr + depth_threshold >= pool_size) depth_threshold = pool_size - pool_ptr - 1; show_node_list(p); print_ln(); } void short_display_n(int32_t p, int32_t m) { breadth_max = m; depth_threshold = pool_size - pool_ptr - 1; show_node_list(p); } void delete_token_ref(int32_t p) { if (mem[p].b32.s0 == TEX_NULL) flush_list(p); else mem[p].b32.s0--; } void delete_glue_ref(int32_t p) { if (mem[p].b32.s1 == TEX_NULL) free_node(p, GLUE_SPEC_SIZE); else mem[p].b32.s1--; } void flush_node_list(int32_t p) { int32_t q; while (p != TEX_NULL) { q = mem[p].b32.s1; if (is_char_node(p)) { mem[p].b32.s1 = avail; avail = p; } else { switch (mem[p].b16.s1) { case HLIST_NODE: case VLIST_NODE: case UNSET_NODE: flush_node_list(mem[p + 5].b32.s1); free_node(p, BOX_NODE_SIZE); goto done; break; case RULE_NODE: free_node(p, RULE_NODE_SIZE); goto done; break; case INS_NODE: flush_node_list(mem[p + 4].b32.s0); delete_glue_ref(INSERTION_NODE_split_top_ptr(p)); free_node(p, INS_NODE_SIZE); goto done; break; case WHATSIT_NODE: switch (mem[p].b16.s0) { case OPEN_NODE: free_node(p, OPEN_NODE_SIZE); break; case WRITE_NODE: case SPECIAL_NODE: delete_token_ref(mem[p + 1].b32.s1); free_node(p, WRITE_NODE_SIZE); goto done; break; case CLOSE_NODE: case LANGUAGE_NODE: free_node(p, SMALL_NODE_SIZE); break; case NATIVE_WORD_NODE: case NATIVE_WORD_NODE_AT: if (NATIVE_NODE_glyph_info_ptr(p) != NULL) { NATIVE_NODE_glyph_info_ptr(p) = mfree(NATIVE_NODE_glyph_info_ptr(p)); NATIVE_NODE_glyph_count(p) = 0; } free_node(p, NATIVE_NODE_size(p)); break; case GLYPH_NODE: free_node(p, GLYPH_NODE_SIZE); break; case PIC_NODE: case PDF_NODE: free_node(p, (PIC_NODE_SIZE + (mem[p + 4].b16.s1 + sizeof(memory_word) - 1) / sizeof(memory_word))); break; case PDF_SAVE_POS_NODE: free_node(p, SMALL_NODE_SIZE); break; default: confusion("ext3"); break; } goto done; break; case GLUE_NODE: if (mem[mem[p + 1].b32.s0].b32.s1 == TEX_NULL) free_node(mem[p + 1].b32.s0, GLUE_SPEC_SIZE); else mem[mem[p + 1].b32.s0].b32.s1--; if (mem[p + 1].b32.s1 != TEX_NULL) flush_node_list(mem[p + 1].b32.s1); free_node(p, MEDIUM_NODE_SIZE); goto done; break; case KERN_NODE: case MATH_NODE: case PENALTY_NODE: free_node(p, MEDIUM_NODE_SIZE); goto done; break; case MARGIN_KERN_NODE: free_node(p, MARGIN_KERN_NODE_SIZE); goto done; break; case LIGATURE_NODE: flush_node_list(mem[p + 1].b32.s1); break; case MARK_NODE: delete_token_ref(mem[p + 1].b32.s1); break; case DISC_NODE: flush_node_list(mem[p + 1].b32.s0); flush_node_list(mem[p + 1].b32.s1); break; case ADJUST_NODE: flush_node_list(mem[p + 1].b32.s1); break; case STYLE_NODE: free_node(p, STYLE_NODE_SIZE); goto done; break; case CHOICE_NODE: flush_node_list(mem[p + 1].b32.s0); flush_node_list(mem[p + 1].b32.s1); flush_node_list(mem[p + 2].b32.s0); flush_node_list(mem[p + 2].b32.s1); free_node(p, STYLE_NODE_SIZE); goto done; break; case ORD_NOAD: case OP_NOAD: case BIN_NOAD: case REL_NOAD: case OPEN_NOAD: case CLOSE_NOAD: case PUNCT_NOAD: case INNER_NOAD: case RADICAL_NOAD: case OVER_NOAD: case UNDER_NOAD: case VCENTER_NOAD: case ACCENT_NOAD: if (mem[p + 1].b32.s1 >= SUB_BOX) flush_node_list(mem[p + 1].b32.s0); if (mem[p + 2].b32.s1 >= SUB_BOX) flush_node_list(mem[p + 2].b32.s0); if (mem[p + 3].b32.s1 >= SUB_BOX) flush_node_list(mem[p + 3].b32.s0); if (mem[p].b16.s1 == RADICAL_NOAD) free_node(p, RADICAL_NOAD_SIZE); else if (mem[p].b16.s1 == ACCENT_NOAD) free_node(p, ACCENT_NOAD_SIZE); else free_node(p, NOAD_SIZE); goto done; break; case LEFT_NOAD: case RIGHT_NOAD: free_node(p, NOAD_SIZE); goto done; break; case FRACTION_NOAD: flush_node_list(mem[p + 2].b32.s0); flush_node_list(mem[p + 3].b32.s0); free_node(p, FRACTION_NOAD_SIZE); goto done; break; default: confusion("flushing"); break; } free_node(p, SMALL_NODE_SIZE); done: ; } p = q; } } int32_t copy_node_list(int32_t p) { int32_t h; int32_t q; int32_t r; unsigned char words; h = get_avail(); q = h; while (p != TEX_NULL) { words = 1; if (is_char_node(p)) { r = get_avail(); } else { /*214:*/ switch (mem[p].b16.s1) { case HLIST_NODE: case VLIST_NODE: case UNSET_NODE: r = get_node(BOX_NODE_SIZE); SYNCTEX_tag(r, BOX_NODE_SIZE) = SYNCTEX_tag(p, BOX_NODE_SIZE); SYNCTEX_line(r, BOX_NODE_SIZE) = SYNCTEX_line(p, BOX_NODE_SIZE); mem[r + 6] = mem[p + 6]; mem[r + 5] = mem[p + 5]; mem[r + 5].b32.s1 = copy_node_list(mem[p + 5].b32.s1); words = 5; break; case RULE_NODE: r = get_node(RULE_NODE_SIZE); words = (RULE_NODE_SIZE - 1); break; case INS_NODE: r = get_node(INS_NODE_SIZE); mem[r + 4] = mem[p + 4]; GLUE_SPEC_ref_count(mem[p + 4].b32.s1)++; mem[r + 4].b32.s0 = copy_node_list(mem[p + 4].b32.s0); words = (INS_NODE_SIZE - 1); break; case WHATSIT_NODE: switch (mem[p].b16.s0) { case OPEN_NODE: r = get_node(OPEN_NODE_SIZE); words = OPEN_NODE_SIZE; break; case WRITE_NODE: case SPECIAL_NODE: r = get_node(WRITE_NODE_SIZE); mem[mem[p + 1].b32.s1].b32.s0++; words = WRITE_NODE_SIZE; break; case CLOSE_NODE: case LANGUAGE_NODE: r = get_node(SMALL_NODE_SIZE); words = SMALL_NODE_SIZE; break; case NATIVE_WORD_NODE: case NATIVE_WORD_NODE_AT: words = NATIVE_NODE_size(p); r = get_node(words); while (words > 0) { words--; mem[r + words] = mem[p + words]; } NATIVE_NODE_glyph_info_ptr(r) = NULL; NATIVE_NODE_glyph_count(r) = 0; copy_native_glyph_info(p, r); break; case GLYPH_NODE: r = get_node(GLYPH_NODE_SIZE); words = GLYPH_NODE_SIZE; break; case PIC_NODE: case PDF_NODE: words = (PIC_NODE_SIZE + (mem[p + 4].b16.s1 + sizeof(memory_word) - 1) / sizeof(memory_word)); r = get_node(words); break; case PDF_SAVE_POS_NODE: r = get_node(SMALL_NODE_SIZE); break; default: confusion("ext2"); break; } break; case GLUE_NODE: r = get_node(MEDIUM_NODE_SIZE); GLUE_SPEC_ref_count(mem[p + 1].b32.s0)++; mem[r + 2].b32.s0 = mem[p + 2].b32.s0; mem[r + 2].b32.s1 = mem[p + 2].b32.s1; mem[r + 1].b32.s0 = mem[p + 1].b32.s0; mem[r + 1].b32.s1 = copy_node_list(mem[p + 1].b32.s1); break; case KERN_NODE: case MATH_NODE: case PENALTY_NODE: r = get_node(MEDIUM_NODE_SIZE); words = MEDIUM_NODE_SIZE; break; case MARGIN_KERN_NODE: r = get_node(MARGIN_KERN_NODE_SIZE); words = MARGIN_KERN_NODE_SIZE; break; case LIGATURE_NODE: r = get_node(SMALL_NODE_SIZE); mem[r + 1] = mem[p + 1]; mem[r + 1].b32.s1 = copy_node_list(mem[p + 1].b32.s1); break; case DISC_NODE: r = get_node(SMALL_NODE_SIZE); mem[r + 1].b32.s0 = copy_node_list(mem[p + 1].b32.s0); mem[r + 1].b32.s1 = copy_node_list(mem[p + 1].b32.s1); break; case MARK_NODE: r = get_node(SMALL_NODE_SIZE); mem[mem[p + 1].b32.s1].b32.s0++; words = SMALL_NODE_SIZE; break; case ADJUST_NODE: r = get_node(SMALL_NODE_SIZE); mem[r + 1].b32.s1 = copy_node_list(mem[p + 1].b32.s1); break; default: confusion("copying"); break; } } while (words > 0) { words--; mem[r + words] = mem[p + words]; } mem[q].b32.s1 = r; q = r; p = LLIST_link(p); } mem[q].b32.s1 = TEX_NULL; q = mem[h].b32.s1; mem[h].b32.s1 = avail; avail = h; return q; } void print_mode(int32_t m) { if (m > 0) switch (m / ((MAX_COMMAND + 1))) { case 0: print_cstr("vertical mode"); break; case 1: print_cstr("horizontal mode"); break; case 2: print_cstr("display math mode"); break; } else if (m == 0) print_cstr("no mode"); else switch ((-(int32_t) m) / ((MAX_COMMAND + 1))) { case 0: print_cstr("internal vertical mode"); break; case 1: print_cstr("restricted horizontal mode"); break; case 2: print_cstr("math mode"); break; } } void print_in_mode(int32_t m) { if (m > 0) switch (m / ((MAX_COMMAND + 1))) { case 0: print_cstr("' in vertical mode"); break; case 1: print_cstr("' in horizontal mode"); break; case 2: print_cstr("' in display math mode"); break; } else if (m == 0) print_cstr("' in no mode"); else switch ((-(int32_t) m) / ((MAX_COMMAND + 1))) { case 0: print_cstr("' in internal vertical mode"); break; case 1: print_cstr("' in restricted horizontal mode"); break; case 2: print_cstr("' in math mode"); break; } } void push_nest(void) { if (nest_ptr > max_nest_stack) { max_nest_stack = nest_ptr; if (nest_ptr == nest_size) overflow("semantic nest size", nest_size); } nest[nest_ptr] = cur_list; nest_ptr++; cur_list.head = get_avail(); cur_list.tail = cur_list.head; cur_list.prev_graf = 0; cur_list.mode_line = line; cur_list.eTeX_aux = TEX_NULL; } void pop_nest(void) { { mem[cur_list.head].b32.s1 = avail; avail = cur_list.head; } nest_ptr--; cur_list = nest[nest_ptr]; } void show_activities(void) { int32_t p; short /*mmode */ m; memory_word a; int32_t q, r; int32_t t; nest[nest_ptr] = cur_list; print_nl_cstr(""); print_ln(); { register int32_t for_end; p = nest_ptr; for_end = 0; if (p >= for_end) do { m = nest[p].mode; a = nest[p].aux; print_nl_cstr("### "); print_mode(m); print_cstr(" entered at line "); print_int(abs(nest[p].mode_line)); if (m == HMODE) { if (nest[p].prev_graf != 0x830000) { print_cstr(" (language"); print_int(nest[p].prev_graf % 65536L); print_cstr(":hyphenmin"); print_int(nest[p].prev_graf / 0x400000); print_char(','); print_int((nest[p].prev_graf / 65536L) % 64); print_char(')'); } } if (nest[p].mode_line < 0) print_cstr(" (\\output routine)"); if (p == 0) { if (PAGE_HEAD != page_tail) { print_nl_cstr("### current page:"); if (output_active) print_cstr(" (held over for next output)"); show_box(mem[PAGE_HEAD].b32.s1); if (page_contents > EMPTY) { print_nl_cstr("total height "); print_totals(); print_nl_cstr(" goal height "); print_scaled(page_so_far[0]); r = mem[PAGE_INS_HEAD].b32.s1; while (r != PAGE_INS_HEAD) { print_ln(); print_esc_cstr("insert"); t = mem[r].b16.s0; print_int(t); print_cstr(" adds "); if (COUNT_REG(t) == 1000) t = mem[r + 3].b32.s1; else t = x_over_n(mem[r + 3].b32.s1, 1000) * COUNT_REG(t); print_scaled(t); if (mem[r].b16.s1 == SPLIT_UP) { q = PAGE_HEAD; t = 0; do { q = LLIST_link(q); if ((NODE_type(q) == INS_NODE) && (mem[q].b16.s0 == mem[r].b16.s0)) t++; } while (!(q == mem[r + 1].b32.s0)); print_cstr(", #"); print_int(t); print_cstr(" might split"); } r = LLIST_link(r); } } } if (mem[CONTRIB_HEAD].b32.s1 != TEX_NULL) print_nl_cstr("### recent contributions:"); } show_box(mem[nest[p].head].b32.s1); switch (abs(m) / ((MAX_COMMAND + 1))) { case 0: { print_nl_cstr("prevdepth "); if (a.b32.s1 <= IGNORE_DEPTH) print_cstr("ignored"); else print_scaled(a.b32.s1); if (nest[p].prev_graf != 0) { print_cstr(", prevgraf "); print_int(nest[p].prev_graf); if (nest[p].prev_graf != 1) print_cstr(" lines"); else print_cstr(" line"); } } break; case 1: { print_nl_cstr("spacefactor "); print_int(a.b32.s0); if (m > 0) { if (a.b32.s1 > 0) { print_cstr(", current language "); print_int(a.b32.s1); } } } break; case 2: if (a.b32.s1 != TEX_NULL) { print_cstr("this will begin denominator of:"); show_box(a.b32.s1); } break; } } while (p-- > for_end); } } void print_param(int32_t n) { switch (n) { case INT_PAR__pretolerance: print_esc_cstr("pretolerance"); break; case INT_PAR__tolerance: print_esc_cstr("tolerance"); break; case INT_PAR__line_penalty: print_esc_cstr("linepenalty"); break; case INT_PAR__hyphen_penalty: print_esc_cstr("hyphenpenalty"); break; case INT_PAR__ex_hyphen_penalty: print_esc_cstr("exhyphenpenalty"); break; case INT_PAR__club_penalty: print_esc_cstr("clubpenalty"); break; case INT_PAR__widow_penalty: print_esc_cstr("widowpenalty"); break; case INT_PAR__display_widow_penalty: print_esc_cstr("displaywidowpenalty"); break; case INT_PAR__broken_penalty: print_esc_cstr("brokenpenalty"); break; case INT_PAR__bin_op_penalty: print_esc_cstr("binoppenalty"); break; case INT_PAR__rel_penalty: print_esc_cstr("relpenalty"); break; case INT_PAR__pre_display_penalty: print_esc_cstr("predisplaypenalty"); break; case INT_PAR__post_display_penalty: print_esc_cstr("postdisplaypenalty"); break; case INT_PAR__inter_line_penalty: print_esc_cstr("interlinepenalty"); break; case INT_PAR__double_hyphen_demerits: print_esc_cstr("doublehyphendemerits"); break; case INT_PAR__final_hyphen_demerits: print_esc_cstr("finalhyphendemerits"); break; case INT_PAR__adj_demerits: print_esc_cstr("adjdemerits"); break; case INT_PAR__mag: print_esc_cstr("mag"); break; case INT_PAR__delimiter_factor: print_esc_cstr("delimiterfactor"); break; case INT_PAR__looseness: print_esc_cstr("looseness"); break; case INT_PAR__time: print_esc_cstr("time"); break; case INT_PAR__day: print_esc_cstr("day"); break; case INT_PAR__month: print_esc_cstr("month"); break; case INT_PAR__year: print_esc_cstr("year"); break; case INT_PAR__show_box_breadth: print_esc_cstr("showboxbreadth"); break; case INT_PAR__show_box_depth: print_esc_cstr("showboxdepth"); break; case INT_PAR__hbadness: print_esc_cstr("hbadness"); break; case INT_PAR__vbadness: print_esc_cstr("vbadness"); break; case INT_PAR__pausing: print_esc_cstr("pausing"); break; case INT_PAR__tracing_online: print_esc_cstr("tracingonline"); break; case INT_PAR__tracing_macros: print_esc_cstr("tracingmacros"); break; case INT_PAR__tracing_stats: print_esc_cstr("tracingstats"); break; case INT_PAR__tracing_paragraphs: print_esc_cstr("tracingparagraphs"); break; case INT_PAR__tracing_pages: print_esc_cstr("tracingpages"); break; case INT_PAR__tracing_output: print_esc_cstr("tracingoutput"); break; case INT_PAR__tracing_lost_chars: print_esc_cstr("tracinglostchars"); break; case INT_PAR__tracing_commands: print_esc_cstr("tracingcommands"); break; case INT_PAR__tracing_restores: print_esc_cstr("tracingrestores"); break; case INT_PAR__uc_hyph: print_esc_cstr("uchyph"); break; case INT_PAR__output_penalty: print_esc_cstr("outputpenalty"); break; case INT_PAR__max_dead_cycles: print_esc_cstr("maxdeadcycles"); break; case INT_PAR__hang_after: print_esc_cstr("hangafter"); break; case INT_PAR__floating_penalty: print_esc_cstr("floatingpenalty"); break; case INT_PAR__global_defs: print_esc_cstr("globaldefs"); break; case INT_PAR__cur_fam: print_esc_cstr("fam"); break; case INT_PAR__escape_char: print_esc_cstr("escapechar"); break; case INT_PAR__default_hyphen_char: print_esc_cstr("defaulthyphenchar"); break; case INT_PAR__default_skew_char: print_esc_cstr("defaultskewchar"); break; case INT_PAR__end_line_char: print_esc_cstr("endlinechar"); break; case INT_PAR__new_line_char: print_esc_cstr("newlinechar"); break; case INT_PAR__language: print_esc_cstr("language"); break; case INT_PAR__left_hyphen_min: print_esc_cstr("lefthyphenmin"); break; case INT_PAR__right_hyphen_min: print_esc_cstr("righthyphenmin"); break; case INT_PAR__holding_inserts: print_esc_cstr("holdinginserts"); break; case INT_PAR__error_context_lines: print_esc_cstr("errorcontextlines"); break; /* Tectonic: MLTeX char_sub* params permanently removed */ case INT_PAR__tracing_stack_levels: print_esc_cstr("tracingstacklevels"); break; case INT_PAR__xetex_linebreak_penalty: print_esc_cstr("XeTeXlinebreakpenalty"); break; case INT_PAR__xetex_protrude_chars: print_esc_cstr("XeTeXprotrudechars"); break; case INT_PAR__synctex: print_esc_cstr("synctex"); break; case INT_PAR__tracing_assigns: print_esc_cstr("tracingassigns"); break; case INT_PAR__tracing_groups: print_esc_cstr("tracinggroups"); break; case INT_PAR__tracing_ifs: print_esc_cstr("tracingifs"); break; case INT_PAR__tracing_scan_tokens: print_esc_cstr("tracingscantokens"); break; case INT_PAR__tracing_nesting: print_esc_cstr("tracingnesting"); break; case INT_PAR__pre_display_direction: print_esc_cstr("predisplaydirection"); break; case INT_PAR__last_line_fit: print_esc_cstr("lastlinefit"); break; case INT_PAR__saving_vdiscards: print_esc_cstr("savingvdiscards"); break; case INT_PAR__saving_hyph_codes: print_esc_cstr("savinghyphcodes"); break; case INT_PAR__suppress_fontnotfound_error: print_esc_cstr("suppressfontnotfounderror"); break; case INT_PAR__texxet: print_esc_cstr("TeXXeTstate"); break; case INT_PAR__xetex_upwards: print_esc_cstr("XeTeXupwardsmode"); break; case INT_PAR__xetex_use_glyph_metrics: print_esc_cstr("XeTeXuseglyphmetrics"); break; case INT_PAR__xetex_inter_char_tokens: print_esc_cstr("XeTeXinterchartokenstate"); break; case INT_PAR__xetex_dash_break: print_esc_cstr("XeTeXdashbreakstate"); break; case INT_PAR__xetex_input_normalization: print_esc_cstr("XeTeXinputnormalization"); break; case INT_PAR__xetex_tracing_fonts: print_esc_cstr("XeTeXtracingfonts"); break; case INT_PAR__xetex_interword_space_shaping: print_esc_cstr("XeTeXinterwordspaceshaping"); break; case INT_PAR__xetex_generate_actual_text: print_esc_cstr("XeTeXgenerateactualtext"); break; case INT_PAR__xetex_hyphenatable_length: print_esc_cstr("XeTeXhyphenatablelength"); break; case INT_PAR__pdfoutput: print_esc_cstr("pdfoutput"); break; default: print_cstr("[unknown int32_t parameter!]"); break; } } void begin_diagnostic(void) { old_setting = selector; if (INTPAR(tracing_online) <= 0 && selector == SELECTOR_TERM_AND_LOG) { selector--; if (history == HISTORY_SPOTLESS) history = HISTORY_WARNING_ISSUED; } } void end_diagnostic(bool blank_line) { print_nl_cstr(""); if (blank_line) print_ln(); selector = old_setting; } void print_length_param(int32_t n) { switch (n) { case DIMEN_PAR__par_indent: print_esc_cstr("parindent"); break; case DIMEN_PAR__math_surround: print_esc_cstr("mathsurround"); break; case DIMEN_PAR__line_skip_limit: print_esc_cstr("lineskiplimit"); break; case DIMEN_PAR__hsize: print_esc_cstr("hsize"); break; case DIMEN_PAR__vsize: print_esc_cstr("vsize"); break; case DIMEN_PAR__max_depth: print_esc_cstr("maxdepth"); break; case DIMEN_PAR__split_max_depth: print_esc_cstr("splitmaxdepth"); break; case DIMEN_PAR__box_max_depth: print_esc_cstr("boxmaxdepth"); break; case DIMEN_PAR__hfuzz: print_esc_cstr("hfuzz"); break; case DIMEN_PAR__vfuzz: print_esc_cstr("vfuzz"); break; case DIMEN_PAR__delimiter_shortfall: print_esc_cstr("delimitershortfall"); break; case DIMEN_PAR__null_delimiter_space: print_esc_cstr("nulldelimiterspace"); break; case DIMEN_PAR__script_space: print_esc_cstr("scriptspace"); break; case DIMEN_PAR__pre_display_size: print_esc_cstr("predisplaysize"); break; case DIMEN_PAR__display_width: print_esc_cstr("displaywidth"); break; case DIMEN_PAR__display_indent: print_esc_cstr("displayindent"); break; case DIMEN_PAR__overfull_rule: print_esc_cstr("overfullrule"); break; case DIMEN_PAR__hang_indent: print_esc_cstr("hangindent"); break; case DIMEN_PAR__h_offset: print_esc_cstr("hoffset"); break; case DIMEN_PAR__v_offset: print_esc_cstr("voffset"); break; case DIMEN_PAR__emergency_stretch: print_esc_cstr("emergencystretch"); break; case DIMEN_PAR__pdf_page_width: print_esc_cstr("pdfpagewidth"); break; case DIMEN_PAR__pdf_page_height: print_esc_cstr("pdfpageheight"); break; default: print_cstr("[unknown dimen parameter!]"); break; } } void print_cmd_chr(uint16_t cmd, int32_t chr_code) { int32_t n; str_number font_name_str; UTF16_code quote_char; switch (cmd) { case LEFT_BRACE: print_cstr("begin-group character "); if (chr_code < 65536L) print(chr_code); else print_char(chr_code); break; case RIGHT_BRACE: print_cstr("end-group character "); if (chr_code < 65536L) print(chr_code); else print_char(chr_code); break; case MATH_SHIFT: print_cstr("math shift character "); if (chr_code < 65536L) print(chr_code); else print_char(chr_code); break; case MAC_PARAM: print_cstr("macro parameter character "); if (chr_code < 65536L) print(chr_code); else print_char(chr_code); break; case SUP_MARK: print_cstr("superscript character "); if (chr_code < 65536L) print(chr_code); else print_char(chr_code); break; case SUB_MARK: print_cstr("subscript character "); if (chr_code < 65536L) print(chr_code); else print_char(chr_code); break; case ENDV: print_cstr("end of alignment template"); break; case SPACER: print_cstr("blank space "); if (chr_code < 65536L) print(chr_code); else print_char(chr_code); break; case LETTER: print_cstr("the letter "); if (chr_code < 65536L) print(chr_code); else print_char(chr_code); break; case OTHER_CHAR: print_cstr("the character "); if (chr_code < 65536L) print(chr_code); else print_char(chr_code); break; case ASSIGN_GLUE: case ASSIGN_MU_GLUE: if (chr_code < SKIP_BASE) { print_skip_param(chr_code - GLUE_BASE); } else if (chr_code < MU_SKIP_BASE) { print_esc_cstr("skip"); print_int(chr_code - SKIP_BASE); } else { print_esc_cstr("muskip"); print_int(chr_code - MU_SKIP_BASE); } break; case ASSIGN_TOKS: if (chr_code >= TOKS_BASE) { print_esc_cstr("toks"); print_int(chr_code - TOKS_BASE); } else { switch (chr_code) { case LOCAL_BASE + LOCAL__output_routine: print_esc_cstr("output"); break; case LOCAL_BASE + LOCAL__every_par: print_esc_cstr("everypar"); break; case LOCAL_BASE + LOCAL__every_math: print_esc_cstr("everymath"); break; case LOCAL_BASE + LOCAL__every_display: print_esc_cstr("everydisplay"); break; case LOCAL_BASE + LOCAL__every_hbox: print_esc_cstr("everyhbox"); break; case LOCAL_BASE + LOCAL__every_vbox: print_esc_cstr("everyvbox"); break; case LOCAL_BASE + LOCAL__every_job: print_esc_cstr("everyjob"); break; case LOCAL_BASE + LOCAL__every_cr: print_esc_cstr("everycr"); break; case LOCAL_BASE + LOCAL__every_eof: print_esc_cstr("everyeof"); break; case LOCAL_BASE + LOCAL__xetex_inter_char_toks: print_esc_cstr("XeTeXinterchartoks"); break; case LOCAL_BASE + LOCAL__tectonic_coda_tokens: print_esc_cstr("TectonicCodaTokens"); break; default: print_esc_cstr("errhelp"); break; } } break; case ASSIGN_INT: if (chr_code < COUNT_BASE) { print_param(chr_code - INT_BASE); } else { print_esc_cstr("count"); print_int(chr_code - COUNT_BASE); } break; case ASSIGN_DIMEN: if (chr_code < SCALED_BASE) { print_length_param(chr_code - DIMEN_BASE); } else { print_esc_cstr("dimen"); print_int(chr_code - SCALED_BASE); } break; case ACCENT: print_esc_cstr("accent"); break; case ADVANCE: print_esc_cstr("advance"); break; case AFTER_ASSIGNMENT: print_esc_cstr("afterassignment"); break; case AFTER_GROUP: print_esc_cstr("aftergroup"); break; case ASSIGN_FONT_DIMEN: print_esc_cstr("fontdimen"); break; case BEGIN_GROUP: print_esc_cstr("begingroup"); break; case BREAK_PENALTY: print_esc_cstr("penalty"); break; case CHAR_NUM: print_esc_cstr("char"); break; case CS_NAME: print_esc_cstr("csname"); break; case DEF_FONT: print_esc_cstr("font"); break; case DELIM_NUM: if (chr_code == 1) print_esc_cstr("Udelimiter"); else print_esc_cstr("delimiter"); break; case DIVIDE: print_esc_cstr("divide"); break; case END_CS_NAME: print_esc_cstr("endcsname"); break; case END_GROUP: print_esc_cstr("endgroup"); break; case EX_SPACE: print_esc(' ' ); break; case EXPAND_AFTER: if (chr_code == 0) print_esc_cstr("expandafter"); else print_esc_cstr("unless"); break; case HALIGN: print_esc_cstr("halign"); break; case HRULE: print_esc_cstr("hrule"); break; case IGNORE_SPACES: if (chr_code == 0) print_esc_cstr("ignorespaces"); else print_esc_cstr("primitive"); break; case INSERT: print_esc_cstr("insert"); break; case ITAL_CORR: print_esc('/' ); break; case MARK: print_esc_cstr("mark"); if (chr_code > 0) print_char('s'); break; case MATH_ACCENT: if (chr_code == 1) print_esc_cstr("Umathaccent"); else print_esc_cstr("mathaccent"); break; case MATH_CHAR_NUM: if (chr_code == 2) print_esc_cstr("Umathchar"); else if (chr_code == 1) print_esc_cstr("Umathcharnum"); else print_esc_cstr("mathchar"); break; case MATH_CHOICE: print_esc_cstr("mathchoice"); break; case MULTIPLY: print_esc_cstr("multiply"); break; case NO_ALIGN: print_esc_cstr("noalign"); break; case NO_BOUNDARY: print_esc_cstr("noboundary"); break; case NO_EXPAND: if (chr_code == 0) print_esc_cstr("noexpand"); else print_esc_cstr("primitive"); break; case NON_SCRIPT: print_esc_cstr("nonscript"); break; case OMIT: print_esc_cstr("omit"); break; case RADICAL: if (chr_code == 1) print_esc_cstr("Uradical"); else print_esc_cstr("radical"); break; case READ_TO_CS: if (chr_code == 0) print_esc_cstr("read"); else print_esc_cstr("readline"); break; case RELAX: print_esc_cstr("relax"); break; case SET_BOX: print_esc_cstr("setbox"); break; case SET_PREV_GRAF: print_esc_cstr("prevgraf"); break; case SET_SHAPE: switch (chr_code) { case LOCAL_BASE + LOCAL__par_shape: print_esc_cstr("parshape"); break; case ETEX_PEN_BASE + ETEX_PENALTIES_PAR__inter_line_penalties: print_esc_cstr("interlinepenalties"); break; case ETEX_PEN_BASE + ETEX_PENALTIES_PAR__club_penalties: print_esc_cstr("clubpenalties"); break; case ETEX_PEN_BASE + ETEX_PENALTIES_PAR__widow_penalties: print_esc_cstr("widowpenalties"); break; case ETEX_PEN_BASE + ETEX_PENALTIES_PAR__display_widow_penalties: print_esc_cstr("displaywidowpenalties"); break; } break; case THE: if (chr_code == 0) print_esc_cstr("the"); else if (chr_code == 1) print_esc_cstr("unexpanded"); else print_esc_cstr("detokenize"); break; case TOKS_REGISTER: print_esc_cstr("toks"); if (chr_code != 0) print_sa_num(chr_code); break; case VADJUST: print_esc_cstr("vadjust"); break; case VALIGN: if (chr_code == 0) { print_esc_cstr("valign"); } else { switch (chr_code) { case BEGIN_L_CODE: print_esc_cstr("beginL"); break; case END_L_CODE: print_esc_cstr("endL"); break; case BEGIN_R_CODE: print_esc_cstr("beginR"); break; default: print_esc_cstr("endR"); break; } } break; case VCENTER: print_esc_cstr("vcenter"); break; case VRULE: print_esc_cstr("vrule"); break; case PAR_END: print_esc_cstr("par"); break; case INPUT: if (chr_code == 0) print_esc_cstr("input"); else if (chr_code == 2) print_esc_cstr("scantokens"); else print_esc_cstr("endinput"); break; case TOP_BOT_MARK: switch (chr_code % MARKS_CODE) { case FIRST_MARK_CODE: print_esc_cstr("firstmark"); break; case BOT_MARK_CODE: print_esc_cstr("botmark"); break; case SPLIT_FIRST_MARK_CODE: print_esc_cstr("splitfirstmark"); break; case SPLIT_BOT_MARK_CODE: print_esc_cstr("splitbotmark"); break; default: print_esc_cstr("topmark"); break; } if (chr_code >= MARKS_CODE) print_char('s'); break; case REGISTER: if (chr_code < 0 || chr_code > 19 /*lo_mem_stat_max*/) { cmd = (mem[chr_code].b16.s1 / 64); } else { cmd = chr_code; chr_code = TEX_NULL; } if (cmd == INT_VAL) print_esc_cstr("count"); else if (cmd == DIMEN_VAL) print_esc_cstr("dimen"); else if (cmd == GLUE_VAL) print_esc_cstr("skip"); else print_esc_cstr("muskip"); if (chr_code != TEX_NULL) print_sa_num(chr_code); break; case SET_AUX: if (chr_code == VMODE) print_esc_cstr("prevdepth"); else print_esc_cstr("spacefactor"); break; case SET_PAGE_INT: if (chr_code == 0) print_esc_cstr("deadcycles"); else if (chr_code == 2) print_esc_cstr("interactionmode"); else print_esc_cstr("insertpenalties"); break; case SET_BOX_DIMEN: if (chr_code == WIDTH_OFFSET) print_esc_cstr("wd"); else if (chr_code == HEIGHT_OFFSET) print_esc_cstr("ht"); else print_esc_cstr("dp"); break; case LAST_ITEM: switch (chr_code) { case INT_VAL: print_esc_cstr("lastpenalty"); break; case DIMEN_VAL: print_esc_cstr("lastkern"); break; case GLUE_VAL: print_esc_cstr("lastskip"); break; case INPUT_LINE_NO_CODE: print_esc_cstr("inputlineno"); break; case LAST_NODE_TYPE_CODE: print_esc_cstr("lastnodetype"); break; case ETEX_VERSION_CODE: print_esc_cstr("eTeXversion"); break; case XETEX_VERSION_CODE: print_esc_cstr("XeTeXversion"); break; case XETEX_COUNT_GLYPHS_CODE: print_esc_cstr("XeTeXcountglyphs"); break; case XETEX_COUNT_VARIATIONS_CODE: print_esc_cstr("XeTeXcountvariations"); break; case XETEX_VARIATION_CODE: print_esc_cstr("XeTeXvariation"); break; case XETEX_FIND_VARIATION_BY_NAME_CODE: print_esc_cstr("XeTeXfindvariationbyname"); break; case XETEX_VARIATION_MIN_CODE: print_esc_cstr("XeTeXvariationmin"); break; case XETEX_VARIATION_MAX_CODE: print_esc_cstr("XeTeXvariationmax"); break; case XETEX_VARIATION_DEFAULT_CODE: print_esc_cstr("XeTeXvariationdefault"); break; case XETEX_COUNT_FEATURES_CODE: print_esc_cstr("XeTeXcountfeatures"); break; case XETEX_FEATURE_CODE_CODE: print_esc_cstr("XeTeXfeaturecode"); break; case XETEX_FIND_FEATURE_BY_NAME_CODE: print_esc_cstr("XeTeXfindfeaturebyname"); break; case XETEX_IS_EXCLUSIVE_FEATURE_CODE: print_esc_cstr("XeTeXisexclusivefeature"); break; case XETEX_COUNT_SELECTORS_CODE: print_esc_cstr("XeTeXcountselectors"); break; case XETEX_SELECTOR_CODE_CODE: print_esc_cstr("XeTeXselectorcode"); break; case XETEX_FIND_SELECTOR_BY_NAME_CODE: print_esc_cstr("XeTeXfindselectorbyname"); break; case XETEX_IS_DEFAULT_SELECTOR_CODE: print_esc_cstr("XeTeXisdefaultselector"); break; case XETEX_OT_COUNT_SCRIPTS_CODE: print_esc_cstr("XeTeXOTcountscripts"); break; case XETEX_OT_COUNT_LANGUAGES_CODE: print_esc_cstr("XeTeXOTcountlanguages"); break; case XETEX_OT_COUNT_FEATURES_CODE: print_esc_cstr("XeTeXOTcountfeatures"); break; case XETEX_OT_SCRIPT_CODE: print_esc_cstr("XeTeXOTscripttag"); break; case XETEX_OT_LANGUAGE_CODE: print_esc_cstr("XeTeXOTlanguagetag"); break; case XETEX_OT_FEATURE_CODE: print_esc_cstr("XeTeXOTfeaturetag"); break; case XETEX_MAP_CHAR_TO_GLYPH_CODE: print_esc_cstr("XeTeXcharglyph"); break; case XETEX_GLYPH_INDEX_CODE: print_esc_cstr("XeTeXglyphindex"); break; case XETEX_GLYPH_BOUNDS_CODE: print_esc_cstr("XeTeXglyphbounds"); break; case XETEX_FONT_TYPE_CODE: print_esc_cstr("XeTeXfonttype"); break; case XETEX_FIRST_CHAR_CODE: print_esc_cstr("XeTeXfirstfontchar"); break; case XETEX_LAST_CHAR_CODE: print_esc_cstr("XeTeXlastfontchar"); break; case XETEX_PDF_PAGE_COUNT_CODE: print_esc_cstr("XeTeXpdfpagecount"); break; case CURRENT_GROUP_LEVEL_CODE: print_esc_cstr("currentgrouplevel"); break; case CURRENT_GROUP_TYPE_CODE: print_esc_cstr("currentgrouptype"); break; case CURRENT_IF_LEVEL_CODE: print_esc_cstr("currentiflevel"); break; case CURRENT_IF_TYPE_CODE: print_esc_cstr("currentiftype"); break; case CURRENT_IF_BRANCH_CODE: print_esc_cstr("currentifbranch"); break; case FONT_CHAR_WD_CODE: print_esc_cstr("fontcharwd"); break; case FONT_CHAR_HT_CODE: print_esc_cstr("fontcharht"); break; case FONT_CHAR_DP_CODE: print_esc_cstr("fontchardp"); break; case FONT_CHAR_IC_CODE: print_esc_cstr("fontcharic"); break; case PAR_SHAPE_LENGTH_CODE: print_esc_cstr("parshapelength"); break; case PAR_SHAPE_INDENT_CODE: print_esc_cstr("parshapeindent"); break; case PAR_SHAPE_DIMEN_CODE: print_esc_cstr("parshapedimen"); break; case (ETEX_EXPR - INT_VAL + INT_VAL): print_esc_cstr("numexpr"); break; case (ETEX_EXPR - INT_VAL + DIMEN_VAL): print_esc_cstr("dimexpr"); break; case (ETEX_EXPR - INT_VAL + GLUE_VAL): print_esc_cstr("glueexpr"); break; case (ETEX_EXPR - INT_VAL + MU_VAL): print_esc_cstr("muexpr"); break; case GLUE_STRETCH_ORDER_CODE: print_esc_cstr("gluestretchorder"); break; case GLUE_SHRINK_ORDER_CODE: print_esc_cstr("glueshrinkorder"); break; case GLUE_STRETCH_CODE: print_esc_cstr("gluestretch"); break; case GLUE_SHRINK_CODE: print_esc_cstr("glueshrink"); break; case MU_TO_GLUE_CODE: print_esc_cstr("mutoglue"); break; case GLUE_TO_MU_CODE: print_esc_cstr("gluetomu"); break; case PDF_LAST_X_POS_CODE: print_esc_cstr("pdflastxpos"); break; case PDF_LAST_Y_POS_CODE: print_esc_cstr("pdflastypos"); break; case ELAPSED_TIME_CODE: print_esc_cstr("elapsedtime"); break; case PDF_SHELL_ESCAPE_CODE: print_esc_cstr("shellescape"); break; case RANDOM_SEED_CODE: print_esc_cstr("randomseed"); break; default: print_esc_cstr("badness"); break; } break; case CONVERT: switch (chr_code) { case NUMBER_CODE: print_esc_cstr("number"); break; case ROMAN_NUMERAL_CODE: print_esc_cstr("romannumeral"); break; case STRING_CODE: print_esc_cstr("string"); break; case MEANING_CODE: print_esc_cstr("meaning"); break; case FONT_NAME_CODE: print_esc_cstr("fontname"); break; case ETEX_REVISION_CODE: print_esc_cstr("eTeXrevision"); break; case EXPANDED_CODE: print_esc_cstr("expanded"); break; case LEFT_MARGIN_KERN_CODE: print_esc_cstr("leftmarginkern"); break; case RIGHT_MARGIN_KERN_CODE: print_esc_cstr("rightmarginkern"); break; case PDF_CREATION_DATE_CODE: print_esc_cstr("creationdate"); break; case PDF_FILE_MOD_DATE_CODE: print_esc_cstr("filemoddate"); break; case PDF_FILE_SIZE_CODE: print_esc_cstr("filesize"); break; case PDF_MDFIVE_SUM_CODE: print_esc_cstr("mdfivesum"); break; case PDF_FILE_DUMP_CODE: print_esc_cstr("filedump"); break; case PDF_STRCMP_CODE: print_esc_cstr("strcmp"); break; case UNIFORM_DEVIATE_CODE: print_esc_cstr("uniformdeviate"); break; case NORMAL_DEVIATE_CODE: print_esc_cstr("normaldeviate"); break; case XETEX_REVISION_CODE: print_esc_cstr("XeTeXrevision"); break; case XETEX_VARIATION_NAME_CODE: print_esc_cstr("XeTeXvariationname"); break; case XETEX_FEATURE_NAME_CODE: print_esc_cstr("XeTeXfeaturename"); break; case XETEX_SELECTOR_NAME_CODE: print_esc_cstr("XeTeXselectorname"); break; case XETEX_GLYPH_NAME_CODE: print_esc_cstr("XeTeXglyphname"); break; case XETEX_UCHAR_CODE: print_esc_cstr("Uchar"); break; case XETEX_UCHARCAT_CODE: print_esc_cstr("Ucharcat"); break; default: print_esc_cstr("jobname"); break; } break; case IF_TEST: if (chr_code >= UNLESS_CODE) print_esc_cstr("unless"); switch (chr_code % UNLESS_CODE) { case IF_CAT_CODE: print_esc_cstr("ifcat"); break; case IF_INT_CODE: print_esc_cstr("ifnum"); break; case IF_DIM_CODE: print_esc_cstr("ifdim"); break; case IF_ODD_CODE: print_esc_cstr("ifodd"); break; case IF_VMODE_CODE: print_esc_cstr("ifvmode"); break; case IF_HMODE_CODE: print_esc_cstr("ifhmode"); break; case IF_MMODE_CODE: print_esc_cstr("ifmmode"); break; case IF_INNER_CODE: print_esc_cstr("ifinner"); break; case IF_VOID_CODE: print_esc_cstr("ifvoid"); break; case IF_HBOX_CODE: print_esc_cstr("ifhbox"); break; case IF_VBOX_CODE: print_esc_cstr("ifvbox"); break; case IFX_CODE: print_esc_cstr("ifx"); break; case IF_EOF_CODE: print_esc_cstr("ifeof"); break; case IF_TRUE_CODE: print_esc_cstr("iftrue"); break; case IF_FALSE_CODE: print_esc_cstr("iffalse"); break; case IF_CASE_CODE: print_esc_cstr("ifcase"); break; case IF_PRIMITIVE_CODE: print_esc_cstr("ifprimitive"); break; case IF_DEF_CODE: print_esc_cstr("ifdefined"); break; case IF_CS_CODE: print_esc_cstr("ifcsname"); break; case IF_FONT_CHAR_CODE: print_esc_cstr("iffontchar"); break; case IF_IN_CSNAME_CODE: print_esc_cstr("ifincsname"); break; default: print_esc_cstr("if"); break; } break; case FI_OR_ELSE: if (chr_code == FI_CODE) print_esc_cstr("fi"); else if (chr_code == OR_CODE) print_esc_cstr("or"); else print_esc_cstr("else"); break; case TAB_MARK: if (chr_code == SPAN_CODE) { print_esc_cstr("span"); } else { print_cstr("alignment tab character "); if (chr_code < 65536L) print(chr_code); else print_char(chr_code); } break; case CAR_RET: if (chr_code == CR_CODE) print_esc_cstr("cr"); else print_esc_cstr("crcr"); break; case SET_PAGE_DIMEN: switch (chr_code) { case 0: /* genuine literal in WEB */ print_esc_cstr("pagegoal"); break; case 1: /* genuine literal in WEB */ print_esc_cstr("pagetotal"); break; case 2: /* genuine literal in WEB */ print_esc_cstr("pagestretch"); break; case 3: /* genuine literal in WEB */ print_esc_cstr("pagefilstretch"); break; case 4: /* genuine literal in WEB */ print_esc_cstr("pagefillstretch"); break; case 5: /* genuine literal in WEB */ print_esc_cstr("pagefilllstretch"); break; case 6: /* genuine literal in WEB */ print_esc_cstr("pageshrink"); break; default: print_esc_cstr("pagedepth"); break; } break; case STOP: if (chr_code == 1) print_esc_cstr("dump"); else print_esc_cstr("end"); break; case HSKIP: switch (chr_code) { case SKIP_CODE: print_esc_cstr("hskip"); break; case FIL_CODE: print_esc_cstr("hfil"); break; case FILL_CODE: print_esc_cstr("hfill"); break; case SS_CODE: print_esc_cstr("hss"); break; default: print_esc_cstr("hfilneg"); break; } break; case VSKIP: switch (chr_code) { case SKIP_CODE: print_esc_cstr("vskip"); break; case FIL_CODE: print_esc_cstr("vfil"); break; case FILL_CODE: print_esc_cstr("vfill"); break; case SS_CODE: print_esc_cstr("vss"); break; default: print_esc_cstr("vfilneg"); break; } break; case MSKIP: print_esc_cstr("mskip"); break; case KERN: print_esc_cstr("kern"); break; case MKERN: print_esc_cstr("mkern"); break; case HMOVE: if (chr_code == 1) print_esc_cstr("moveleft"); else print_esc_cstr("moveright"); break; case VMOVE: if (chr_code == 1) print_esc_cstr("raise"); else print_esc_cstr("lower"); break; case MAKE_BOX: switch (chr_code) { case BOX_CODE: print_esc_cstr("box"); break; case COPY_CODE: print_esc_cstr("copy"); break; case LAST_BOX_CODE: print_esc_cstr("lastbox"); break; case VSPLIT_CODE: print_esc_cstr("vsplit"); break; case VTOP_CODE: print_esc_cstr("vtop"); break; case (VTOP_CODE + VMODE): print_esc_cstr("vbox"); break; default: print_esc_cstr("hbox"); break; } break; case LEADER_SHIP: if (chr_code == A_LEADERS) print_esc_cstr("leaders"); else if (chr_code == C_LEADERS) print_esc_cstr("cleaders"); else if (chr_code == X_LEADERS) print_esc_cstr("xleaders"); else print_esc_cstr("shipout"); break; case START_PAR: if (chr_code == 0) print_esc_cstr("noindent"); else print_esc_cstr("indent"); break; case REMOVE_ITEM: if (chr_code == GLUE_NODE) print_esc_cstr("unskip"); else if (chr_code == KERN_NODE) print_esc_cstr("unkern"); else print_esc_cstr("unpenalty"); break; case UN_HBOX: if (chr_code == COPY_CODE) print_esc_cstr("unhcopy"); else print_esc_cstr("unhbox"); break; case UN_VBOX: if (chr_code == COPY_CODE) print_esc_cstr("unvcopy"); else if (chr_code == LAST_BOX_CODE) print_esc_cstr("pagediscards"); else if (chr_code == VSPLIT_CODE) print_esc_cstr("splitdiscards"); else print_esc_cstr("unvbox"); break; case DISCRETIONARY: if (chr_code == 1) print_esc('-' ); else print_esc_cstr("discretionary"); break; case EQ_NO: if (chr_code == 1) print_esc_cstr("leqno"); else print_esc_cstr("eqno"); break; case MATH_COMP: switch (chr_code) { case ORD_NOAD: print_esc_cstr("mathord"); break; case OP_NOAD: print_esc_cstr("mathop"); break; case BIN_NOAD: print_esc_cstr("mathbin"); break; case REL_NOAD: print_esc_cstr("mathrel"); break; case OPEN_NOAD: print_esc_cstr("mathopen"); break; case CLOSE_NOAD: print_esc_cstr("mathclose"); break; case PUNCT_NOAD: print_esc_cstr("mathpunct"); break; case INNER_NOAD: print_esc_cstr("mathinner"); break; case UNDER_NOAD: print_esc_cstr("underline"); break; default: print_esc_cstr("overline"); break; } break; case LIMIT_SWITCH: if (chr_code == LIMITS) print_esc_cstr("limits"); else if (chr_code == NO_LIMITS) print_esc_cstr("nolimits"); else print_esc_cstr("displaylimits"); break; case MATH_STYLE: print_style(chr_code); break; case ABOVE: switch (chr_code) { case OVER_CODE: print_esc_cstr("over"); break; case ATOP_CODE: print_esc_cstr("atop"); break; case DELIMITED_CODE + ABOVE_CODE: print_esc_cstr("abovewithdelims"); break; case DELIMITED_CODE + OVER_CODE: print_esc_cstr("overwithdelims"); break; case DELIMITED_CODE + ATOP_CODE: print_esc_cstr("atopwithdelims"); break; default: print_esc_cstr("above"); break; } break; case LEFT_RIGHT: if (chr_code == LEFT_NOAD) print_esc_cstr("left"); else if (chr_code == MIDDLE_NOAD) print_esc_cstr("middle"); else print_esc_cstr("right"); break; case PREFIX: if (chr_code == 1) print_esc_cstr("long"); else if (chr_code == 2) print_esc_cstr("outer"); else if (chr_code == 8) print_esc_cstr("protected"); else print_esc_cstr("global"); break; case DEF: if (chr_code == 0) print_esc_cstr("def"); else if (chr_code == 1) print_esc_cstr("gdef"); else if (chr_code == 2) print_esc_cstr("edef"); else print_esc_cstr("xdef"); break; case LET: if (chr_code != NORMAL) print_esc_cstr("futurelet"); else print_esc_cstr("let"); break; case SHORTHAND_DEF: switch (chr_code) { case CHAR_DEF_CODE: print_esc_cstr("chardef"); break; case MATH_CHAR_DEF_CODE: print_esc_cstr("mathchardef"); break; case XETEX_MATH_CHAR_DEF_CODE: print_esc_cstr("Umathchardef"); break; case XETEX_MATH_CHAR_NUM_DEF_CODE: print_esc_cstr("Umathcharnumdef"); break; case COUNT_DEF_CODE: print_esc_cstr("countdef"); break; case DIMEN_DEF_CODE: print_esc_cstr("dimendef"); break; case SKIP_DEF_CODE: print_esc_cstr("skipdef"); break; case MU_SKIP_DEF_CODE: print_esc_cstr("muskipdef"); break; case CHAR_SUB_DEF_CODE: print_esc_cstr("charsubdef"); break; default: print_esc_cstr("toksdef"); break; } break; case CHAR_GIVEN: print_esc_cstr("char"); print_hex(chr_code); break; case MATH_GIVEN: print_esc_cstr("mathchar"); print_hex(chr_code); break; case XETEX_MATH_GIVEN: print_esc_cstr("Umathchar"); print_hex(math_class(chr_code)); print_hex(math_fam(chr_code)); print_hex(math_char(chr_code)); break; case DEF_CODE: if (chr_code == CAT_CODE_BASE) print_esc_cstr("catcode"); else if (chr_code == MATH_CODE_BASE) print_esc_cstr("mathcode"); else if (chr_code == LC_CODE_BASE) print_esc_cstr("lccode"); else if (chr_code == UC_CODE_BASE) print_esc_cstr("uccode"); else if (chr_code == SF_CODE_BASE) print_esc_cstr("sfcode"); else print_esc_cstr("delcode"); break; case XETEX_DEF_CODE: if (chr_code == SF_CODE_BASE) print_esc_cstr("XeTeXcharclass"); else if (chr_code == MATH_CODE_BASE) print_esc_cstr("Umathcodenum"); else if (chr_code == (MATH_CODE_BASE + 1)) print_esc_cstr("Umathcode"); else if (chr_code == DEL_CODE_BASE) print_esc_cstr("Udelcodenum"); else print_esc_cstr("Udelcode"); break; case DEF_FAMILY: print_size(chr_code - MATH_FONT_BASE); break; case HYPH_DATA: if (chr_code == 1) print_esc_cstr("patterns"); else print_esc_cstr("hyphenation"); break; case ASSIGN_FONT_INT: switch (chr_code) { case 0: print_esc_cstr("hyphenchar"); break; case 1: print_esc_cstr("skewchar"); break; case LP_CODE_BASE: print_esc_cstr("lpcode"); break; case RP_CODE_BASE: print_esc_cstr("rpcode"); break; } break; case SET_FONT: print_cstr("select font "); font_name_str = font_name[chr_code]; if (font_area[chr_code] == AAT_FONT_FLAG || font_area[chr_code] == OTGR_FONT_FLAG) { int32_t for_end = length(font_name_str) - 1; quote_char = '"' ; for (n = 0; n <= for_end; n++) { if (str_pool[str_start[(font_name_str) - 65536L] + n] == '"' ) quote_char = '\'' ; } print_char(quote_char); print(font_name_str); print_char(quote_char); } else { print(font_name_str); } if (font_size[chr_code] != font_dsize[chr_code]) { print_cstr(" at "); print_scaled(font_size[chr_code]); print_cstr("pt"); } break; case SET_INTERACTION: switch (chr_code) { case BATCH_MODE: print_esc_cstr("batchmode"); break; case NONSTOP_MODE: print_esc_cstr("nonstopmode"); break; case SCROLL_MODE: print_esc_cstr("scrollmode"); break; default: print_esc_cstr("errorstopmode"); break; } break; case IN_STREAM: if (chr_code == 0) print_esc_cstr("closein"); else print_esc_cstr("openin"); break; case MESSAGE: if (chr_code == 0) print_esc_cstr("message"); else print_esc_cstr("errmessage"); break; case CASE_SHIFT: if (chr_code == LC_CODE_BASE) print_esc_cstr("lowercase"); else print_esc_cstr("uppercase"); break; case XRAY: switch (chr_code) { case SHOW_BOX_CODE: print_esc_cstr("showbox"); break; case SHOW_THE_CODE: print_esc_cstr("showthe"); break; case SHOW_LISTS: print_esc_cstr("showlists"); break; case SHOW_GROUPS: print_esc_cstr("showgroups"); break; case SHOW_TOKENS: print_esc_cstr("showtokens"); break; case SHOW_IFS: print_esc_cstr("showifs"); break; default: print_esc_cstr("show"); break; } break; case UNDEFINED_CS: print_cstr("undefined"); break; case CALL: case LONG_CALL: case OUTER_CALL: case LONG_OUTER_CALL: n = cmd - CALL; if (mem[mem[chr_code].b32.s1].b32.s0 == PROTECTED_TOKEN) n = n + 4; if (odd(n / 4)) print_esc_cstr("protected"); if (odd(n)) print_esc_cstr("long"); if (odd(n / 2)) print_esc_cstr("outer"); if (n > 0) print_char(' '); print_cstr("macro"); break; case END_TEMPLATE: print_esc_cstr("outer endtemplate"); break; case EXTENSION: switch (chr_code) { case OPEN_NODE: print_esc_cstr("openout"); break; case WRITE_NODE: print_esc_cstr("write"); break; case CLOSE_NODE: print_esc_cstr("closeout"); break; case SPECIAL_NODE: print_esc_cstr("special"); break; case IMMEDIATE_CODE: print_esc_cstr("immediate"); break; case SET_LANGUAGE_CODE: print_esc_cstr("setlanguage"); break; case PDF_SAVE_POS_NODE: print_esc_cstr("pdfsavepos"); break; case RESET_TIMER_CODE: print_esc_cstr("resettimer"); break; case SET_RANDOM_SEED_CODE: print_esc_cstr("setrandomseed"); break; case PIC_FILE_CODE: print_esc_cstr("XeTeXpicfile"); break; case PDF_FILE_CODE: print_esc_cstr("XeTeXpdffile"); break; case GLYPH_CODE: print_esc_cstr("XeTeXglyph"); break; case XETEX_LINEBREAK_LOCALE_EXTENSION_CODE: print_esc_cstr("XeTeXlinebreaklocale"); break; case XETEX_INPUT_ENCODING_EXTENSION_CODE: print_esc_cstr("XeTeXinputencoding"); break; case XETEX_DEFAULT_ENCODING_EXTENSION_CODE: print_esc_cstr("XeTeXdefaultencoding"); break; default: print_cstr("[unknown extension!]"); break; } break; default: print_cstr("[unknown command code!]"); break; } } void not_aat_font_error(int32_t cmd, int32_t c, int32_t f) { error_here_with_diagnostic("Cannot use "); print_cmd_chr(cmd, c); print_cstr(" with "); print(font_name[f]); print_cstr("; not an AAT font"); capture_to_diagnostic(NULL); error(); } void not_aat_gr_font_error(int32_t cmd, int32_t c, int32_t f) { error_here_with_diagnostic("Cannot use "); print_cmd_chr(cmd, c); print_cstr(" with "); print(font_name[f]); print_cstr("; not an AAT or Graphite font"); capture_to_diagnostic(NULL); error(); } void not_ot_font_error(int32_t cmd, int32_t c, int32_t f) { error_here_with_diagnostic("Cannot use "); print_cmd_chr(cmd, c); print_cstr(" with "); print(font_name[f]); print_cstr("; not an OpenType Layout font"); capture_to_diagnostic(NULL); error(); } void not_native_font_error(int32_t cmd, int32_t c, int32_t f) { error_here_with_diagnostic("Cannot use "); print_cmd_chr(cmd, c); print_cstr(" with "); print(font_name[f]); print_cstr("; not a native platform font"); capture_to_diagnostic(NULL); error(); } /*:1434*/ int32_t id_lookup(int32_t j, int32_t l) { int32_t h; int32_t d; int32_t p; int32_t k; int32_t ll; h = 0; for (k = j; k <= j + l - 1; k++) { h = h + h + buffer[k]; while (h >= HASH_PRIME) h = h - 8501; } p = h + HASH_BASE; ll = l; for (d = 0; d <= l - 1; d++) { if (buffer[j + d] >= 65536L) ll++; } while (true) { if (hash[p].s1 > 0) { if (length(hash[p].s1) == ll) { if (str_eq_buf(hash[p].s1, j)) goto found; } } if (hash[p].s0 == 0) { if (no_new_control_sequence) { p = UNDEFINED_CONTROL_SEQUENCE; } else { /*269:*/ if (hash[p].s1 > 0) { if (hash_high < hash_extra) { hash_high++; hash[p].s0 = hash_high + EQTB_SIZE; p = hash_high + EQTB_SIZE; } else { do { if (hash_used == HASH_BASE) overflow("hash size", HASH_SIZE + hash_extra); hash_used--; } while (hash[hash_used].s1 != 0); hash[p].s0 = hash_used; p = hash_used; } } if (pool_ptr + ll > pool_size) overflow("pool size", pool_size - init_pool_ptr); d = cur_length(); while (pool_ptr > str_start[str_ptr - TOO_BIG_CHAR]) { pool_ptr--; str_pool[pool_ptr + l] = str_pool[pool_ptr]; } for (k = j; k <= j + l - 1; k++) { if (buffer[k] < 65536L) { str_pool[pool_ptr] = buffer[k]; pool_ptr++; } else { str_pool[pool_ptr] = 0xD800 + (buffer[k] - 65536L) / 1024; pool_ptr++; str_pool[pool_ptr] = 0xDC00 + (buffer[k] - 65536L) % 1024; pool_ptr++; } } hash[p].s1 = make_string(); pool_ptr += d; } goto found; } p = hash[p].s0; } found: return p; } int32_t prim_lookup(str_number s) { int32_t h; int32_t p; int32_t k; int32_t j, l = 0; if (s <= BIGGEST_CHAR) { if (s < 0) { p = UNDEFINED_PRIMITIVE; goto found; } else p = (s % PRIM_PRIME) + 1; } else { j = str_start[(s) - 65536L]; if (s == str_ptr) l = (cur_length()); else l = length(s); h = str_pool[j]; { register int32_t for_end; k = j + 1; for_end = j + l - 1; if (k <= for_end) do { h = h + h + str_pool[k]; while (h >= PRIM_PRIME) h = h - PRIM_PRIME; } while (k++ < for_end); } p = h + 1; } while (true) { if (prim[p].s1 > 65536L) { if (length(prim[p].s1) - 1 == l) { if (str_eq_str(prim[p].s1 - 1, s)) goto found; } } else if (prim[p].s1 == 1 + s) goto found; if (prim[p].s0 == 0) { if (no_new_control_sequence) p = UNDEFINED_PRIMITIVE; else { /*272:*/ if (prim[p].s1 > 0) { do { if (prim_used == PRIM_BASE) overflow("primitive size", PRIM_SIZE); prim_used--; } while (!(prim[prim_used].s1 == 0)); prim[p].s0 = prim_used; p = prim_used; } prim[p].s1 = s + 1; } goto found; } p = prim[p].s0; } found: return p; } /*:276*//*280: *//*296: */ void print_group(bool e) { switch (cur_group) { case BOTTOM_LEVEL: print_cstr("bottom level"); return; case SIMPLE_GROUP: case SEMI_SIMPLE_GROUP: { if (cur_group == SEMI_SIMPLE_GROUP) print_cstr("semi "); print_cstr("simple"); } break; case HBOX_GROUP: case ADJUSTED_HBOX_GROUP: { if (cur_group == ADJUSTED_HBOX_GROUP) print_cstr("adjusted "); print_cstr("hbox"); } break; case VBOX_GROUP: print_cstr("vbox"); break; case VTOP_GROUP: print_cstr("vtop"); break; case ALIGN_GROUP: case NO_ALIGN_GROUP: { if (cur_group == NO_ALIGN_GROUP) print_cstr("no "); print_cstr("align"); } break; case OUTPUT_GROUP: print_cstr("output"); break; case DISC_GROUP: print_cstr("disc"); break; case INSERT_GROUP: print_cstr("insert"); break; case VCENTER_GROUP: print_cstr("vcenter"); break; case MATH_GROUP: case MATH_CHOICE_GROUP: case MATH_SHIFT_GROUP: case MATH_LEFT_GROUP: { print_cstr("math"); if (cur_group == MATH_CHOICE_GROUP) print_cstr(" choice"); else if (cur_group == MATH_SHIFT_GROUP) print_cstr(" shift"); else if (cur_group == MATH_LEFT_GROUP) print_cstr(" left"); } break; } print_cstr(" group (level "); print_int(cur_level); print_char(')'); if (save_stack[save_ptr - 1].b32.s1 != 0) { if (e) print_cstr(" entered at line "); else print_cstr(" at line "); print_int(save_stack[save_ptr - 1].b32.s1); } } /*:1448*//*1449: */ bool pseudo_input(void) { int32_t p; int32_t sz; b16x4 w; int32_t r; last = first; p = mem[pseudo_files].b32.s0; if (p == TEX_NULL) return false; else { mem[pseudo_files].b32.s0 = mem[p].b32.s1; sz = mem[p].b32.s0; if (4 * sz - 3 >= buf_size - last) { /*35: */ cur_input.loc = first; cur_input.limit = last - 1; overflow("buffer size", buf_size); } last = first; { register int32_t for_end; r = p + 1; for_end = p + sz - 1; if (r <= for_end) do { w = mem[r].b16; buffer[last] = w.s3; buffer[last + 1] = w.s2; buffer[last + 2] = w.s1; buffer[last + 3] = w.s0; last = last + 4; } while (r++ < for_end); } if (last >= max_buf_stack) max_buf_stack = last + 1; while ((last > first) && (buffer[last - 1] == ' ' )) last--; free_node(p, sz); return true; } } void pseudo_close(void) { int32_t p, q; p = mem[pseudo_files].b32.s1; q = mem[pseudo_files].b32.s0; { mem[pseudo_files].b32.s1 = avail; avail = pseudo_files; } pseudo_files = p; while (q != TEX_NULL) { p = q; q = mem[p].b32.s1; free_node(p, mem[p].b32.s0); } } void group_warning(void) { int32_t i; bool w; base_ptr = input_ptr; input_stack[base_ptr] = cur_input; i = in_open; w = false; while ((grp_stack[i] == cur_boundary) && (i > 0)) { if (INTPAR(tracing_nesting) > 0) { while ((input_stack[base_ptr].state == TOKEN_LIST) || (input_stack[base_ptr].index > i)) base_ptr--; if (input_stack[base_ptr].name > 17) w = true; } grp_stack[i] = save_stack[save_ptr].b32.s1; i--; } if (w) { print_nl_cstr("Warning: "); diagnostic_begin_capture_warning_here(); print_cstr("end of "); print_group(true); print_cstr(" of a different file"); print_ln(); if (INTPAR(tracing_nesting) > 1) show_context(); if (history == HISTORY_SPOTLESS) history = HISTORY_WARNING_ISSUED; capture_to_diagnostic(NULL); } } void if_warning(void) { int32_t i; bool w; base_ptr = input_ptr; input_stack[base_ptr] = cur_input; i = in_open; w = false; while (if_stack[i] == cond_ptr) { if (INTPAR(tracing_nesting) > 0) { while ((input_stack[base_ptr].state == TOKEN_LIST) || (input_stack[base_ptr].index > i)) base_ptr--; if (input_stack[base_ptr].name > 17) w = true; } if_stack[i] = mem[cond_ptr].b32.s1; i--; } if (w) { print_nl_cstr("Warning: "); diagnostic_begin_capture_warning_here(); print_cstr("end of "); print_cmd_chr(IF_TEST, cur_if); if (if_line != 0) { print_cstr(" entered on line "); print_int(if_line); } print_cstr(" of a different file"); print_ln(); if (INTPAR(tracing_nesting) > 1) show_context(); capture_to_diagnostic(NULL); if (history == HISTORY_SPOTLESS) history = HISTORY_WARNING_ISSUED; } } void file_warning(void) { int32_t p; uint16_t l; uint16_t c; int32_t i; p = save_ptr; l = cur_level; c = cur_group; save_ptr = cur_boundary; while (grp_stack[in_open] != save_ptr) { cur_level--; print_nl_cstr("Warning: "); diagnostic_begin_capture_warning_here(); print_cstr("end of file when "); print_group(true); print_cstr(" is incomplete"); capture_to_diagnostic(NULL); cur_group = save_stack[save_ptr].b16.s0; save_ptr = save_stack[save_ptr].b32.s1; } save_ptr = p; cur_level = l; cur_group = c; p = cond_ptr; l = if_limit; c = cur_if; i = if_line; while (if_stack[in_open] != cond_ptr) { print_nl_cstr("Warning: "); diagnostic_begin_capture_warning_here(); print_cstr("end of file when "); print_cmd_chr(IF_TEST, cur_if); if (if_limit == FI_CODE) print_esc_cstr("else"); if (if_line != 0) { print_cstr(" entered on line "); print_int(if_line); } print_cstr(" is incomplete"); capture_to_diagnostic(NULL); if_line = mem[cond_ptr + 1].b32.s1; cur_if = mem[cond_ptr].b16.s0; if_limit = mem[cond_ptr].b16.s1; cond_ptr = LLIST_link(cond_ptr); } cond_ptr = p; if_limit = l; cur_if = c; if_line = i; print_ln(); if (INTPAR(tracing_nesting) > 1) { diagnostic_begin_capture_warning_here(); show_context(); capture_to_diagnostic(NULL); } if (history == HISTORY_SPOTLESS) history = HISTORY_WARNING_ISSUED; } void delete_sa_ref(int32_t q) { int32_t p; small_number i; small_number s; mem[q + 1].b32.s0--; if (mem[q + 1].b32.s0 != TEX_NULL) return; if (mem[q].b16.s1 < DIMEN_VAL_LIMIT) { if (mem[q + 2].b32.s1 == 0) s = WORD_NODE_SIZE; else return; } else { if (mem[q].b16.s1 < MU_VAL_LIMIT) { if (mem[q + 1].b32.s1 == 0) delete_glue_ref(0); else return; } else if (mem[q + 1].b32.s1 != TEX_NULL) return; s = POINTER_NODE_SIZE; } do { i = mem[q].b16.s1 % 64; p = q; q = mem[p].b32.s1; free_node(p, s); if (q == TEX_NULL) { sa_root[i] = TEX_NULL; return; } { if (odd(i)) mem[q + (i / 2) + 1].b32.s1 = TEX_NULL; else mem[q + (i / 2) + 1].b32.s0 = TEX_NULL; mem[q].b16.s0--; } s = INDEX_NODE_SIZE; } while (!(mem[q].b16.s0 > 0)); } /*:1609*//*1611: */ void sa_save(int32_t p) { int32_t q; uint16_t i; if (cur_level != sa_level) { if (save_ptr > max_save_stack) { max_save_stack = save_ptr; if (max_save_stack > save_size - 7) overflow("save size", save_size); } save_stack[save_ptr].b16.s1 = RESTORE_SA; save_stack[save_ptr].b16.s0 = sa_level; save_stack[save_ptr].b32.s1 = sa_chain; save_ptr++; sa_chain = TEX_NULL; sa_level = cur_level; } i = mem[p].b16.s1; if (i < DIMEN_VAL_LIMIT) { if (mem[p + 2].b32.s1 == 0) { q = get_node(POINTER_NODE_SIZE); i = TOK_VAL_LIMIT; } else { q = get_node(WORD_NODE_SIZE); mem[q + 2].b32.s1 = mem[p + 2].b32.s1; } mem[q + 1].b32.s1 = TEX_NULL; } else { q = get_node(POINTER_NODE_SIZE); mem[q + 1].b32.s1 = mem[p + 1].b32.s1; } mem[q + 1].b32.s0 = p; mem[q].b16.s1 = i; mem[q].b16.s0 = mem[p].b16.s0; mem[q].b32.s1 = sa_chain; sa_chain = q; mem[p + 1].b32.s0++; } void sa_destroy(int32_t p) { if (mem[p].b16.s1 < MU_VAL_LIMIT) delete_glue_ref(mem[p + 1].b32.s1); else if (mem[p + 1].b32.s1 != TEX_NULL) { if (mem[p].b16.s1 < BOX_VAL_LIMIT) flush_node_list(mem[p + 1].b32.s1); else delete_token_ref(mem[p + 1].b32.s1); } } void sa_def(int32_t p, int32_t e) { mem[p + 1].b32.s0++; if (mem[p + 1].b32.s1 == e) { sa_destroy(p); } else { if (mem[p].b16.s0 == cur_level) sa_destroy(p); else sa_save(p); mem[p].b16.s0 = cur_level; mem[p + 1].b32.s1 = e; } delete_sa_ref(p); } void sa_w_def(int32_t p, int32_t w) { mem[p + 1].b32.s0++; if (mem[p + 2].b32.s1 == w) { } else { if (mem[p].b16.s0 != cur_level) sa_save(p); mem[p].b16.s0 = cur_level; mem[p + 2].b32.s1 = w; } delete_sa_ref(p); } void gsa_def(int32_t p, int32_t e) { mem[p + 1].b32.s0++; sa_destroy(p); mem[p].b16.s0 = LEVEL_ONE; mem[p + 1].b32.s1 = e; delete_sa_ref(p); } void gsa_w_def(int32_t p, int32_t w) { mem[p + 1].b32.s0++; mem[p].b16.s0 = LEVEL_ONE; mem[p + 2].b32.s1 = w; delete_sa_ref(p); } void sa_restore(void) { int32_t p; do { p = mem[sa_chain + 1].b32.s0; if (mem[p].b16.s0 == LEVEL_ONE) { if (mem[p].b16.s1 >= DIMEN_VAL_LIMIT) sa_destroy(sa_chain); } else { if (mem[p].b16.s1 < DIMEN_VAL_LIMIT) { if (mem[sa_chain].b16.s1 < DIMEN_VAL_LIMIT) mem[p + 2].b32.s1 = mem[sa_chain + 2].b32.s1; else mem[p + 2].b32.s1 = 0; } else { sa_destroy(p); mem[p + 1].b32.s1 = mem[sa_chain + 1].b32.s1; } mem[p].b16.s0 = mem[sa_chain].b16.s0; } delete_sa_ref(p); p = sa_chain; sa_chain = mem[p].b32.s1; if (mem[p].b16.s1 < DIMEN_VAL_LIMIT) free_node(p, WORD_NODE_SIZE); else free_node(p, POINTER_NODE_SIZE); } while (!(sa_chain == TEX_NULL)); } void new_save_level(group_code c) { if (save_ptr > max_save_stack) { max_save_stack = save_ptr; if (max_save_stack > save_size - 7) overflow("save size", save_size); } save_stack[save_ptr + 0].b32.s1 = line; save_ptr++; save_stack[save_ptr].b16.s1 = LEVEL_BOUNDARY; save_stack[save_ptr].b16.s0 = cur_group; save_stack[save_ptr].b32.s1 = cur_boundary; if (cur_level == UINT16_MAX) overflow("grouping levels", UINT16_MAX); cur_boundary = save_ptr; cur_group = c; cur_level++; save_ptr++; } void eq_destroy(memory_word w) { int32_t q; switch (w.b16.s1) { case 113: case 114: case 115: case 116: delete_token_ref(w.b32.s1); break; case 119: delete_glue_ref(w.b32.s1); break; case 120: { q = w.b32.s1; if (q != TEX_NULL) free_node(q, mem[q].b32.s0 + mem[q].b32.s0 + 1); } break; case 121: flush_node_list(w.b32.s1); break; case 72: case 91: if (w.b32.s1 < 0 || w.b32.s1 > 19) delete_sa_ref(w.b32.s1); break; default: ; break; } } void eq_save(int32_t p, uint16_t l) { if (save_ptr > max_save_stack) { max_save_stack = save_ptr; if (max_save_stack > save_size - 7) overflow("save size", save_size); } if (l == LEVEL_ZERO) save_stack[save_ptr].b16.s1 = RESTORE_ZERO; else { save_stack[save_ptr] = eqtb[p]; save_ptr++; save_stack[save_ptr].b16.s1 = RESTORE_OLD_VALUE; } save_stack[save_ptr].b16.s0 = l; save_stack[save_ptr].b32.s1 = p; save_ptr++; } void eq_define(int32_t p, uint16_t t, int32_t e) { if (eqtb[p].b16.s1 == t && eqtb[p].b32.s1 == e) { eq_destroy(eqtb[p]); return; } if (eqtb[p].b16.s0 == cur_level) eq_destroy(eqtb[p]); else if (cur_level > LEVEL_ONE) eq_save(p, eqtb[p].b16.s0); eqtb[p].b16.s0 = cur_level; eqtb[p].b16.s1 = t; eqtb[p].b32.s1 = e; } void eq_word_define(int32_t p, int32_t w) { if (eqtb[p].b32.s1 == w) return; if (XEQ_LEVEL(p) != cur_level) { eq_save(p, XEQ_LEVEL(p)); XEQ_LEVEL(p) = cur_level; } eqtb[p].b32.s1 = w; } void geq_define(int32_t p, uint16_t t, int32_t e) { eq_destroy(eqtb[p]); eqtb[p].b16.s0 = LEVEL_ONE; eqtb[p].b16.s1 = t; eqtb[p].b32.s1 = e; } void geq_word_define(int32_t p, int32_t w) { eqtb[p].b32.s1 = w; XEQ_LEVEL(p) = LEVEL_ONE; } void save_for_after(int32_t t) { if (cur_level > LEVEL_ONE) { if (save_ptr > max_save_stack) { max_save_stack = save_ptr; if (max_save_stack > save_size - 7) overflow("save size", save_size); } save_stack[save_ptr].b16.s1 = INSERT_TOKEN; save_stack[save_ptr].b16.s0 = LEVEL_ZERO; save_stack[save_ptr].b32.s1 = t; save_ptr++; } } void unsave(void) { int32_t p; uint16_t l = 0; int32_t t; bool a; a = false; if (cur_level > LEVEL_ONE) { cur_level--; while (true) { save_ptr--; if (save_stack[save_ptr].b16.s1 == LEVEL_BOUNDARY) goto done; p = save_stack[save_ptr].b32.s1; if (save_stack[save_ptr].b16.s1 == INSERT_TOKEN) { /*338: */ t = cur_tok; cur_tok = p; if (a) { p = get_avail(); mem[p].b32.s0 = cur_tok; mem[p].b32.s1 = cur_input.loc; cur_input.loc = p; cur_input.start = p; if (cur_tok < RIGHT_BRACE_LIMIT) { if (cur_tok < LEFT_BRACE_LIMIT) align_state--; else align_state++; } } else { back_input(); a = true; } cur_tok = t; } else if (save_stack[save_ptr].b16.s1 == RESTORE_SA) { sa_restore(); sa_chain = p; sa_level = save_stack[save_ptr].b16.s0; } else { if (save_stack[save_ptr].b16.s1 == RESTORE_OLD_VALUE) { l = save_stack[save_ptr].b16.s0; save_ptr--; } else save_stack[save_ptr] = eqtb[UNDEFINED_CONTROL_SEQUENCE]; if ((p < INT_BASE) || (p > EQTB_SIZE)) { if (eqtb[p].b16.s0 == LEVEL_ONE) { eq_destroy(save_stack[save_ptr]); } else { eq_destroy(eqtb[p]); eqtb[p] = save_stack[save_ptr]; } } else if (XEQ_LEVEL(p) != LEVEL_ONE) { eqtb[p] = save_stack[save_ptr]; XEQ_LEVEL(p) = l; } } } done: if (grp_stack[in_open] == cur_boundary) group_warning(); cur_group = save_stack[save_ptr].b16.s0; cur_boundary = save_stack[save_ptr].b32.s1; save_ptr--; } else confusion("curlevel"); } void prepare_mag(void) { if (mag_set > 0 && INTPAR(mag) != mag_set) { ttbc_diagnostic_t *errmsg = error_here_with_diagnostic("Incompatible magnification ("); print_int(INTPAR(mag)); print_cstr(");"); print_nl_cstr(" the previous value will be retained"); ttstub_diag_printf(errmsg, " (%d)", mag_set); capture_to_diagnostic(NULL); { help_ptr = 2; help_line[1] = "I can handle only one magnification ratio per job. So I've"; help_line[0] = "reverted to the magnification you used earlier on this run."; } int_error(mag_set); geq_word_define(INT_BASE + INT_PAR__mag, mag_set); } if ((INTPAR(mag) <= 0) || (INTPAR(mag) > 32768L)) { ttbc_diagnostic_t *errmsg = error_here_with_diagnostic("Illegal magnification has been changed to 1000"); ttstub_diag_printf(errmsg, " (%d)", INTPAR(mag)); capture_to_diagnostic(NULL); { help_ptr = 1; help_line[0] = "The magnification ratio must be between 1 and 32768."; } int_error(INTPAR(mag)); geq_word_define(INT_BASE + INT_PAR__mag, 1000); } mag_set = INTPAR(mag); } void token_show(int32_t p) { if (p != TEX_NULL) show_token_list(mem[p].b32.s1, TEX_NULL, 10000000L); } void print_meaning(void) { print_cmd_chr(cur_cmd, cur_chr); if (cur_cmd >= CALL) { print_char(':'); print_ln(); token_show(cur_chr); } else if ((cur_cmd == TOP_BOT_MARK) && (cur_chr < 5)) { print_char(':'); print_ln(); token_show(cur_mark[cur_chr]); } } // Used just to trace commands - all gated behind INTPAR(tracing_commands) void show_cur_cmd_chr(void) { int32_t n; int32_t l; int32_t p; begin_diagnostic(); diagnostic_begin_capture_warning_here(); print_nl('{'); if (cur_list.mode != shown_mode) { print_mode(cur_list.mode); print_cstr(": "); shown_mode = cur_list.mode; } print_cmd_chr(cur_cmd, cur_chr); if (INTPAR(tracing_ifs) > 0) { if (cur_cmd >= IF_TEST) { if (cur_cmd <= FI_OR_ELSE) { print_cstr(": "); if (cur_cmd == FI_OR_ELSE) { print_cmd_chr(IF_TEST, cur_if); print_char(' '); n = 0; l = if_line; } else { n = 1; l = line; } p = cond_ptr; while (p != TEX_NULL) { n++; p = LLIST_link(p); } print_cstr("(level "); print_int(n); print_char(')'); if (l != 0) { print_cstr(" entered on line "); print_int(l); } } } } print_char('}'); capture_to_diagnostic(NULL); end_diagnostic(false); } void show_context(void) { unsigned char /*max_selector */ old_setting; int32_t nn; bool bottom_line; int32_t i; int32_t j; int32_t l; int32_t m; int32_t n; int32_t p; int32_t q; base_ptr = input_ptr; input_stack[base_ptr] = cur_input; nn = -1; bottom_line = false; while (true) { cur_input = input_stack[base_ptr]; if ((cur_input.state != TOKEN_LIST)) { if ((cur_input.name > 19) || (base_ptr == 0)) bottom_line = true; } if ((base_ptr == input_ptr) || bottom_line || (nn < INTPAR(error_context_lines))) { /*324: */ if ((base_ptr == input_ptr) || (cur_input.state != TOKEN_LIST) || (cur_input.index != BACKED_UP) || (cur_input.loc != TEX_NULL)) { tally = 0; old_setting = selector; if (cur_input.state != TOKEN_LIST) { if (cur_input.name <= 17) { if (cur_input.name == 0) { if (base_ptr == 0) print_nl_cstr("<*>"); else print_nl_cstr(" "); } else { print_nl_cstr("'); } } else { print_nl_cstr("l."); if (cur_input.index == in_open) print_int(line); else print_int(line_stack[cur_input.index + 1]); } print_char(' '); { l = tally; tally = 0; selector = SELECTOR_PSEUDO; trick_count = 1000000L; } if (buffer[cur_input.limit] == INTPAR(end_line_char)) j = cur_input.limit; else j = cur_input.limit + 1; if (j > 0) { register int32_t for_end; i = cur_input.start; for_end = j - 1; if (i <= for_end) do { if (i == cur_input.loc) { first_count = tally; trick_count = tally + 1 + error_line - half_error_line; if (trick_count < error_line) trick_count = error_line; } print_char(buffer[i]); } while (i++ < for_end); } } else { switch (cur_input.index) { case PARAMETER: print_nl_cstr(" "); break; case U_TEMPLATE: case V_TEMPLATE: print_nl_cstr("