]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
diff: fix incorrectly displaying files as duplicates
authorJamie Landeg-Jones <jamie@catflap.org>
Mon, 25 Jan 2021 17:42:26 +0000 (18:42 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Mon, 1 Feb 2021 13:05:25 +0000 (14:05 +0100)
commit3728c4d3149553967532a97254737bdb2cd92417
treef29ca52cb36cc794ade393b14499b67977041e6a
parent0702bf9c495d517ef30432de1990f9a301598942
diff: fix incorrectly displaying files as duplicates

When diff hits certain access errors, function diffreg() shows the error
message, and then returns to the calling function, which calls
print_status() with the return value.

However, in these cases, the return value isn't changed from the initial
default value of D_SAME.

Normally, print_status() with a value of D_SAME does nothing, so this
works out ok, however, if the "-s" flag is set, a message is displayed
showing identicality:

case D_SAME:
                if (sflag)
                        printf("Files %s%s and %s%s are identical\n",                                                                                                       path1, entry, path2, entry);
                break;

This then produces such results as:

% diff  -s /COPYRIGHT /var/run/rpcbind.sock
diff: /var/run/rpcbind.sock: Operation not supported
Files /COPYRIGHT and /var/run/rpcbind.sock are identical

% diff  -s /COPYRIGHT /etc/master.passwd
diff: /etc/master.passwd: Permission denied
Files /COPYRIGHT and /etc/master.passwd are identical

Create a D_ERROR status which is returned in such cases, and
print_status() then deals with that status seperately from D_SAME

PR: 252614
MFC after: 1 week

(cherry picked from commit fefb3c46a80fdde6f307e73a2b5b5aed806df1ce)
usr.bin/diff/diff.c
usr.bin/diff/diff.h
usr.bin/diff/diffreg.c