aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2021-01-09 16:22:28 +0000
committerEd Maste <emaste@FreeBSD.org>2021-01-09 18:34:06 +0000
commit12a8d3027d414abd15798de1b6d8b01151bdac50 (patch)
tree947b4ccd90eeafc806f01f1832f21112e2b0b2f5 /usr.bin
parent40e6e2c2f711f95cb623691aacc235a79c1cfaeb (diff)
downloadsrc-12a8d3027d414abd15798de1b6d8b01151bdac50.tar.gz
src-12a8d3027d414abd15798de1b6d8b01151bdac50.zip
diff: honour flags with -q
Previously -q (just print a line when files differ) ignored flags like -w (ignore whitespace). Avoid the D_BRIEF short-circuit when flags are in effect. PR: 252515 Reported by: Scott Aitken Reviewed by: kevans MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28064
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/diff/diffreg.c4
-rwxr-xr-xusr.bin/diff/tests/diff_test.sh10
2 files changed, 13 insertions, 1 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index 74c0df7dce30..7d2b20b43def 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -369,7 +369,9 @@ diffreg(char *file1, char *file2, int flags, int capsicum)
goto closem;
}
- if (diff_format == D_BRIEF && ignore_pats == NULL) {
+ if (diff_format == D_BRIEF && ignore_pats == NULL &&
+ (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNORECASE|D_STRIPCR)) == 0)
+ {
rval = D_DIFFER;
status |= 1;
goto closem;
diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh
index 9f460231f480..7ee88d1fe607 100755
--- a/usr.bin/diff/tests/diff_test.sh
+++ b/usr.bin/diff/tests/diff_test.sh
@@ -9,6 +9,7 @@ atf_test_case group_format
atf_test_case side_by_side
atf_test_case brief_format
atf_test_case b230049
+atf_test_case b252515
atf_test_case Bflag
atf_test_case Nflag
atf_test_case tabsize
@@ -65,6 +66,14 @@ b230049_body()
b230049_a.in b230049_b.in
}
+b252515_body()
+{
+ printf 'a b\n' > b252515_a.in
+ printf 'a b\n' > b252515_b.in
+ atf_check -o empty -s eq:0 \
+ diff -qw b252515_a.in b252515_b.in
+}
+
header_body()
{
export TZ=UTC
@@ -228,6 +237,7 @@ atf_init_test_cases()
atf_add_test_case side_by_side
atf_add_test_case brief_format
atf_add_test_case b230049
+ atf_add_test_case b252515
atf_add_test_case Bflag
atf_add_test_case Nflag
atf_add_test_case tabsize