Esempio n. 1
0
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);
}
Esempio n. 2
0
static int
pru(unsigned int u) {
	fprintf(Output_File, "%u", u);
	return unslen(u);
}
Esempio n. 3
0
static int
pru(size_t u) {
	fprintf(Output_File, "%s", size_t2string(u));
	return unslen(u);
}
Esempio n. 4
0
static int
pru(size_t u) {
	fprintf(Output_File, "%zu", u);
	return unslen(u);
}