diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2020-10-27 12:27:26 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2020-10-27 12:27:26 +0000 |
commit | b0d30b27f0dac95224dfdb7a242dbbbe1e19930c (patch) | |
tree | 146925f5a6d95c3b4d5bdbb42d1d900a502ca06d /usr.bin | |
parent | 1f474190fc280d4a4ef0c214e4d7fff0d1237e22 (diff) | |
download | src-b0d30b27f0dac95224dfdb7a242dbbbe1e19930c.tar.gz src-b0d30b27f0dac95224dfdb7a242dbbbe1e19930c.zip |
diff: don't force the format to 'context' with -p immediately
Instead, leave the fomat as unspecified (if it hasn't been) and use the
-p flag as a hint to 'context' if no other formatting option is specified.
This fixes `diff -purw`, used frequently by emaste, and matches the behavior
of its GNU counterpart.
PR: 250015
Reviewed by: emaste
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=367076
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/diff/diff.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c index 27d5bb5cb336..0e46b96f9667 100644 --- a/usr.bin/diff/diff.c +++ b/usr.bin/diff/diff.c @@ -210,17 +210,6 @@ main(int argc, char **argv) diff_format = D_NREVERSE; break; case 'p': - /* - * If it's not unset and it's not set to context or - * unified, we'll error out here as a conflicting - * format. If it's unset, we'll go ahead and set it to - * context. - */ - if (FORMAT_MISMATCHED(D_CONTEXT) && - FORMAT_MISMATCHED(D_UNIFIED)) - conflicting_format(); - if (diff_format == D_UNSET) - diff_format = D_CONTEXT; dflags |= D_PROTOTYPE; break; case 'P': @@ -320,6 +309,8 @@ main(int argc, char **argv) newarg = optind != prevoptind; prevoptind = optind; } + if (diff_format == D_UNSET && (dflags & D_PROTOTYPE) != 0) + diff_format = D_CONTEXT; if (diff_format == D_UNSET) diff_format = D_NORMAL; argc -= optind; |