{
struct stat stats;
- /* We need binary input, since `tail' relies on `lseek' and byte counts,
- while binary output will preserve the style (Unix/DOS) of text file. */
- SET_BINARY2 (fd, STDOUT_FILENO);
-
if (fstat (fd, &stats))
{
error (0, errno, _("cannot fstat %s"), quote (pretty_filename));
{
struct stat stats;
- /* We need binary input, since `tail' relies on `lseek' and byte counts,
- while binary output will preserve the style (Unix/DOS) of text file. */
- SET_BINARY2 (fd, STDOUT_FILENO);
-
if (fstat (fd, &stats))
{
error (0, errno, _("cannot fstat %s"), quote (pretty_filename));
{
have_read_stdin = true;
fd = STDIN_FILENO;
+ if (O_BINARY && ! isatty (STDIN_FILENO))
+ freopen (NULL, "rb", stdin);
}
else
- fd = open (f->name, O_RDONLY);
+ fd = open (f->name, O_RDONLY | O_BINARY);
f->tailable = !(reopen_inaccessible_files && fd == -1);
|| (header_mode == multiple_files && n_files > 1))
print_headers = true;
+ if (O_BINARY && ! isatty (STDOUT_FILENO))
+ freopen (NULL, "wb", stdout);
+
for (i = 0; i < n_files; i++)
ok &= tail_file (&F[i], n_units);