diff options
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; |