1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-20 10:51:48 +02:00

maint: use xsetmode, not xfreopen

This fixes a bug noted by Eric Blake.  Code was using xfreopen to
change files to binary mode, but this fails for stdout when in
append mode.  Such code should use xsetmode instead.  This affects
only the port on platforms like MS-Windows which distiguish text
from binary I/O.
* bootstrap.conf (gnulib_modules):
Remove xfreopen and add xsetmode.  Sort.
* src/base64.c (main):
* src/cat.c (main):
* src/cksum.c (cksum):
* src/head.c (head_file, main):
* src/md5sum.c (digest_file):
* src/od.c (open_next_file):
* src/split.c (main):
* src/sum.c (bsd_sum_file, sysv_sum_file):
* src/tac.c (tac_file, main):
* src/tail.c (tail_file):
* src/tee.c (tee_files):
* src/tr.c (main):
* src/wc.c (wc_file): Use xsetmode, not xfreopen.
This commit is contained in:
Paul Eggert
2017-02-15 15:58:08 -08:00
parent e5cfadd6c7
commit 75aababed4
14 changed files with 38 additions and 58 deletions

View File

@@ -38,8 +38,8 @@
#include "quote.h"
#include "safe-read.h"
#include "sig2str.h"
#include "xfreopen.h"
#include "xdectoint.h"
#include "xsetmode.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no 'g' prefix). */
@@ -1553,8 +1553,7 @@ main (int argc, char **argv)
quoteaf (infile));
/* Binary I/O is safer when byte counts are used. */
if (O_BINARY && ! isatty (STDIN_FILENO))
xfreopen (NULL, "rb", stdin);
xsetmode (STDIN_FILENO, O_BINARY);
/* Get the optimal block size of input device and make a buffer. */