]> git.ipfire.org Git - thirdparty/coreutils.git/commit
maint: use clearerr on stdin when appropriate
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 22 Aug 2021 18:54:44 +0000 (11:54 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 22 Aug 2021 20:10:26 +0000 (13:10 -0700)
commit88846befff58d181c5f77d50ec4b11980af16563
treefec8553f98b934baed2efa7435b214c6836b479d
parent4d355e52703633a0f8416aeacabd9586a35305a8
maint: use clearerr on stdin when appropriate

This is so that commands like ‘fmt - -’ read from stdin
both times, even when it is a tty.  Fix some other minor
issues that are related.
* src/blake2/b2sum.c (main):
* src/cksum.c (cksum):
* src/cut.c (cut_file):
* src/expand-common.c (next_file):
* src/fmt.c (fmt):
* src/fold.c (fold_file):
* src/md5sum.c (digest_file, digest_check):
* src/nl.c (nl_file):
* src/od.c (check_and_close):
* src/paste.c (paste_parallel, paste_serial):
* src/pr.c (close_file):
* src/sum.c (bsd_sum_file):
Use clearerr on stdin so that stdin can be read multiple times
even if it is a tty.  Do not assume that ferror preserves errno as
POSIX does not guarantee this.  Coalesce duplicate diagnostic
calls.
* src/blake2/b2sum.c (main):
* src/fmt.c (main, fmt):
Report read error, even if it's merely fclose failure.
* src/fmt.c: Include die.h.
(fmt): New arg FILE.  Close input (reporting error) if not stdin.
All callers changed.
* src/ptx.c (swallow_file_in_memory): Clear stdin's EOF flag.
* src/sort.c (xfclose): Remove unnecessary feof call.
14 files changed:
src/blake2/b2sum.c
src/cksum.c
src/cut.c
src/expand-common.c
src/fmt.c
src/fold.c
src/md5sum.c
src/nl.c
src/od.c
src/paste.c
src/pr.c
src/ptx.c
src/sort.c
src/sum.c