assert
autobuild
backupfile
- base64
base32
+ base64
buffer-lcm
c-strcase
c-strtod
sigaction
smack
ssize_t
- statat
stat-macros
stat-size
stat-time
+ statat
stdbool
stdlib-safer
stpcpy
winsz-termios
write-any-file
xalloc
- xfreopen
+ xdectoint
xfts
xgetcwd
xgetgroups
xprintf
xprintf-posix
xreadlink
- xdectoint
+ xsetmode
xstrtod
xstrtoimax
xstrtol
#include "quote.h"
#include "xstrtol.h"
#include "xdectoint.h"
-#include "xfreopen.h"
+#include "xsetmode.h"
#define AUTHORS proper_name ("Simon Josefsson")
if (STREQ (infile, "-"))
{
- if (O_BINARY)
- xfreopen (NULL, "rb", stdin);
+ xsetmode (STDIN_FILENO, O_BINARY);
input_fh = stdin;
}
else
#include "fadvise.h"
#include "full-write.h"
#include "safe-read.h"
-#include "xfreopen.h"
+#include "xsetmode.h"
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "cat"
if (! (number || show_ends || squeeze_blank))
{
file_open_mode |= O_BINARY;
- if (O_BINARY && ! isatty (STDOUT_FILENO))
- xfreopen (NULL, "wb", stdout);
+ xsetmode (STDOUT_FILENO, O_BINARY);
}
/* 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))
- xfreopen (NULL, "rb", stdin);
+ if (file_open_mode & O_BINARY)
+ xsetmode (STDIN_FILENO, O_BINARY);
}
else
{
#include <stdint.h>
#include "system.h"
#include "fadvise.h"
-#include "xfreopen.h"
+#include "xsetmode.h"
#ifdef CRCTAB
{
fp = stdin;
have_read_stdin = true;
- if (O_BINARY && ! isatty (STDIN_FILENO))
- xfreopen (NULL, "rb", stdin);
+ xsetmode (STDIN_FILENO, O_BINARY);
}
else
{
#include "quote.h"
#include "safe-read.h"
#include "stat-size.h"
-#include "xfreopen.h"
#include "xdectoint.h"
+#include "xsetmode.h"
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "head"
have_read_stdin = true;
fd = STDIN_FILENO;
filename = _("standard input");
- if (O_BINARY && ! isatty (STDIN_FILENO))
- xfreopen (NULL, "rb", stdin);
+ xsetmode (STDIN_FILENO, O_BINARY);
}
else
{
? (char const *const *) &argv[optind]
: default_file_list);
- if (O_BINARY && ! isatty (STDOUT_FILENO))
- xfreopen (NULL, "wb", stdout);
+ xsetmode (STDOUT_FILENO, O_BINARY);
for (i = 0; file_list[i]; ++i)
ok &= head_file (file_list[i], n_units, count_lines, elide_from_end);
#include "error.h"
#include "fadvise.h"
#include "stdio--.h"
-#include "xfreopen.h"
+#include "xsetmode.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)
- xfreopen (NULL, "rb", stdin);
+ xsetmode (STDIN_FILENO, O_BINARY);
}
}
else
#include "ftoastr.h"
#include "quote.h"
#include "stat-size.h"
-#include "xfreopen.h"
#include "xprintf.h"
+#include "xsetmode.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no 'g' prefix). */
input_filename = _("standard input");
in_stream = stdin;
have_read_stdin = true;
- if (O_BINARY && ! isatty (STDIN_FILENO))
- xfreopen (NULL, "rb", stdin);
+ xsetmode (STDIN_FILENO, O_BINARY);
}
else
{
#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). */
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. */
#include "fadvise.h"
#include "human.h"
#include "safe-read.h"
-#include "xfreopen.h"
+#include "xsetmode.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))
- xfreopen (NULL, "rb", stdin);
+ xsetmode (STDIN_FILENO, O_BINARY);
}
else
{
{
fd = STDIN_FILENO;
have_read_stdin = true;
- if (O_BINARY && ! isatty (STDIN_FILENO))
- xfreopen (NULL, "rb", stdin);
+ xsetmode (STDIN_FILENO, O_BINARY);
}
else
{
#include "filenamecat.h"
#include "safe-read.h"
#include "stdlib--.h"
-#include "xfreopen.h"
+#include "xsetmode.h"
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "tac"
have_read_stdin = true;
fd = STDIN_FILENO;
filename = _("standard input");
- if (O_BINARY && ! isatty (STDIN_FILENO))
- xfreopen (NULL, "rb", stdin);
+ xsetmode (STDIN_FILENO, O_BINARY);
}
else
{
? (char const *const *) &argv[optind]
: default_file_list);
- if (O_BINARY && ! isatty (STDOUT_FILENO))
- xfreopen (NULL, "wb", stdout);
+ xsetmode (STDOUT_FILENO, O_BINARY);
{
size_t i;
#include "safe-read.h"
#include "stat-size.h"
#include "stat-time.h"
-#include "xfreopen.h"
#include "xnanosleep.h"
#include "xdectoint.h"
+#include "xsetmode.h"
#include "xstrtol.h"
#include "xstrtod.h"
{
have_read_stdin = true;
fd = STDIN_FILENO;
- if (O_BINARY && ! isatty (STDIN_FILENO))
- xfreopen (NULL, "rb", stdin);
+ xsetmode (STDIN_FILENO, O_BINARY);
}
else
fd = open (f->name, O_RDONLY | O_BINARY);
|| (header_mode == multiple_files && n_files > 1))
print_headers = true;
- if (O_BINARY && ! isatty (STDOUT_FILENO))
- xfreopen (NULL, "wb", stdout);
+ xsetmode (STDOUT_FILENO, O_BINARY);
for (i = 0; i < n_files; i++)
ok &= tail_file (&F[i], n_units);
#include "error.h"
#include "fadvise.h"
#include "stdio--.h"
-#include "xfreopen.h"
+#include "xsetmode.h"
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "tee"
? (append ? "ab" : "wb")
: (append ? "a" : "w"));
- if (O_BINARY && ! isatty (STDIN_FILENO))
- xfreopen (NULL, "rb", stdin);
- if (O_BINARY && ! isatty (STDOUT_FILENO))
- xfreopen (NULL, "wb", stdout);
-
+ xsetmode (STDIN_FILENO, O_BINARY);
+ xsetmode (STDOUT_FILENO, O_BINARY);
fadvise (stdin, FADVISE_SEQUENTIAL);
/* Set up FILES[0 .. NFILES] and DESCRIPTORS[0 .. NFILES].
#include "fadvise.h"
#include "quote.h"
#include "safe-read.h"
-#include "xfreopen.h"
+#include "xsetmode.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no 'g' prefix). */
/* Use binary I/O, since 'tr' is sometimes used to transliterate
non-printable characters, or characters which are stripped away
by text-mode reads (like CR and ^Z). */
- if (O_BINARY && ! isatty (STDIN_FILENO))
- xfreopen (NULL, "rb", stdin);
- if (O_BINARY && ! isatty (STDOUT_FILENO))
- xfreopen (NULL, "wb", stdout);
-
+ xsetmode (STDIN_FILENO, O_BINARY);
+ xsetmode (STDOUT_FILENO, O_BINARY);
fadvise (stdin, FADVISE_SEQUENTIAL);
if (squeeze_repeats && non_option_args == 1)
#include "readtokens0.h"
#include "safe-read.h"
#include "stat-size.h"
-#include "xfreopen.h"
+#include "xsetmode.h"
#if !defined iswspace && !HAVE_ISWSPACE
# define iswspace(wc) \
if (! file || STREQ (file, "-"))
{
have_read_stdin = true;
- if (O_BINARY && ! isatty (STDIN_FILENO))
- xfreopen (NULL, "rb", stdin);
+ xsetmode (STDIN_FILENO, O_BINARY);
return wc (STDIN_FILENO, file, fstatus, -1);
}
else