commit - 3f909282bf0e2f427e0ef86ad5aa41440ffae088
commit + c38b7f767103c2220cf36e96c72686639fcbe797
blob - e03a92f3d09d5f43bb2fcd5198f7447ccb87e031
blob + cab83083b171c576d1794b3a39ee4328956fe162
--- diff.c
+++ diff.c
/* $OpenBSD$ */
/*
- * Copyright (c) 2018 Martin Pieuchot <mpi@openbsd.org>
+ * Copyright (c) 2018,2020 Martin Pieuchot <mpi@openbsd.org>
* Copyright (c) 2020 Neels Hofmeyr <neels@hofmeyr.de>
*
* Permission to use, copy, modify, and distribute this software for any
int diffreg(char *, char *, int, int);
char *mmapfile(const char *, struct stat *);
-void output(const struct output_info *,
- const struct diff_result *);
+void output(const struct diff_result *, const struct output_info *);
const struct diff_algo_config myers, patience, myers_divide;
info.left_time = st1.st_mtime;
info.right_time = st2.st_mtime;
- output(&info, result);
+ output(result, &info);
diff_result_free(result);
munmap(str1, st1.st_size);
}
static void
-print_default(const struct output_info *info,
- const struct diff_result *result, const struct chunk_context *cc)
+print_default(const struct diff_result *result, const struct output_info *info,
+ const struct chunk_context *cc)
{
const struct diff_chunk *c, *cleft = NULL, *cright = NULL;
int c_idx;
}
static void
-print_unified(bool *header_printed, const struct output_info *info,
- const struct diff_result *result, const struct chunk_context *cc)
+print_unified(const struct diff_result *result, const struct output_info *info,
+ const struct chunk_context *cc, bool *header_printed)
{
int c_idx;
}
static void
-print_cformat(bool *header_printed, const struct output_info *info,
- const struct diff_result *result, const struct chunk_context *cc)
+print_cformat(const struct diff_result *result, const struct output_info *info,
+ const struct chunk_context *cc, bool *header_printed)
{
const struct diff_chunk *c, *cleft = NULL, *cright = NULL;
int c_idx;
}
static void
-print_chunk(bool *header_printed, const struct output_info *info,
- const struct diff_result *result, const struct chunk_context *cc)
+print_chunk(const struct diff_result *result, const struct output_info *info,
+ const struct chunk_context *cc, bool *header_printed)
{
if (range_empty(&cc->left) && range_empty(&cc->right))
return;
switch (info->format) {
case F_UNIFIED:
- print_unified(header_printed, info, result, cc);
+ print_unified(result, info, cc, header_printed);
break;
case F_CFORMAT:
- print_cformat(header_printed, info, result, cc);
+ print_cformat(result, info, cc, header_printed);
break;
case F_FFORMAT:
case F_ED:
default:
- print_default(info, result, cc);
+ print_default(result, info, cc);
break;
}
}
void
-output(const struct output_info *info, const struct diff_result *result)
+output(const struct diff_result *result, const struct output_info *info)
{
struct chunk_context cc = {};
bool header_printed = false;
* gap between it and this next one. Print the previous
* one and start fresh here.
*/
- print_chunk(&header_printed, info, result, &cc);
-
+ print_chunk(result, info, &cc, &header_printed);
cc = next;
}
if (chunk_context_empty(&cc))
return;
- print_chunk(&header_printed, info, result, &cc);
+ print_chunk(result, info, &cc, &header_printed);
}