From: Paul Eggert Date: Mon, 11 Jul 2005 18:21:54 +0000 (+0000) Subject: (cksum): Avoid setmode; use POSIX-specified routines instead. X-Git-Tag: CPPI-1_12~272 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9824112cfa187648b200b16dda1884ff54f64e52;p=platform%2Fupstream%2Fcoreutils.git (cksum): Avoid setmode; use POSIX-specified routines instead. --- diff --git a/src/cksum.c b/src/cksum.c index 0499379..0dce68c 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;