diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -709,10 +709,10 @@ * in one file for -b or -w. */ if (flags & (D_FOLDBLANKS | D_IGNOREBLANKS)) { - if (c == EOF && d == '\n') { + if (c == EOF && isspace(d)) { ctnew++; break; - } else if (c == '\n' && d == EOF) { + } else if (isspace(c) && d == EOF) { ctold++; break; } diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh --- a/usr.bin/diff/tests/diff_test.sh +++ b/usr.bin/diff/tests/diff_test.sh @@ -22,6 +22,7 @@ atf_test_case functionname atf_test_case noderef atf_test_case ignorecase +atf_test_case crlfeol simple_body() { @@ -334,6 +335,14 @@ atf_check -o empty -s exit:0 diff -u -r --ignore-file-name-case A B } +crlfeol_body() +{ + printf 'hello world\r\n' > a + printf 'hello world' > b + + atf_check -o empty -s exit:0 diff -b a b +} + atf_init_test_cases() { atf_add_test_case simple @@ -358,4 +367,5 @@ atf_add_test_case functionname atf_add_test_case noderef atf_add_test_case ignorecase + atf_add_test_case crlfeol }