From fddcb7b82ff45dc9e08bab26bbfe7a2d2e8ca20f Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Thu, 20 Apr 2017 14:22:33 +0000 Subject: Implement a basic --changed-group-format etcupdate(8) requires that option, while GNU diff supports many more variation of that options, their behaviour beside the simple verion implemented here are quite inconsistent as such I do not plan to implement those. The only special keyword supported by this implementation are: %< and %> %= is not implemented as the documentation of GNU diff says: common lines, but it actually when tested print the changes from the first file --- usr.bin/diff/diff.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'usr.bin/diff/diff.c') diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c index 9c20fa182d90..f314e9f76c3f 100644 --- a/usr.bin/diff/diff.c +++ b/usr.bin/diff/diff.c @@ -41,6 +41,7 @@ int lflag, Nflag, Pflag, rflag, sflag, Tflag, cflag; int diff_format, diff_context, status, ignore_file_case; int tabsize = 8; char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; +char *group_format = NULL; struct stat stb1, stb2; struct excludes *excludes_list; regex_t ignore_re; @@ -54,6 +55,7 @@ enum { OPT_NORMAL, OPT_HORIZON_LINES, OPT_SPEED_LARGE_FILES, + OPT_CHANGED_GROUP_FORMAT, }; static struct option longopts[] = { @@ -89,6 +91,7 @@ static struct option longopts[] = { { "speed-large-files", no_argument, NULL, OPT_SPEED_LARGE_FILES}, { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, { "tabsize", optional_argument, NULL, OPT_TSIZE }, + { "changed-group-format", required_argument, NULL, OPT_CHANGED_GROUP_FORMAT}, { NULL, 0, 0, '\0'} }; @@ -227,6 +230,10 @@ main(int argc, char **argv) case 'x': push_excludes(optarg); break; + case OPT_CHANGED_GROUP_FORMAT: + diff_format = D_GFORMAT; + group_format = optarg; + break; case OPT_HORIZON_LINES: break; /* XXX TODO for compatibility with GNU diff3 */ case OPT_IGN_FN_CASE: -- cgit v1.2.3