diff options
-rw-r--r-- | bootstrap.conf | 4 | ||||
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | src/cat.c | 5 | ||||
-rw-r--r-- | src/cksum.c | 3 | ||||
-rw-r--r-- | src/head.c | 5 | ||||
-rw-r--r-- | src/md5sum.c | 3 | ||||
-rw-r--r-- | src/od.c | 3 | ||||
-rw-r--r-- | src/split.c | 3 | ||||
-rw-r--r-- | src/sum.c | 5 | ||||
-rw-r--r-- | src/tac.c | 5 | ||||
-rw-r--r-- | src/tail.c | 5 | ||||
-rw-r--r-- | src/tee.c | 5 | ||||
-rw-r--r-- | src/tr.c | 5 | ||||
-rw-r--r-- | src/wc.c | 3 |
14 files changed, 35 insertions, 20 deletions
diff --git a/bootstrap.conf b/bootstrap.conf index 338dada3a..aae307cbc 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -99,7 +99,9 @@ gnulib_modules=" vc-list-files verify version-etc-fsf wcwidth winsz-ioctl winsz-termios write-any-file - xalloc xgetcwd xgethostname + xalloc + xfreopen + xgetcwd xgethostname xmemcoll xnanosleep xprintf xprintf-posix diff --git a/po/POTFILES.in b/po/POTFILES.in index c8e97d6df..8a6e541f4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -24,6 +24,7 @@ lib/unicodeio.c lib/userspec.c lib/version-etc.c lib/xalloc-die.c +lib/xfreopen.c lib/xfts.c lib/xmemcoll.c lib/xmemxfrm.c @@ -39,6 +39,7 @@ #include "full-write.h" #include "quote.h" #include "safe-read.h" +#include "xfreopen.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "cat" @@ -664,7 +665,7 @@ main (int argc, char **argv) { file_open_mode |= O_BINARY; if (O_BINARY && ! isatty (STDOUT_FILENO)) - freopen (NULL, "wb", stdout); + xfreopen (NULL, "wb", stdout); } /* Check if any of the input files are the same as the output file. */ @@ -684,7 +685,7 @@ main (int argc, char **argv) have_read_stdin = true; input_desc = STDIN_FILENO; if ((file_open_mode & O_BINARY) && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { diff --git a/src/cksum.c b/src/cksum.c index 8bbed37f9..2893d303b 100644 --- a/src/cksum.c +++ b/src/cksum.c @@ -43,6 +43,7 @@ #include <sys/types.h> #include <stdint.h> #include "system.h" +#include "xfreopen.h" #ifdef CRCTAB @@ -192,7 +193,7 @@ cksum (const char *file, bool print_name) fp = stdin; have_read_stdin = true; if (O_BINARY && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { diff --git a/src/head.c b/src/head.c index 0ef912a58..7f90d4b29 100644 --- a/src/head.c +++ b/src/head.c @@ -36,6 +36,7 @@ #include "full-read.h" #include "quote.h" #include "safe-read.h" +#include "xfreopen.h" #include "xstrtol.h" /* The official name of this program (e.g., no `g' prefix). */ @@ -838,7 +839,7 @@ head_file (const char *filename, uintmax_t n_units, bool count_lines, fd = STDIN_FILENO; filename = _("standard input"); if (O_BINARY && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { @@ -1051,7 +1052,7 @@ main (int argc, char **argv) : default_file_list); if (O_BINARY && ! isatty (STDOUT_FILENO)) - freopen (NULL, "wb", stdout); + xfreopen (NULL, "wb", stdout); for (i = 0; file_list[i]; ++i) ok &= head_file (file_list[i], n_units, count_lines, elide_from_end); diff --git a/src/md5sum.c b/src/md5sum.c index 238c02ee6..d31a780bf 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -37,6 +37,7 @@ #endif #include "error.h" #include "stdio--.h" +#include "xfreopen.h" /* The official name of this program (e.g., no `g' prefix). */ #if HASH_ALGO_MD5 @@ -391,7 +392,7 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result) if (*binary < 0) *binary = ! isatty (STDIN_FILENO); if (*binary) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } } else @@ -25,6 +25,7 @@ #include "system.h" #include "error.h" #include "quote.h" +#include "xfreopen.h" #include "xprintf.h" #include "xstrtol.h" @@ -864,7 +865,7 @@ open_next_file (void) in_stream = stdin; have_read_stdin = true; if (O_BINARY && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { diff --git a/src/split.c b/src/split.c index 85687c407..be182eff6 100644 --- a/src/split.c +++ b/src/split.c @@ -34,6 +34,7 @@ #include "full-write.h" #include "quote.h" #include "safe-read.h" +#include "xfreopen.h" #include "xstrtol.h" /* The official name of this program (e.g., no `g' prefix). */ @@ -544,7 +545,7 @@ main (int argc, char **argv) /* Binary I/O is safer when bytecounts are used. */ if (O_BINARY && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); /* No output file is open now. */ output_desc = -1; @@ -28,6 +28,7 @@ #include "error.h" #include "human.h" #include "safe-read.h" +#include "xfreopen.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "sum" @@ -97,7 +98,7 @@ bsd_sum_file (const char *file, int print_name) fp = stdin; have_read_stdin = true; if (O_BINARY && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { @@ -165,7 +166,7 @@ sysv_sum_file (const char *file, int print_name) fd = STDIN_FILENO; have_read_stdin = true; if (O_BINARY && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { @@ -48,6 +48,7 @@ tac -r -s '.\| #include "quotearg.h" #include "safe-read.h" #include "stdlib--.h" +#include "xfreopen.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "tac" @@ -533,7 +534,7 @@ tac_file (const char *filename) fd = STDIN_FILENO; filename = _("standard input"); if (O_BINARY && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { @@ -647,7 +648,7 @@ main (int argc, char **argv) : default_file_list); if (O_BINARY && ! isatty (STDOUT_FILENO)) - freopen (NULL, "wb", stdout); + xfreopen (NULL, "wb", stdout); { size_t i; diff --git a/src/tail.c b/src/tail.c index 43fd6d412..6ad6d4330 100644 --- a/src/tail.c +++ b/src/tail.c @@ -40,6 +40,7 @@ #include "quote.h" #include "safe-read.h" #include "stat-time.h" +#include "xfreopen.h" #include "xnanosleep.h" #include "xstrtol.h" #include "xstrtod.h" @@ -1273,7 +1274,7 @@ tail_file (struct File_spec *f, uintmax_t n_units) have_read_stdin = true; fd = STDIN_FILENO; if (O_BINARY && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else fd = open (f->name, O_RDONLY | O_BINARY); @@ -1683,7 +1684,7 @@ main (int argc, char **argv) print_headers = true; if (O_BINARY && ! isatty (STDOUT_FILENO)) - freopen (NULL, "wb", stdout); + xfreopen (NULL, "wb", stdout); for (i = 0; i < n_files; i++) ok &= tail_file (&F[i], n_units); @@ -24,6 +24,7 @@ #include "system.h" #include "error.h" #include "stdio--.h" +#include "xfreopen.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "tee" @@ -152,9 +153,9 @@ tee_files (int nfiles, const char **files) files[i] = files[i - 1]; if (O_BINARY && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); if (O_BINARY && ! isatty (STDOUT_FILENO)) - freopen (NULL, "wb", stdout); + xfreopen (NULL, "wb", stdout); /* In the array of NFILES + 1 descriptors, make the first one correspond to standard output. */ @@ -27,6 +27,7 @@ #include "error.h" #include "quote.h" #include "safe-read.h" +#include "xfreopen.h" #include "xstrtol.h" /* The official name of this program (e.g., no `g' prefix). */ @@ -1750,9 +1751,9 @@ main (int argc, char **argv) non-printable characters, or characters which are stripped away by text-mode reads (like CR and ^Z). */ if (O_BINARY && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); if (O_BINARY && ! isatty (STDOUT_FILENO)) - freopen (NULL, "wb", stdout); + xfreopen (NULL, "wb", stdout); if (squeeze_repeats && non_option_args == 1) { @@ -32,6 +32,7 @@ #include "quotearg.h" #include "readtokens0.h" #include "safe-read.h" +#include "xfreopen.h" #if !defined iswspace && !HAVE_ISWSPACE # define iswspace(wc) \ @@ -486,7 +487,7 @@ wc_file (char const *file, struct fstatus *fstatus) { have_read_stdin = true; if (O_BINARY && ! isatty (STDIN_FILENO)) - freopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); return wc (STDIN_FILENO, file, fstatus); } else |