summaryrefslogtreecommitdiff
path: root/src/head.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-01-01 22:28:40 +0000
committerJim Meyering <jim@meyering.net>1999-01-01 22:28:40 +0000
commit9eedfd24825177e5ebe42bdac856ab15b8274a9c (patch)
treea3b5112d0fdc3e50190d0c14b3a8da8e8cac576c /src/head.c
parenta498f54f370473db5ad41d7f0b0ecf0d7135fa6a (diff)
downloadcoreutils-9eedfd24825177e5ebe42bdac856ab15b8274a9c.tar.xz
(head_bytes, head_lines) [O_BINARY]: Use binary I/O.
Diffstat (limited to 'src/head.c')
-rw-r--r--src/head.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/head.c b/src/head.c
index 869e450f8..474ff8bc5 100644
--- a/src/head.c
+++ b/src/head.c
@@ -1,5 +1,5 @@
/* head -- output first part of file(s)
- Copyright (C) 89, 90, 91, 95, 96, 1997, 1998 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
@@ -124,6 +124,9 @@ head_bytes (const char *filename, int fd, U_LONG_LONG bytes_to_write)
char buffer[BUFSIZE];
int bytes_read;
+ /* Need BINARY I/O for the byte counts to be accurate. */
+ SET_BINARY2 (fd, fileno (stdout));
+
while (bytes_to_write)
{
bytes_read = safe_read (fd, buffer, BUFSIZE);
@@ -150,6 +153,9 @@ head_lines (const char *filename, int fd, U_LONG_LONG lines_to_write)
int bytes_read;
int bytes_to_write;
+ /* Need BINARY I/O for the byte counts to be accurate. */
+ SET_BINARY2 (fd, fileno (stdout));
+
while (lines_to_write)
{
bytes_read = safe_read (fd, buffer, BUFSIZE);