diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-07-11 18:21:54 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-07-11 18:21:54 +0000 |
commit | 9824112cfa187648b200b16dda1884ff54f64e52 (patch) | |
tree | d64b95391f173d158484b71a3488c9978b7f16eb /src | |
parent | 8770c00ef45e3c6c4dd3d5ce1e55a6fb1adb13dc (diff) | |
download | coreutils-9824112cfa187648b200b16dda1884ff54f64e52.tar.xz |
(cksum): Avoid setmode; use POSIX-specified routines instead.
Diffstat (limited to 'src')
-rw-r--r-- | src/cksum.c | 7 |
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; |