commit - ec38e642d2237c42552e1a0b89554d36bf20d7ff
commit + af4b424466c219a0f4055cde9397c63429f7ca9a
blob - c84bc69bb2bf0b14c4165386c28867661735f606
blob + 5e9c48771fbdd73ddda301a22024de0361abe005
--- diff_output.c
+++ diff_output.c
const struct diff_result *result);
enum diff_rc diff_output_unidiff(FILE *dest, const struct diff_input_info *info,
const struct diff_result *result, unsigned int context_lines);
-enum diff_rc diff_output_info(FILE *dest, const struct diff_input_info *info);
void diff_output_lines(FILE *dest, const char *prefix, struct diff_atom *start_atom, unsigned int count);
void
}
}
-enum diff_rc
-diff_output_info(FILE *dest, const struct diff_input_info *info)
-{
- fprintf(dest, "--- %s\n+++ %s\n",
- info->left_path ? : "a",
- info->right_path ? : "b");
- return DIFF_RC_OK;
-}
-
/*
* Output all lines of a diff_result.
*/
{
int i;
- diff_output_info(dest, info);
-
for (i = 0; i < result->chunks.len; i++) {
struct diff_chunk *c = &result->chunks.head[i];
}
static void
-diff_output_unidiff_chunk(FILE *dest, bool *info_printed,
+diff_output_unidiff_chunk(FILE *dest, bool *header_printed,
const struct diff_input_info *info, const struct diff_result *result,
const struct chunk_context *cc)
{
if (range_empty(&cc->left) && range_empty(&cc->right))
return;
- if (!(*info_printed)) {
- diff_output_info(dest, info);
- *info_printed = true;
+ if (!(*header_printed)) {
+ fprintf(dest, "--- %s\n+++ %s\n",
+ info->left_path ? : "a", info->right_path ? : "b");
+ *header_printed = true;
}
fprintf(dest, "@@ -%d,%d +%d,%d @@\n",
const struct diff_result *result, unsigned int context_lines)
{
struct chunk_context cc = {};
- bool info_printed = false;
+ bool header_printed = false;
int i;
for (i = 0; i < result->chunks.len; i++) {
debug("new chunk to be printed does not touch previous chunk;"
" print left %d-%d right %d-%d\n", cc.left.start,
cc.left.end, cc.right.start, cc.right.end);
- diff_output_unidiff_chunk(dest, &info_printed, info, result,
+ diff_output_unidiff_chunk(dest, &header_printed, info, result,
&cc);
cc = next;
}
if (!chunk_context_empty(&cc))
- diff_output_unidiff_chunk(dest, &info_printed, info, result,
+ diff_output_unidiff_chunk(dest, &header_printed, info, result,
&cc);
return DIFF_RC_OK;
}