void QMapData::dump() { qDebug("Map data (ref = %d, size = %d, randomBits = %#.8x)", int(ref), size, randomBits); QString preOutput; QVector<QString> output(topLevel + 1); Node *e = reinterpret_cast<Node *>(this); QString str; str.sprintf(" %.8x", adjust_ptr(reinterpret_cast<Node *>(this))); preOutput += str; Node *update[LastLevel + 1]; for (int i = 0; i <= topLevel; ++i) { str.sprintf("%d: [%.8x] -", i, adjust_ptr(reinterpret_cast<Node *>(forward[i]))); output[i] += str; update[i] = reinterpret_cast<Node *>(forward[i]); } Node *node = reinterpret_cast<Node *>(forward[0]); while (node != e) { int level = 0; while (level < topLevel && update[level + 1] == node) ++level; str.sprintf(" %.8x", adjust_ptr(node)); preOutput += str; for (int i = 0; i <= level; ++i) { str.sprintf("-> [%.8x] -", adjust_ptr(node->forward[i])); output[i] += str; update[i] = node->forward[i]; } for (int j = level + 1; j <= topLevel; ++j) output[j] += QLatin1String("---------------"); node = node->forward[0]; } qDebug("%s", preOutput.ascii()); for (int i = 0; i <= topLevel; ++i) qDebug("%s", output[i].ascii()); }
void tex::handle_right_brace () { scal d; int f; ptr p; ptr q; switch (cur_group) { case SIMPLE_GROUP: unsave(); break; case BOTTOM_LEVEL: print_err("Too many }'s"); help_close_group(); error(); break; case SEMI_SIMPLE_GROUP: case MATH_SHIFT_GROUP: case MATH_LEFT_GROUP: extra_right_brace(); break; case HBOX_GROUP: package(0); break; case ADJUSTED_HBOX_GROUP: tex::adjust_tail = tex::adjust_head; package(0); break; case VBOX_GROUP: end_graf(); package(0); break; case VTOP_GROUP: end_graf(); package(VTOP_CODE); break; case INSERT_GROUP: end_graf(); q = split_top_skip; add_glue_ref(q); d = split_max_depth; f = floating_penalty; unsave(); decr(save_ptr); p = vpack(link(head), 0, ADDITIONAL); pop_nest(); if (saved(0) < 255) { tail_append(new_node(INS_NODE_SIZE)); type(tail) = INS_NODE; subtype(tail) = saved(0); ins_height(tail) = box_height(p) + box_depth(p); ins_ptr(tail) = list_ptr(p); split_top_ptr(tail) = q; ins_depth(tail) = d; float_cost(tail) = f; } else { tail_append(new_node(SMALL_NODE_SIZE)); type(tail) = ADJUST_NODE; subtype(tail) = 0; adjust_ptr(tail) = list_ptr(p); delete_glue_ref(q); } free_node(p, BOX_NODE_SIZE); if (nest_ptr == nest) build_page(); break; case OUTPUT_GROUP: if (loc != null || (token_type != OUTPUT_TEXT && token_type != BACKED_UP)) { print_err("Unbalanced output routine"); help_output_balance(); error(); do get_token(); while (loc != null); } end_token_list(); end_graf(); unsave(); output_active = FALSE; insert_penalties = 0; if (box(255) != null) { print_err("Output routine didn't use all of "); print_esc("box255"); help_output(); box_error(255); } if (tail != head) { link(page_tail) = link(head); page_tail = tail; } if (link(page_head) != null) { if (link(contrib_head) == null) contrib_tail = page_tail; link(page_tail) = link(contrib_head); link(contrib_head) = link(page_head); link(page_head) = null; page_tail = page_head; } pop_nest(); build_page(); break; case DISC_GROUP: build_discretionary(); break; case ALIGN_GROUP: back_input(); cur_tok = sym2tok(FROZEN_CR); print_err("Missing "); print_esc("cr"); print(" inserted"); help_align_cr(); ins_error(); break; case NO_ALIGN_GROUP: end_graf(); unsave(); align_peek(); break; case VCENTER_GROUP: end_graf(); unsave(); save_ptr -= 2; p = vpackage(link(head), saved(1), saved(0), MAX_DIMEN); pop_nest(); tail_append(new_noad()); type(tail) = VCENTER_NOAD; math_type(nucleus(tail)) = SUB_BOX; info(nucleus(tail)) = p; break; case MATH_CHOICE_GROUP: build_choices(); break; case MATH_GROUP: unsave(); decr(save_ptr); math_type(saved(0)) = SUB_MLIST; p = fin_mlist(null); math_link(saved(0)) = p; if (p != null) { if (link(p) == null) { if (type(p) == ORD_NOAD) { if (math_type(subscr(p)) == EMPTY && math_type(supscr(p)) == EMPTY) { mcopy(saved(0), nucleus(p)); free_node(p, NOAD_SIZE); } } else if (type(p) == ACCENT_NOAD && saved(0) == nucleus(tail) && type(tail) == ORD_NOAD) { q = head; while (link(q) != tail) q = link(q); link(q) = p; free_node(tail, NOAD_SIZE); tail = p; } } } break; default: confusion("rightbrace"); break; } }
void tex::flush_node_list(ptr p) { ptr q; while (p != null) { q = link(p); if (is_char_node(p)) { free_avail(p); } else { switch (type(p)) { case HLIST_NODE: case VLIST_NODE: case UNSET_NODE: flush_node_list(list_ptr(p)); free_node(p, BOX_NODE_SIZE); goto done; case RULE_NODE: free_node(p, RULE_NODE_SIZE); goto done; case INS_NODE: flush_node_list(ins_ptr(p)); delete_glue_ref(split_top_ptr(p)); free_node(p, INS_NODE_SIZE); goto done; case WHATSIT_NODE: free_whatsit(p); goto done; case GLUE_NODE: fast_delete_glue_ref(glue_ptr(p)); if (leader_ptr(p) != null) flush_node_list(leader_ptr(p)); break; case KERN_NODE: case MATH_NODE: case PENALTY_NODE: break; case LIGATURE_NODE: flush_node_list(lig_ptr(p)); break; case MARK_NODE: delete_token_ref(mark_ptr(p)); break; case DISC_NODE: flush_node_list(pre_break(p)); flush_node_list(post_break(p)); break; case ADJUST_NODE: flush_node_list(adjust_ptr(p)); break; case STYLE_NODE: free_node(p, STYLE_NODE_SIZE); goto done; case CHOICE_NODE: flush_node_list(display_mlist(p)); flush_node_list(text_mlist(p)); flush_node_list(script_mlist(p)); flush_node_list(script_script_mlist(p)); free_node(p, STYLE_NODE_SIZE); goto done; 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 (math_type(nucleus(p)) >= SUB_BOX) flush_node_list(math_link(nucleus(p))); if (math_type(supscr(p)) >= SUB_BOX) flush_node_list(math_link(supscr(p))); if (math_type(subscr(p)) >= SUB_BOX) flush_node_list(math_link(subscr(p))); if (type(p) == RADICAL_NOAD) free_node(p, RADICAL_NOAD_SIZE); else if (type(p) == ACCENT_NOAD) free_node(p, ACCENT_NOAD_SIZE); else free_node(p, NOAD_SIZE); goto done; case LEFT_NOAD: case RIGHT_NOAD: free_node(p, NOAD_SIZE); goto done; case FRACTION_NOAD: flush_node_list(math_link(numerator(p))); flush_node_list(math_link(denominator(p))); free_node(p, FRACTION_NOAD_SIZE); goto done; default: confusion("flushing"); break; } free_node(p, SMALL_NODE_SIZE); done:; } p = q; } }
ptr tex::copy_node_list(ptr p) { ptr h; ptr q; ptr r=0; h = q = new_avail(); while (p != null) { if (is_char_node(p)) { r = new_avail(); font(r) = font(p); character(r) = character(p); } else { switch (type(p)) { case HLIST_NODE: case VLIST_NODE: case UNSET_NODE: r = tex::new_node(BOX_NODE_SIZE); memcpy((void *)r, (void *)p, BOX_NODE_SIZE); list_ptr(r) = copy_node_list(list_ptr(p)); break; case RULE_NODE: r = tex::new_node(RULE_NODE_SIZE); memcpy((void *)r, (void *)p, RULE_NODE_SIZE); break; case INS_NODE: r = tex::new_node(INS_NODE_SIZE); memcpy((void *)r, (void *)p, INS_NODE_SIZE); add_glue_ref(split_top_ptr(p)); ins_ptr(r) = copy_node_list(ins_ptr(p)); break; case WHATSIT_NODE: r = copy_whatsit(p); break; case GLUE_NODE: r = tex::new_node(SMALL_NODE_SIZE); memcpy((void *)r, (void *)p, SMALL_NODE_SIZE); add_glue_ref(glue_ptr(p)); glue_ptr(r) = glue_ptr(p); leader_ptr(r) = copy_node_list(leader_ptr(p)); break; case KERN_NODE: case MATH_NODE: case PENALTY_NODE: r = tex::new_node(SMALL_NODE_SIZE); memcpy((void *)r, (void *)p, SMALL_NODE_SIZE); break; case LIGATURE_NODE: r = tex::new_node(SMALL_NODE_SIZE); memcpy((void *)r, (void *)p, SMALL_NODE_SIZE); lig_ptr(r) = copy_node_list(lig_ptr(p)); break; case DISC_NODE: r = tex::new_node(SMALL_NODE_SIZE); memcpy((void *)r, (void *)p, SMALL_NODE_SIZE); pre_break(r) = copy_node_list(pre_break(p)); post_break(r) = copy_node_list(post_break(p)); break; case MARK_NODE: r = tex::new_node(SMALL_NODE_SIZE); memcpy((void *)r, (void *)p, SMALL_NODE_SIZE); add_token_ref(mark_ptr(p)); break; case ADJUST_NODE: r = tex::new_node(SMALL_NODE_SIZE); memcpy((void *)r, (void *)p, SMALL_NODE_SIZE); adjust_ptr(r) = copy_node_list(adjust_ptr(p)); break; default: confusion("copying"); break; } } q = link(q) = r; p = link(p); } link(q) = null; q = link(h); free_avail(h); return q; }
void tex::show_adjust(ptr p) { print_esc("vadjust"); node_list_display(adjust_ptr(p)); }