diff options
author | Jim Meyering <jim@meyering.net> | 1999-01-01 22:48:03 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1999-01-01 22:48:03 +0000 |
commit | e60b747ade42ec381fee53e54c82b208fd1d165a (patch) | |
tree | 9b6ed06a111409c7fd493728b008a3a757f42f4a | |
parent | 7cb251e78234ecb37c412fdd3f496602badb3c8d (diff) | |
download | coreutils-e60b747ade42ec381fee53e54c82b208fd1d165a.tar.xz |
(tail_lines, tail_bytes) [O_BINARY]: Use binary I/O when appropriate.
-rw-r--r-- | src/tail.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/tail.c b/src/tail.c index e5e4e852d..d6dac195c 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1,5 +1,5 @@ /* tail -- output the last part of file(s) - Copyright (C) 89, 90, 91, 95, 96, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 89, 90, 91, 1995-1998, 1999 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -838,6 +838,10 @@ tail_bytes (const char *pretty_filename, int fd, off_t n_bytes) { 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); + /* FIXME: resolve this like in dd.c. */ /* Use fstat instead of checking for errno == ESPIPE because lseek doesn't work on some special files but doesn't return an @@ -915,6 +919,10 @@ tail_lines (const char *pretty_filename, int fd, long int n_lines) struct stat stats; off_t length; + /* 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, "%s", pretty_filename); |