summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-07-11 18:21:54 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-07-11 18:21:54 +0000
commit9824112cfa187648b200b16dda1884ff54f64e52 (patch)
treed64b95391f173d158484b71a3488c9978b7f16eb /src
parent8770c00ef45e3c6c4dd3d5ce1e55a6fb1adb13dc (diff)
downloadcoreutils-9824112cfa187648b200b16dda1884ff54f64e52.tar.xz
(cksum): Avoid setmode; use POSIX-specified routines instead.
Diffstat (limited to 'src')
-rw-r--r--src/cksum.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/cksum.c b/src/cksum.c
index 0499379cc..0dce68cca 100644
--- a/src/cksum.c
+++ b/src/cksum.c
@@ -199,10 +199,12 @@ cksum (const char *file, bool print_name)
{
fp = stdin;
have_read_stdin = true;
+ if (O_BINARY && ! isatty (STDIN_FILENO))
+ freopen (NULL, "rb", stdin);
}
else
{
- fp = fopen (file, "r");
+ fp = fopen (file, (O_BINARY ? "rb" : "r"));
if (fp == NULL)
{
error (0, errno, "%s", file);
@@ -210,9 +212,6 @@ cksum (const char *file, bool print_name)
}
}
- /* Read input in BINARY mode, unless it is a console device. */
- SET_BINARY (fileno (fp));
-
while ((bytes_read = fread (buf, 1, BUFLEN, fp)) > 0)
{
unsigned char *cp = buf;