summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cat.c5
-rw-r--r--src/cksum.c3
-rw-r--r--src/head.c5
-rw-r--r--src/md5sum.c3
-rw-r--r--src/od.c3
-rw-r--r--src/split.c3
-rw-r--r--src/sum.c5
-rw-r--r--src/tac.c5
-rw-r--r--src/tail.c5
-rw-r--r--src/tee.c5
-rw-r--r--src/tr.c5
-rw-r--r--src/wc.c3
12 files changed, 31 insertions, 19 deletions
diff --git a/src/cat.c b/src/cat.c
index 9c1996a67..543e5cf13 100644
--- a/src/cat.c
+++ b/src/cat.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
diff --git a/src/od.c b/src/od.c
index ed3b50a8c..2dcb39837 100644
--- a/src/od.c
+++ b/src/od.c
@@ -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;
diff --git a/src/sum.c b/src/sum.c
index 314656f53..4cb8f31aa 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -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
{
diff --git a/src/tac.c b/src/tac.c
index c83986f59..be8f3abcc 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -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);
diff --git a/src/tee.c b/src/tee.c
index 4e46aabb5..2d13f6d54 100644
--- a/src/tee.c
+++ b/src/tee.c
@@ -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. */
diff --git a/src/tr.c b/src/tr.c
index 0f94eef84..f4b531731 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -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)
{
diff --git a/src/wc.c b/src/wc.c
index 0bb1929f4..280d7ac88 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -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