mirror of
https://https.git.savannah.gnu.org/git/diffutils.git
synced 2026-01-27 18:04:32 +00:00
This fixes a bug I recently introduced. * src/diff.c (compare_files): Set and use openerr to avoid the need for a doomed second attempt at openat. Don’t insist on openat succeeding before trying fstatat. Unless openat fails with ENOENT, ENOTDIR, ELOOP, EOVERFLOW, ENAMETOOLONG it’s possible for it to fail even when fstatat would succeed. ENOTDIR also means the file does not exist. However, do not worry about EBADF as that is no longer possible now that diff uses xstdopen. When checking whether a file should be considered to be nonexistent, do not require the other file desc to be UNOPENED or STDIN_FILENO; all that is needed is for the other file to not have an ENOENT or ENOTDIR failure. * src/diff.h (struct file_data): New member openerr. (OPEN_FAILED): New constant. * tests/new-file: Add a regression test to catch the bug fixed by the above. diff: fix recent -N regression * src/diff.c (compare_files): Fix recent regression, by looking at cmp.file[1 - f].err rather than cmp.file[1 - f].desc. Also, do not bother checking for EBADF, as that’s no longer possible now that diff uses xstdopen.
31 lines
583 B
Bash
Executable File
31 lines
583 B
Bash
Executable File
#!/bin/sh
|
|
# Test --new-file (-N) and --unidirectional-new-file.
|
|
|
|
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
|
|
|
fail=0
|
|
|
|
echo a > a || fail=1
|
|
|
|
echo '0a1
|
|
> a' > exp || fail=1
|
|
|
|
returns_ 1 diff -N b a > out || fail=1
|
|
compare exp out || fail=1
|
|
|
|
returns_ 1 diff -N b - < a > out || fail=1
|
|
compare exp out || fail=1
|
|
|
|
returns_ 1 diff --unidirectional-new-file b - < a > out || fail=1
|
|
compare exp out || fail=1
|
|
|
|
echo '1d0
|
|
< a' > exp || fail=1
|
|
|
|
returns_ 1 diff -N - b < a > out || fail=1
|
|
compare exp out || fail=1
|
|
|
|
returns_ 2 diff --unidirectional-new-file - b < a > out || fail=1
|
|
|
|
Exit $fail
|