* bootstrap.conf (modules): Add xfreopen.
* src/cat.c (main): Include "xfreopen.h". Use xfreopen.
* src/cksum.c (cksum): Likewise.
* src/head.c (head_file, main): Likewise.
* src/md5sum.c (digest_file): Likewise.
* src/od.c (open_next_file): Likewise.
* src/split.c (type_undef): Likewise.
* src/sum.c (bsd_sum_file, sysv_sum_file): Likewise.
* src/tac.c (tac_file, main): Likewise.
* src/tail.c (tail_file, main): Likewise.
* src/tee.c (tee_files): Likewise.
* src/tr.c (main): Likewise.
* src/wc.c (wc_file): Likewise.
* po/POTFILES.in: Add lib/xfreopen.c
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
lib/userspec.c
lib/version-etc.c
lib/xalloc-die.c
+lib/xfreopen.c
lib/xfts.c
lib/xmemcoll.c
lib/xmemxfrm.c
#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"
{
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. */
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
{
#include <sys/types.h>
#include <stdint.h>
#include "system.h"
+#include "xfreopen.h"
#ifdef CRCTAB
fp = stdin;
have_read_stdin = true;
if (O_BINARY && ! isatty (STDIN_FILENO))
- freopen (NULL, "rb", stdin);
+ xfreopen (NULL, "rb", stdin);
}
else
{
#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). */
fd = STDIN_FILENO;
filename = _("standard input");
if (O_BINARY && ! isatty (STDIN_FILENO))
- freopen (NULL, "rb", stdin);
+ xfreopen (NULL, "rb", stdin);
}
else
{
: 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);
#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
if (*binary < 0)
*binary = ! isatty (STDIN_FILENO);
if (*binary)
- freopen (NULL, "rb", stdin);
+ xfreopen (NULL, "rb", stdin);
}
}
else
#include "system.h"
#include "error.h"
#include "quote.h"
+#include "xfreopen.h"
#include "xprintf.h"
#include "xstrtol.h"
in_stream = stdin;
have_read_stdin = true;
if (O_BINARY && ! isatty (STDIN_FILENO))
- freopen (NULL, "rb", stdin);
+ xfreopen (NULL, "rb", stdin);
}
else
{
#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). */
/* 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;
#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"
fp = stdin;
have_read_stdin = true;
if (O_BINARY && ! isatty (STDIN_FILENO))
- freopen (NULL, "rb", stdin);
+ xfreopen (NULL, "rb", stdin);
}
else
{
fd = STDIN_FILENO;
have_read_stdin = true;
if (O_BINARY && ! isatty (STDIN_FILENO))
- freopen (NULL, "rb", stdin);
+ xfreopen (NULL, "rb", stdin);
}
else
{
#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"
fd = STDIN_FILENO;
filename = _("standard input");
if (O_BINARY && ! isatty (STDIN_FILENO))
- freopen (NULL, "rb", stdin);
+ xfreopen (NULL, "rb", stdin);
}
else
{
: default_file_list);
if (O_BINARY && ! isatty (STDOUT_FILENO))
- freopen (NULL, "wb", stdout);
+ xfreopen (NULL, "wb", stdout);
{
size_t i;
#include "quote.h"
#include "safe-read.h"
#include "stat-time.h"
+#include "xfreopen.h"
#include "xnanosleep.h"
#include "xstrtol.h"
#include "xstrtod.h"
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);
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);
#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"
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. */
#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). */
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)
{
#include "quotearg.h"
#include "readtokens0.h"
#include "safe-read.h"
+#include "xfreopen.h"
#if !defined iswspace && !HAVE_ISWSPACE
# define iswspace(wc) \
{
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