STATIC void node_dump(Linear_s *t, Blknum_t blknum, int indent) { Buf_s *buf; Node_s *node; Blknum_t overflow; if (!blknum) return; buf = t_get(t, blknum); node = buf->d; Hrec_s rec; unint i; if (Dump_buf) { pr_buf(buf, indent); } pr_head(node, indent); for (i = 0; i < node->numrecs; i++) { rec = get_rec(node, i); pr_indent(indent); printf("%ld. ", i); rec_dump(rec); } overflow = node->overflow; buf_put(&buf); if (overflow) { node_dump(t, overflow, indent+1); } }
int main(void) { int i, j; for(i = 0; i < HEAD_SIZE; i++) { head[i].x = i; } for(i = 0; i < DATA_SIZE; i++) { int x = get_int(); int j = x & 0xf; list_add_tail(j, x); } for(i = 0; i < HEAD_SIZE; i++) { struct ds *p = head + i; struct ds *pp; for(pp = head->next; pp; pp = pp->next) { int mask = (pp->x & 0xf0) >> 4; list_del(pp); } } pr_head(); return 0; }
STATIC void pr_node(Node_s *node) { unint i; Hrec_s rec; pr_head(node, 0); for (i = 0; i < node->numrecs; i++) { rec = get_rec(node, i); printf("%3ld. ", i); pr_rec(rec); putchar('\n'); } }
static void show_run(const struct run *run) { /* The animals came in two by two ... */ const struct chunk *cnk0 = &run->rn_chunk0; const struct chunk *cnk1 = &run->rn_chunk1; size_t nl_cnt0 = cnk0->ch_last.ps_nl_cnt - cnk0->ch_first.ps_nl_cnt; size_t nl_cnt1 = cnk1->ch_last.ps_nl_cnt - cnk1->ch_first.ps_nl_cnt; FILE *f0; FILE *f1; /* display heading of chunk */ if (!is_set_option('d')) { /* no assumptions about the lengths of the file names! */ size_t size = run->rn_size; int pos = 0; pos += pr_head(cnk0); while (pos < max_line_length + 1) { pos += prs(" "); } pos += prs("|"); pos += pr_head(cnk1); while (pos < 2*max_line_length - unslen(size)) { pos += prs(" "); } fprintf(Output_File, "[%s]\n", size_t2string(size)); } else { (void)pr_head(cnk0); fprintf(Output_File, "\n"); (void)pr_head(cnk1); fprintf(Output_File, "\n"); } /* stop if that suffices */ if (is_set_option('n')) return; /* ... had enough so soon ... */ /* open the files that hold the chunks */ f0 = open_chunk(cnk0); f1 = open_chunk(cnk1); /* display the chunks in the required format */ if (!is_set_option('d')) { /* fill 2-column lines and print them */ while (nl_cnt0 != 0 || nl_cnt1 != 0) { if (nl_cnt0) { fill_line(f0, line0); nl_cnt0--; } else { clear_line(line0); } if (nl_cnt1) { fill_line(f1, line1); nl_cnt1--; } else { clear_line(line1); } show_2C_line(line0, line1); } } else { /* display the lines in a diff(1)-like format */ while (nl_cnt0--) { show_1C_line(f0, "<"); } fprintf(Output_File, "---\n"); while (nl_cnt1--) { show_1C_line(f1, ">"); } } /* close the pertinent files */ fclose(f0); fclose(f1); }