mirror of
https://https.git.savannah.gnu.org/git/diffutils.git
synced 2026-01-27 01:44:20 +00:00
* src/cmp.c (type_no_stdout): New constant.
(main): Use it to avoid bug when the "EOF on foo" message is generated and stdout is /dev/null.
This commit is contained in:
parent
57253a174c
commit
708ba31420
@ -1,3 +1,10 @@
|
||||
2006-03-09 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* src/cmp.c (type_no_stdout): New constant.
|
||||
(main): Use it to avoid bug when the "EOF on foo" message is
|
||||
generated and stdout is /dev/null.
|
||||
Problem reported by Vincent Lefevre (Debian bug 356083).
|
||||
|
||||
2006-01-04 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* README-alpha: Describe CVS access better, using the README-alpha
|
||||
|
||||
13
src/cmp.c
13
src/cmp.c
@ -78,6 +78,7 @@ static enum comparison_type
|
||||
{
|
||||
type_first_diff, /* Print the first difference. */
|
||||
type_all_diffs, /* Print all differences. */
|
||||
type_no_stdout, /* Do not output to stdout; only stderr. */
|
||||
type_status /* Exit status only. */
|
||||
} comparison_type;
|
||||
|
||||
@ -317,7 +318,12 @@ main (int argc, char **argv)
|
||||
if (fstat (STDOUT_FILENO, &outstat) == 0
|
||||
&& stat (NULL_DEVICE, &nullstat) == 0
|
||||
&& 0 < same_file (&outstat, &nullstat))
|
||||
comparison_type = type_status;
|
||||
comparison_type =
|
||||
((fstat (STDERR_FILENO, &outstat) == 0
|
||||
? 0 < same_file (&outstat, &nullstat)
|
||||
: errno == EBADF)
|
||||
? type_status
|
||||
: type_no_stdout);
|
||||
}
|
||||
|
||||
/* If only a return code is needed,
|
||||
@ -356,7 +362,7 @@ main (int argc, char **argv)
|
||||
for (f = 0; f < 2; f++)
|
||||
if (close (file_desc[f]) != 0)
|
||||
error (EXIT_TROUBLE, errno, "%s", file[f]);
|
||||
if (exit_status != 0 && comparison_type != type_status)
|
||||
if (exit_status != EXIT_SUCCESS && comparison_type < type_no_stdout)
|
||||
check_stdout ();
|
||||
exit (exit_status);
|
||||
return exit_status;
|
||||
@ -536,6 +542,9 @@ cmp (void)
|
||||
while (first_diff < smaller);
|
||||
ret = EXIT_FAILURE;
|
||||
break;
|
||||
|
||||
case type_no_stdout:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user