mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
all: use die() rather than error(EXIT_FAILURE)
die() has the advantage of being apparent to the compiler that it doesn't return, which will avoid warnings in some cases, and possibly generate better code. * cfg.mk (sc_die_EXIT_FAILURE): A new syntax check rule to catch any new uses of error (CONSTANT, ...);
This commit is contained in:
1 parent
d035eacfde
commit
492dcb2eb1
84 files changed
+875
-800
No files matched your search
@@ -226,6 +226,16 @@ sc_error_shell_always_quotes:
|
||||
exit 1; } \
|
||||
|| :
|
||||
|
||||
# Usage of error() with an exit constant, should instead use die(),
|
||||
# as that avoids warnings and may generate better code, due to being apparent
|
||||
# to the compiler that it doesn't return.
|
||||
sc_die_EXIT_FAILURE:
|
||||
@cd $(srcdir)/src && GIT_PAGER= git grep -E \
|
||||
'error \(.*_(FAILURE|INVALID)' \
|
||||
&& { echo '$(ME): '"Use die() instead of error" 1>&2; \
|
||||
exit 1; } \
|
||||
|| :
|
||||
|
||||
# Avoid unstyled quoting to internal slots and thus destined for diagnostics
|
||||
# as that can leak unescaped control characters to the output, when using
|
||||
# the default "literal" quoting style.
|
||||
|
||||
+12
-11
@@ -25,6 +25,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "quote.h"
|
||||
@@ -135,7 +136,7 @@ wrap_write (const char *buffer, size_t len,
|
||||
{
|
||||
/* Simple write. */
|
||||
if (fwrite (buffer, 1, len, stdout) < len)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
else
|
||||
for (written = 0; written < len;)
|
||||
@@ -147,13 +148,13 @@ wrap_write (const char *buffer, size_t len,
|
||||
if (to_write == 0)
|
||||
{
|
||||
if (fputc ('\n', out) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
*current_column = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fwrite (buffer + written, 1, to_write, stdout) < to_write)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
*current_column += to_write;
|
||||
written += to_write;
|
||||
}
|
||||
@@ -194,10 +195,10 @@ do_encode (FILE *in, FILE *out, uintmax_t wrap_column)
|
||||
|
||||
/* When wrapping, terminate last line. */
|
||||
if (wrap_column && current_column > 0 && fputc ('\n', out) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
if (ferror (in))
|
||||
error (EXIT_FAILURE, errno, _("read error"));
|
||||
die (EXIT_FAILURE, errno, _("read error"));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -234,7 +235,7 @@ do_decode (FILE *in, FILE *out, bool ignore_garbage)
|
||||
sum += n;
|
||||
|
||||
if (ferror (in))
|
||||
error (EXIT_FAILURE, errno, _("read error"));
|
||||
die (EXIT_FAILURE, errno, _("read error"));
|
||||
}
|
||||
while (sum < BASE_LENGTH (DEC_BLOCKSIZE) && !feof (in));
|
||||
|
||||
@@ -250,10 +251,10 @@ do_decode (FILE *in, FILE *out, bool ignore_garbage)
|
||||
ok = base_decode_ctx (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n);
|
||||
|
||||
if (fwrite (outbuf, 1, n, out) < n)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
if (!ok)
|
||||
error (EXIT_FAILURE, 0, _("invalid input"));
|
||||
die (EXIT_FAILURE, 0, _("invalid input"));
|
||||
}
|
||||
}
|
||||
while (!feof (in));
|
||||
@@ -327,7 +328,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
input_fh = fopen (infile, "rb");
|
||||
if (input_fh == NULL)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
}
|
||||
|
||||
fadvise (input_fh, FADVISE_SEQUENTIAL);
|
||||
@@ -340,9 +341,9 @@ main (int argc, char **argv)
|
||||
if (fclose (input_fh) == EOF)
|
||||
{
|
||||
if (STREQ (infile, "-"))
|
||||
error (EXIT_FAILURE, errno, _("closing standard input"));
|
||||
die (EXIT_FAILURE, errno, _("closing standard input"));
|
||||
else
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "ioblksize.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "full-write.h"
|
||||
@@ -183,7 +184,7 @@ simple_cat (
|
||||
/* The following is ok, since we know that 0 < n_read. */
|
||||
size_t n = n_read;
|
||||
if (full_write (STDOUT_FILENO, buf, n) != n)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,7 +200,7 @@ write_pending (char *outbuf, char **bpout)
|
||||
if (0 < n_write)
|
||||
{
|
||||
if (full_write (STDOUT_FILENO, outbuf, n_write) != n_write)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
*bpout = outbuf;
|
||||
}
|
||||
}
|
||||
@@ -283,7 +284,7 @@ cat (
|
||||
do
|
||||
{
|
||||
if (full_write (STDOUT_FILENO, wp, outsize) != outsize)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
wp += outsize;
|
||||
remaining_bytes = bpout - wp;
|
||||
}
|
||||
@@ -634,7 +635,7 @@ main (int argc, char **argv)
|
||||
/* Get device, i-node number, and optimal blocksize of output. */
|
||||
|
||||
if (fstat (STDOUT_FILENO, &stat_buf) < 0)
|
||||
error (EXIT_FAILURE, errno, _("standard output"));
|
||||
die (EXIT_FAILURE, errno, _("standard output"));
|
||||
|
||||
outsize = io_blksize (stat_buf);
|
||||
out_dev = stat_buf.st_dev;
|
||||
@@ -761,7 +762,7 @@ main (int argc, char **argv)
|
||||
while (++argind < argc);
|
||||
|
||||
if (have_read_stdin && close (STDIN_FILENO) < 0)
|
||||
error (EXIT_FAILURE, errno, _("closing standard input"));
|
||||
die (EXIT_FAILURE, errno, _("closing standard input"));
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
+10
-9
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "dev-ino.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "ignore-value.h"
|
||||
#include "quote.h"
|
||||
@@ -512,14 +513,14 @@ main (int argc, char **argv)
|
||||
if (bit_flags == FTS_PHYSICAL)
|
||||
{
|
||||
if (dereference == 1)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
affect_symlink_referent = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dereference == 0)
|
||||
error (EXIT_FAILURE, 0, _("-R -h requires -P"));
|
||||
die (EXIT_FAILURE, 0, _("-R -h requires -P"));
|
||||
affect_symlink_referent = true;
|
||||
}
|
||||
}
|
||||
@@ -543,8 +544,8 @@ main (int argc, char **argv)
|
||||
char *ref_context = NULL;
|
||||
|
||||
if (getfilecon (reference_file, &ref_context) < 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to get security context of %s"),
|
||||
quoteaf (reference_file));
|
||||
die (EXIT_FAILURE, errno, _("failed to get security context of %s"),
|
||||
quoteaf (reference_file));
|
||||
|
||||
specified_context = ref_context;
|
||||
}
|
||||
@@ -557,8 +558,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
specified_context = argv[optind++];
|
||||
if (security_check_context (se_const (specified_context)) < 0)
|
||||
error (EXIT_FAILURE, errno, _("invalid context: %s"),
|
||||
quote (specified_context));
|
||||
die (EXIT_FAILURE, errno, _("invalid context: %s"),
|
||||
quote (specified_context));
|
||||
}
|
||||
|
||||
if (reference_file && component_specified)
|
||||
@@ -572,8 +573,8 @@ main (int argc, char **argv)
|
||||
static struct dev_ino dev_ino_buf;
|
||||
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (root_dev_ino == NULL)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+9
-8
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "chown-core.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fts_.h"
|
||||
#include "quote.h"
|
||||
@@ -89,8 +90,8 @@ parse_group (const char *name)
|
||||
unsigned long int tmp;
|
||||
if (! (xstrtoul (name, NULL, 10, &tmp, "") == LONGINT_OK
|
||||
&& tmp <= GID_T_MAX))
|
||||
error (EXIT_FAILURE, 0, _("invalid group: %s"),
|
||||
quote (name));
|
||||
die (EXIT_FAILURE, 0, _("invalid group: %s"),
|
||||
quote (name));
|
||||
gid = tmp;
|
||||
}
|
||||
endgrent (); /* Save a file descriptor. */
|
||||
@@ -261,8 +262,8 @@ main (int argc, char **argv)
|
||||
if (bit_flags == FTS_PHYSICAL)
|
||||
{
|
||||
if (dereference == 1)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
dereference = 0;
|
||||
}
|
||||
}
|
||||
@@ -285,8 +286,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
struct stat ref_stats;
|
||||
if (stat (reference_file, &ref_stats))
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
|
||||
gid = ref_stats.st_gid;
|
||||
chopt.group_name = gid_to_name (ref_stats.st_gid);
|
||||
@@ -303,8 +304,8 @@ main (int argc, char **argv)
|
||||
static struct dev_ino dev_ino_buf;
|
||||
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (chopt.root_dev_ino == NULL)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
|
||||
bit_flags |= FTS_DEFER_STAT;
|
||||
|
||||
+5
-4
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "dev-ino.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "filemode.h"
|
||||
#include "ignore-value.h"
|
||||
@@ -535,8 +536,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
change = mode_create_from_ref (reference_file);
|
||||
if (!change)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -554,8 +555,8 @@ main (int argc, char **argv)
|
||||
static struct dev_ino dev_ino_buf;
|
||||
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (root_dev_ino == NULL)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+9
-8
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "chown-core.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fts_.h"
|
||||
#include "quote.h"
|
||||
@@ -230,7 +231,7 @@ main (int argc, char **argv)
|
||||
&required_uid, &required_gid,
|
||||
NULL, NULL);
|
||||
if (e)
|
||||
error (EXIT_FAILURE, 0, "%s: %s", e, quote (optarg));
|
||||
die (EXIT_FAILURE, 0, "%s: %s", e, quote (optarg));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -262,8 +263,8 @@ main (int argc, char **argv)
|
||||
if (bit_flags == FTS_PHYSICAL)
|
||||
{
|
||||
if (dereference == 1)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("-R --dereference requires either -H or -L"));
|
||||
dereference = 0;
|
||||
}
|
||||
}
|
||||
@@ -286,8 +287,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
struct stat ref_stats;
|
||||
if (stat (reference_file, &ref_stats))
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf (reference_file));
|
||||
|
||||
uid = ref_stats.st_uid;
|
||||
gid = ref_stats.st_gid;
|
||||
@@ -299,7 +300,7 @@ main (int argc, char **argv)
|
||||
const char *e = parse_user_spec (argv[optind], &uid, &gid,
|
||||
&chopt.user_name, &chopt.group_name);
|
||||
if (e)
|
||||
error (EXIT_FAILURE, 0, "%s: %s", e, quote (argv[optind]));
|
||||
die (EXIT_FAILURE, 0, "%s: %s", e, quote (argv[optind]));
|
||||
|
||||
/* If a group is specified but no user, set the user name to the
|
||||
empty string so that diagnostics say "ownership :GROUP"
|
||||
@@ -315,8 +316,8 @@ main (int argc, char **argv)
|
||||
static struct dev_ino dev_ino_buf;
|
||||
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (chopt.root_dev_ino == NULL)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
|
||||
bit_flags |= FTS_DEFER_STAT;
|
||||
|
||||
+12
-11
@@ -24,6 +24,7 @@
|
||||
#include <grp.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "ignore-value.h"
|
||||
#include "mgetgroups.h"
|
||||
@@ -326,11 +327,11 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (chroot (newroot) != 0)
|
||||
error (EXIT_CANCELED, errno, _("cannot change root directory to %s"),
|
||||
quoteaf (newroot));
|
||||
die (EXIT_CANCELED, errno, _("cannot change root directory to %s"),
|
||||
quoteaf (newroot));
|
||||
|
||||
if (! skip_chdir && chdir ("/"))
|
||||
error (EXIT_CANCELED, errno, _("cannot chdir to root directory"));
|
||||
die (EXIT_CANCELED, errno, _("cannot chdir to root directory"));
|
||||
|
||||
if (argc == optind + 1)
|
||||
{
|
||||
@@ -355,7 +356,7 @@ main (int argc, char **argv)
|
||||
char const *err = parse_user_spec (userspec, &uid, &gid, NULL, NULL);
|
||||
|
||||
if (err && uid_unset (uid) && gid_unset (gid))
|
||||
error (EXIT_CANCELED, errno, "%s", (err));
|
||||
die (EXIT_CANCELED, errno, "%s", (err));
|
||||
}
|
||||
|
||||
/* If no gid is supplied or looked up, do so now.
|
||||
@@ -371,8 +372,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
else if (gid_unset (gid))
|
||||
{
|
||||
error (EXIT_CANCELED, errno,
|
||||
_("no group specified for unknown uid: %d"), (int) uid);
|
||||
die (EXIT_CANCELED, errno,
|
||||
_("no group specified for unknown uid: %d"), (int) uid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,8 +397,8 @@ main (int argc, char **argv)
|
||||
if (ngroups <= 0)
|
||||
{
|
||||
if (! n_gids)
|
||||
error (EXIT_CANCELED, errno,
|
||||
_("failed to get supplemental groups"));
|
||||
die (EXIT_CANCELED, errno,
|
||||
_("failed to get supplemental groups"));
|
||||
/* else look-up outside the chroot worked, then go with those. */
|
||||
}
|
||||
else
|
||||
@@ -409,16 +410,16 @@ main (int argc, char **argv)
|
||||
#endif
|
||||
|
||||
if ((uid_set (uid) || groups) && setgroups (n_gids, gids) != 0)
|
||||
error (EXIT_CANCELED, errno, _("failed to set supplemental groups"));
|
||||
die (EXIT_CANCELED, errno, _("failed to set supplemental groups"));
|
||||
|
||||
free (in_gids);
|
||||
free (out_gids);
|
||||
|
||||
if (gid_set (gid) && setgid (gid))
|
||||
error (EXIT_CANCELED, errno, _("failed to set group-ID"));
|
||||
die (EXIT_CANCELED, errno, _("failed to set group-ID"));
|
||||
|
||||
if (uid_set (uid) && setuid (uid))
|
||||
error (EXIT_CANCELED, errno, _("failed to set user-ID"));
|
||||
die (EXIT_CANCELED, errno, _("failed to set user-ID"));
|
||||
|
||||
/* Execute the given command. */
|
||||
execvp (argv[0], argv);
|
||||
|
||||
+4
-3
@@ -109,6 +109,7 @@ main (void)
|
||||
|
||||
# include <getopt.h>
|
||||
# include "long-options.h"
|
||||
# include "die.h"
|
||||
# include "error.h"
|
||||
|
||||
/* Number of bytes to read at once. */
|
||||
@@ -213,7 +214,7 @@ cksum (const char *file, bool print_name)
|
||||
unsigned char *cp = buf;
|
||||
|
||||
if (length + bytes_read < length)
|
||||
error (EXIT_FAILURE, 0, _("%s: file too long"), quotef (file));
|
||||
die (EXIT_FAILURE, 0, _("%s: file too long"), quotef (file));
|
||||
length += bytes_read;
|
||||
while (bytes_read--)
|
||||
crc = (crc << 8) ^ crctab[((crc >> 24) ^ *cp++) & 0xFF];
|
||||
@@ -248,7 +249,7 @@ cksum (const char *file, bool print_name)
|
||||
printf ("%u %s\n", (unsigned int) crc, hp);
|
||||
|
||||
if (ferror (stdout))
|
||||
error (EXIT_FAILURE, errno, "-: %s", _("write error"));
|
||||
die (EXIT_FAILURE, errno, "-: %s", _("write error"));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -311,7 +312,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
die (EXIT_FAILURE, errno, "-");
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -22,6 +22,7 @@
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "linebuffer.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "hard-locale.h"
|
||||
@@ -277,14 +278,14 @@ compare_files (char **infiles)
|
||||
alt[i][2] = 0;
|
||||
streams[i] = (STREQ (infiles[i], "-") ? stdin : fopen (infiles[i], "r"));
|
||||
if (!streams[i])
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
|
||||
|
||||
fadvise (streams[i], FADVISE_SEQUENTIAL);
|
||||
|
||||
thisline[i] = readlinebuffer_delim (all_line[i][alt[i][0]], streams[i],
|
||||
delim);
|
||||
if (ferror (streams[i]))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
|
||||
}
|
||||
|
||||
while (thisline[0] || thisline[1])
|
||||
@@ -355,7 +356,7 @@ compare_files (char **infiles)
|
||||
all_line[i][alt[i][1]], i + 1);
|
||||
|
||||
if (ferror (streams[i]))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
|
||||
|
||||
fill_up[i] = false;
|
||||
}
|
||||
@@ -363,7 +364,7 @@ compare_files (char **infiles)
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
if (fclose (streams[i]) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
|
||||
}
|
||||
|
||||
int
|
||||
@@ -417,7 +418,7 @@ main (int argc, char **argv)
|
||||
|
||||
case OUTPUT_DELIMITER_OPTION:
|
||||
if (col_sep_len && !STREQ (col_sep, optarg))
|
||||
error (EXIT_FAILURE, 0, _("multiple output delimiters specified"));
|
||||
die (EXIT_FAILURE, 0, _("multiple output delimiters specified"));
|
||||
col_sep = optarg;
|
||||
col_sep_len = *optarg ? strlen (optarg) : 1;
|
||||
break;
|
||||
|
||||
+3
-2
@@ -38,6 +38,7 @@
|
||||
#include "copy.h"
|
||||
#include "cp-hash.h"
|
||||
#include "extent-scan.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "fcntl--.h"
|
||||
@@ -1762,8 +1763,8 @@ static void
|
||||
restore_default_fscreatecon_or_die (void)
|
||||
{
|
||||
if (setfscreatecon (NULL) != 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("failed to restore the default file creation context"));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("failed to restore the default file creation context"));
|
||||
}
|
||||
|
||||
/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE, VERBOSE and
|
||||
|
||||
+3
-2
@@ -27,6 +27,7 @@
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
@@ -174,8 +175,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
argv[nskip] = arg_name; /* XXX: Discards any specified path. */
|
||||
launch_program (prog_name, argc - nskip, argv + nskip);
|
||||
error (EXIT_FAILURE, 0, _("unknown program %s"),
|
||||
quote (prog_name));
|
||||
die (EXIT_FAILURE, 0, _("unknown program %s"),
|
||||
quote (prog_name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "backupfile.h"
|
||||
#include "copy.h"
|
||||
#include "cp-hash.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "filenamecat.h"
|
||||
#include "ignore-value.h"
|
||||
@@ -575,7 +576,7 @@ target_directory_operand (char const *file, struct stat *st, bool *new_dst)
|
||||
if (err)
|
||||
{
|
||||
if (err != ENOENT)
|
||||
error (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file));
|
||||
die (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file));
|
||||
*new_dst = true;
|
||||
}
|
||||
return is_a_dir;
|
||||
@@ -605,9 +606,9 @@ do_copy (int n_files, char **file, const char *target_directory,
|
||||
if (no_target_directory)
|
||||
{
|
||||
if (target_directory)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot combine --target-directory (-t) "
|
||||
"and --no-target-directory (-T)"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot combine --target-directory (-t) "
|
||||
"and --no-target-directory (-T)"));
|
||||
if (2 < n_files)
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quoteaf (file[2]));
|
||||
@@ -622,8 +623,8 @@ do_copy (int n_files, char **file, const char *target_directory,
|
||||
&& target_directory_operand (file[n_files - 1], &sb, &new_dst))
|
||||
target_directory = file[--n_files];
|
||||
else if (2 < n_files)
|
||||
error (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (file[n_files - 1]));
|
||||
die (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (file[n_files - 1]));
|
||||
}
|
||||
|
||||
if (target_directory)
|
||||
@@ -1072,17 +1073,17 @@ main (int argc, char **argv)
|
||||
|
||||
case 't':
|
||||
if (target_directory)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("multiple target directories specified"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("multiple target directories specified"));
|
||||
else
|
||||
{
|
||||
struct stat st;
|
||||
if (stat (optarg, &st) != 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to access %s"),
|
||||
quoteaf (optarg));
|
||||
die (EXIT_FAILURE, errno, _("failed to access %s"),
|
||||
quoteaf (optarg));
|
||||
if (! S_ISDIR (st.st_mode))
|
||||
error (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (optarg));
|
||||
die (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (optarg));
|
||||
}
|
||||
target_directory = optarg;
|
||||
break;
|
||||
@@ -1184,13 +1185,13 @@ main (int argc, char **argv)
|
||||
x.preserve_security_context = false;
|
||||
|
||||
if (x.preserve_security_context && (x.set_security_context || scontext))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot set target context and preserve it"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot set target context and preserve it"));
|
||||
|
||||
if (x.require_preserve_context && ! selinux_enabled)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot preserve security context "
|
||||
"without an SELinux-enabled kernel"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot preserve security context "
|
||||
"without an SELinux-enabled kernel"));
|
||||
|
||||
/* FIXME: This handles new files. But what about existing files?
|
||||
I.e., if updating a tree, new files would have the specified context,
|
||||
@@ -1199,14 +1200,14 @@ main (int argc, char **argv)
|
||||
restorecon (dst_path, 0, true);
|
||||
*/
|
||||
if (scontext && setfscreatecon (se_const (scontext)) < 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (scontext));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (scontext));
|
||||
|
||||
#if !USE_XATTR
|
||||
if (x.require_preserve_xattr)
|
||||
error (EXIT_FAILURE, 0, _("cannot preserve extended attributes, cp is "
|
||||
"built without xattr support"));
|
||||
die (EXIT_FAILURE, 0, _("cannot preserve extended attributes, cp is "
|
||||
"built without xattr support"));
|
||||
#endif
|
||||
|
||||
/* Allocate space for remembering copied and created files. */
|
||||
|
||||
+28
-29
@@ -542,7 +542,7 @@ static uintmax_t
|
||||
get_first_line_in_buffer (void)
|
||||
{
|
||||
if (head == NULL && !load_buffer ())
|
||||
error (EXIT_FAILURE, errno, _("input disappeared"));
|
||||
die (EXIT_FAILURE, errno, _("input disappeared"));
|
||||
|
||||
return head->first_available;
|
||||
}
|
||||
@@ -652,8 +652,8 @@ static void
|
||||
set_input_file (const char *name)
|
||||
{
|
||||
if (! STREQ (name, "-") && fd_reopen (STDIN_FILENO, name, O_RDONLY, 0) < 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quoteaf (name));
|
||||
die (EXIT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quoteaf (name));
|
||||
}
|
||||
|
||||
/* Write all lines from the beginning of the buffer up to, but
|
||||
@@ -1090,8 +1090,8 @@ static void
|
||||
check_for_offset (struct control *p, const char *str, const char *num)
|
||||
{
|
||||
if (xstrtoimax (num, NULL, 10, &p->offset, "") != LONGINT_OK)
|
||||
error (EXIT_FAILURE, 0, _("%s: integer expected after delimiter"),
|
||||
quote (str));
|
||||
die (EXIT_FAILURE, 0, _("%s: integer expected after delimiter"),
|
||||
quote (str));
|
||||
}
|
||||
|
||||
/* Given that the first character of command line arg STR is '{',
|
||||
@@ -1107,8 +1107,8 @@ parse_repeat_count (int argnum, struct control *p, char *str)
|
||||
|
||||
end = str + strlen (str) - 1;
|
||||
if (*end != '}')
|
||||
error (EXIT_FAILURE, 0, _("%s: '}' is required in repeat count"),
|
||||
quote (str));
|
||||
die (EXIT_FAILURE, 0, _("%s: '}' is required in repeat count"),
|
||||
quote (str));
|
||||
*end = '\0';
|
||||
|
||||
if (str+1 == end-1 && *(str+1) == '*')
|
||||
@@ -1117,9 +1117,9 @@ parse_repeat_count (int argnum, struct control *p, char *str)
|
||||
{
|
||||
if (xstrtoumax (str + 1, NULL, 10, &val, "") != LONGINT_OK)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s}: integer required between '{' and '}'"),
|
||||
quote (global_argv[argnum]));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("%s}: integer required between '{' and '}'"),
|
||||
quote (global_argv[argnum]));
|
||||
}
|
||||
p->repeat = val;
|
||||
}
|
||||
@@ -1144,8 +1144,8 @@ extract_regexp (int argnum, bool ignore, char const *str)
|
||||
|
||||
closing_delim = strrchr (str + 1, delim);
|
||||
if (closing_delim == NULL)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s: closing delimiter '%c' missing"), str, delim);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("%s: closing delimiter '%c' missing"), str, delim);
|
||||
|
||||
len = closing_delim - str - 1;
|
||||
p = new_control_record ();
|
||||
@@ -1195,17 +1195,16 @@ parse_patterns (int argc, int start, char **argv)
|
||||
p->argnum = i;
|
||||
|
||||
if (xstrtoumax (argv[i], NULL, 10, &val, "") != LONGINT_OK)
|
||||
error (EXIT_FAILURE, 0, _("%s: invalid pattern"), quote (argv[i]));
|
||||
die (EXIT_FAILURE, 0, _("%s: invalid pattern"), quote (argv[i]));
|
||||
if (val == 0)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s: line number must be greater than zero"),
|
||||
argv[i]);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("%s: line number must be greater than zero"), argv[i]);
|
||||
if (val < last_val)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (uintmax_t)];
|
||||
error (EXIT_FAILURE, 0,
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("line number %s is smaller than preceding line number, %s"),
|
||||
quote (argv[i]), umaxtostr (last_val, buf));
|
||||
quote (argv[i]), umaxtostr (last_val, buf));
|
||||
}
|
||||
|
||||
if (val == last_val)
|
||||
@@ -1292,17 +1291,17 @@ check_format_conv_type (char *format, int flags)
|
||||
|
||||
default:
|
||||
if (isprint (ch))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid conversion specifier in suffix: %c"), ch);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid conversion specifier in suffix: %c"), ch);
|
||||
else
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid conversion specifier in suffix: \\%.3o"), ch);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid conversion specifier in suffix: \\%.3o"), ch);
|
||||
}
|
||||
|
||||
if (flags & ~ compatible_flags)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid flags in conversion specification: %%%c%c"),
|
||||
(flags & ~ compatible_flags & FLAG_ALTERNATIVE ? '#' : '\''), ch);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid flags in conversion specification: %%%c%c"),
|
||||
(flags & ~ compatible_flags & FLAG_ALTERNATIVE ? '#' : '\''), ch);
|
||||
}
|
||||
|
||||
/* Return the maximum number of bytes that can be generated by
|
||||
@@ -1317,8 +1316,8 @@ max_out (char *format)
|
||||
if (*f == '%' && *++f != '%')
|
||||
{
|
||||
if (percent)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("too many %% conversion specifications in suffix"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("too many %% conversion specifications in suffix"));
|
||||
percent = true;
|
||||
int flags;
|
||||
f += get_format_flags (f, &flags);
|
||||
@@ -1331,8 +1330,8 @@ max_out (char *format)
|
||||
}
|
||||
|
||||
if (! percent)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("missing %% conversion specification in suffix"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("missing %% conversion specification in suffix"));
|
||||
|
||||
int maxlen = snprintf (NULL, 0, format, UINT_MAX);
|
||||
if (! (0 <= maxlen && maxlen <= SIZE_MAX))
|
||||
|
||||
+7
-6
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "argmatch.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "parse-datetime.h"
|
||||
#include "posixtm.h"
|
||||
@@ -301,7 +302,7 @@ batch_convert (const char *input_filename, const char *format, timezone_t tz)
|
||||
in_stream = fopen (input_filename, "r");
|
||||
if (in_stream == NULL)
|
||||
{
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (input_filename));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (input_filename));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +332,7 @@ batch_convert (const char *input_filename, const char *format, timezone_t tz)
|
||||
}
|
||||
|
||||
if (fclose (in_stream) == EOF)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (input_filename));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (input_filename));
|
||||
|
||||
free (line);
|
||||
|
||||
@@ -435,7 +436,7 @@ main (int argc, char **argv)
|
||||
if (new_format)
|
||||
{
|
||||
if (format)
|
||||
error (EXIT_FAILURE, 0, _("multiple output formats specified"));
|
||||
die (EXIT_FAILURE, 0, _("multiple output formats specified"));
|
||||
format = new_format;
|
||||
}
|
||||
}
|
||||
@@ -469,7 +470,7 @@ main (int argc, char **argv)
|
||||
if (argv[optind][0] == '+')
|
||||
{
|
||||
if (format)
|
||||
error (EXIT_FAILURE, 0, _("multiple output formats specified"));
|
||||
die (EXIT_FAILURE, 0, _("multiple output formats specified"));
|
||||
format = argv[optind++] + 1;
|
||||
}
|
||||
else if (set_date || option_specified_date)
|
||||
@@ -534,7 +535,7 @@ main (int argc, char **argv)
|
||||
if (reference != NULL)
|
||||
{
|
||||
if (stat (reference, &refstats) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (reference));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (reference));
|
||||
when = get_stat_mtime (&refstats);
|
||||
}
|
||||
else
|
||||
@@ -547,7 +548,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (! valid_date)
|
||||
error (EXIT_FAILURE, 0, _("invalid date %s"), quote (datestr));
|
||||
die (EXIT_FAILURE, 0, _("invalid date %s"), quote (datestr));
|
||||
|
||||
if (set_date)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "close-stream.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fd-reopen.h"
|
||||
#include "gethrxtime.h"
|
||||
@@ -692,12 +693,11 @@ alloc_ibuf (void)
|
||||
{
|
||||
uintmax_t ibs = input_blocksize;
|
||||
char hbuf[LONGEST_HUMAN_READABLE + 1];
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("memory exhausted by input buffer of size %"PRIuMAX
|
||||
" bytes (%s)"),
|
||||
ibs,
|
||||
human_readable (input_blocksize, hbuf,
|
||||
human_opts | human_base_1024, 1, 1));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("memory exhausted by input buffer of size %"PRIuMAX" bytes (%s)"),
|
||||
ibs,
|
||||
human_readable (input_blocksize, hbuf,
|
||||
human_opts | human_base_1024, 1, 1));
|
||||
}
|
||||
|
||||
real_buf += SWAB_ALIGN_OFFSET; /* allow space for swab */
|
||||
@@ -721,12 +721,12 @@ alloc_obuf (void)
|
||||
{
|
||||
uintmax_t obs = output_blocksize;
|
||||
char hbuf[LONGEST_HUMAN_READABLE + 1];
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("memory exhausted by output buffer of size %"PRIuMAX
|
||||
" bytes (%s)"),
|
||||
obs,
|
||||
human_readable (output_blocksize, hbuf,
|
||||
human_opts | human_base_1024, 1, 1));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("memory exhausted by output buffer of size %"PRIuMAX
|
||||
" bytes (%s)"),
|
||||
obs,
|
||||
human_readable (output_blocksize, hbuf,
|
||||
human_opts | human_base_1024, 1, 1));
|
||||
}
|
||||
obuf = ptr_align (real_obuf, page_size);
|
||||
}
|
||||
@@ -932,15 +932,14 @@ static void
|
||||
cleanup (void)
|
||||
{
|
||||
if (close (STDIN_FILENO) < 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("closing input file %s"), quoteaf (input_file));
|
||||
die (EXIT_FAILURE, errno, _("closing input file %s"), quoteaf (input_file));
|
||||
|
||||
/* Don't remove this call to close, even though close_stdout
|
||||
closes standard output. This close is necessary when cleanup
|
||||
is called as part of a signal handler. */
|
||||
if (close (STDOUT_FILENO) < 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("closing output file %s"), quoteaf (output_file));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("closing output file %s"), quoteaf (output_file));
|
||||
}
|
||||
|
||||
/* Process any pending signals. If signals are caught, this function
|
||||
@@ -1450,8 +1449,8 @@ scanargs (int argc, char *const *argv)
|
||||
invalid = LONGINT_OVERFLOW;
|
||||
|
||||
if (invalid != LONGINT_OK)
|
||||
error (EXIT_FAILURE, invalid == LONGINT_OVERFLOW ? EOVERFLOW : 0,
|
||||
"%s: %s", _("invalid number"), quote (val));
|
||||
die (EXIT_FAILURE, invalid == LONGINT_OVERFLOW ? EOVERFLOW : 0,
|
||||
"%s: %s", _("invalid number"), quote (val));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1534,16 +1533,16 @@ scanargs (int argc, char *const *argv)
|
||||
input_flags &= ~O_FULLBLOCK;
|
||||
|
||||
if (multiple_bits_set (conversions_mask & (C_ASCII | C_EBCDIC | C_IBM)))
|
||||
error (EXIT_FAILURE, 0, _("cannot combine any two of {ascii,ebcdic,ibm}"));
|
||||
die (EXIT_FAILURE, 0, _("cannot combine any two of {ascii,ebcdic,ibm}"));
|
||||
if (multiple_bits_set (conversions_mask & (C_BLOCK | C_UNBLOCK)))
|
||||
error (EXIT_FAILURE, 0, _("cannot combine block and unblock"));
|
||||
die (EXIT_FAILURE, 0, _("cannot combine block and unblock"));
|
||||
if (multiple_bits_set (conversions_mask & (C_LCASE | C_UCASE)))
|
||||
error (EXIT_FAILURE, 0, _("cannot combine lcase and ucase"));
|
||||
die (EXIT_FAILURE, 0, _("cannot combine lcase and ucase"));
|
||||
if (multiple_bits_set (conversions_mask & (C_EXCL | C_NOCREAT)))
|
||||
error (EXIT_FAILURE, 0, _("cannot combine excl and nocreat"));
|
||||
die (EXIT_FAILURE, 0, _("cannot combine excl and nocreat"));
|
||||
if (multiple_bits_set (input_flags & (O_DIRECT | O_NOCACHE))
|
||||
|| multiple_bits_set (output_flags & (O_DIRECT | O_NOCACHE)))
|
||||
error (EXIT_FAILURE, 0, _("cannot combine direct and nocache"));
|
||||
die (EXIT_FAILURE, 0, _("cannot combine direct and nocache"));
|
||||
|
||||
if (input_flags & O_NOCACHE)
|
||||
{
|
||||
@@ -1742,7 +1741,7 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize,
|
||||
{
|
||||
struct stat st;
|
||||
if (fstat (STDIN_FILENO, &st) != 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot fstat %s"), quoteaf (file));
|
||||
die (EXIT_FAILURE, errno, _("cannot fstat %s"), quoteaf (file));
|
||||
if (usable_st_size (&st) && st.st_size < input_offset + offset)
|
||||
{
|
||||
/* When skipping past EOF, return the number of _full_ blocks
|
||||
@@ -2022,7 +2021,7 @@ set_fd_flags (int fd, int add_flags, char const *name)
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
error (EXIT_FAILURE, errno, _("setting flags for %s"), quoteaf (name));
|
||||
die (EXIT_FAILURE, errno, _("setting flags for %s"), quoteaf (name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2375,8 +2374,8 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
if (ifd_reopen (STDIN_FILENO, input_file, O_RDONLY | input_flags, 0) < 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to open %s"),
|
||||
quoteaf (input_file));
|
||||
die (EXIT_FAILURE, errno, _("failed to open %s"),
|
||||
quoteaf (input_file));
|
||||
}
|
||||
|
||||
offset = lseek (STDIN_FILENO, 0, SEEK_CUR);
|
||||
@@ -2405,8 +2404,8 @@ main (int argc, char **argv)
|
||||
|| ifd_reopen (STDOUT_FILENO, output_file, O_RDWR | opts, perms) < 0)
|
||||
&& (ifd_reopen (STDOUT_FILENO, output_file, O_WRONLY | opts, perms)
|
||||
< 0))
|
||||
error (EXIT_FAILURE, errno, _("failed to open %s"),
|
||||
quoteaf (output_file));
|
||||
die (EXIT_FAILURE, errno, _("failed to open %s"),
|
||||
quoteaf (output_file));
|
||||
|
||||
if (seek_records != 0 && !(conversions_mask & C_NOTRUNC))
|
||||
{
|
||||
@@ -2414,11 +2413,11 @@ main (int argc, char **argv)
|
||||
unsigned long int obs = output_blocksize;
|
||||
|
||||
if (OFF_T_MAX / output_blocksize < seek_records)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("offset too large: "
|
||||
"cannot truncate to a length of seek=%"PRIuMAX""
|
||||
" (%lu-byte) blocks"),
|
||||
seek_records, obs);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("offset too large: "
|
||||
"cannot truncate to a length of seek=%"PRIuMAX""
|
||||
" (%lu-byte) blocks"),
|
||||
seek_records, obs);
|
||||
|
||||
if (iftruncate (STDOUT_FILENO, size) != 0)
|
||||
{
|
||||
@@ -2430,15 +2429,15 @@ main (int argc, char **argv)
|
||||
int ftruncate_errno = errno;
|
||||
struct stat stdout_stat;
|
||||
if (fstat (STDOUT_FILENO, &stdout_stat) != 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot fstat %s"),
|
||||
quoteaf (output_file));
|
||||
die (EXIT_FAILURE, errno, _("cannot fstat %s"),
|
||||
quoteaf (output_file));
|
||||
if (S_ISREG (stdout_stat.st_mode)
|
||||
|| S_ISDIR (stdout_stat.st_mode)
|
||||
|| S_TYPEISSHM (&stdout_stat))
|
||||
error (EXIT_FAILURE, ftruncate_errno,
|
||||
_("failed to truncate to %"PRIuMAX" bytes"
|
||||
" in output file %s"),
|
||||
size, quoteaf (output_file));
|
||||
die (EXIT_FAILURE, ftruncate_errno,
|
||||
_("failed to truncate to %"PRIuMAX" bytes"
|
||||
" in output file %s"),
|
||||
size, quoteaf (output_file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "canonicalize.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fsusage.h"
|
||||
#include "human.h"
|
||||
@@ -1784,7 +1785,7 @@ main (int argc, char **argv)
|
||||
/* Print the "no FS processed" diagnostic only if there was no preceding
|
||||
diagnostic, e.g., if all have been excluded. */
|
||||
if (exit_status == EXIT_SUCCESS)
|
||||
error (EXIT_FAILURE, 0, _("no file systems processed"));
|
||||
die (EXIT_FAILURE, 0, _("no file systems processed"));
|
||||
}
|
||||
|
||||
IF_LINT (free (columns));
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@
|
||||
#include "system.h"
|
||||
#include "dircolors.h"
|
||||
#include "c-strcase.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "obstack.h"
|
||||
#include "quote.h"
|
||||
@@ -470,7 +471,7 @@ main (int argc, char **argv)
|
||||
syntax = guess_shell_syntax ();
|
||||
if (syntax == SHELL_SYNTAX_UNKNOWN)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("no SHELL environment variable, and no shell type option given"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "argmatch.h"
|
||||
#include "argv-iter.h"
|
||||
#include "di-set.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "exclude.h"
|
||||
#include "fprintftime.h"
|
||||
@@ -845,7 +846,7 @@ main (int argc, char **argv)
|
||||
if (opt_threshold == 0 && *optarg == '-')
|
||||
{
|
||||
/* Do not allow -0, as this wouldn't make sense anyway. */
|
||||
error (EXIT_FAILURE, 0, _("invalid --threshold argument '-0'"));
|
||||
die (EXIT_FAILURE, 0, _("invalid --threshold argument '-0'"));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1022,8 +1023,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (! (STREQ (files_from, "-") || freopen (files_from, "r", stdin)))
|
||||
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quoteaf (files_from));
|
||||
die (EXIT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quoteaf (files_from));
|
||||
|
||||
ai = argv_iter_init_stream (stdin);
|
||||
|
||||
@@ -1130,7 +1131,7 @@ main (int argc, char **argv)
|
||||
di_set_free (di_mnt);
|
||||
|
||||
if (files_from && (ferror (stdin) || fclose (stdin) != 0) && ok)
|
||||
error (EXIT_FAILURE, 0, _("error reading %s"), quoteaf (files_from));
|
||||
die (EXIT_FAILURE, 0, _("error reading %s"), quoteaf (files_from));
|
||||
|
||||
if (print_grand_total)
|
||||
print_size (&tot_dui, _("total"));
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
@@ -121,7 +122,7 @@ main (int argc, char **argv)
|
||||
optind = 0; /* Force GNU getopt to re-initialize. */
|
||||
while ((optc = getopt_long (argc, argv, "+iu:0", longopts, NULL)) != -1)
|
||||
if (optc == 'u' && unsetenv (optarg))
|
||||
error (EXIT_CANCELED, errno, _("cannot unset %s"), quote (optarg));
|
||||
die (EXIT_CANCELED, errno, _("cannot unset %s"), quote (optarg));
|
||||
|
||||
if (optind < argc && STREQ (argv[optind], "-"))
|
||||
++optind;
|
||||
@@ -132,8 +133,8 @@ main (int argc, char **argv)
|
||||
if (putenv (argv[optind]))
|
||||
{
|
||||
*eq = '\0';
|
||||
error (EXIT_CANCELED, errno, _("cannot set %s"),
|
||||
quote (argv[optind]));
|
||||
die (EXIT_CANCELED, errno, _("cannot set %s"),
|
||||
quote (argv[optind]));
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
|
||||
+5
-4
@@ -19,6 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "quote.h"
|
||||
@@ -79,7 +80,7 @@ add_tab_stop (uintmax_t tabval)
|
||||
if (max_column_width < column_width)
|
||||
{
|
||||
if (SIZE_MAX < column_width)
|
||||
error (EXIT_FAILURE, 0, _("tabs are too far apart"));
|
||||
die (EXIT_FAILURE, 0, _("tabs are too far apart"));
|
||||
max_column_width = column_width;
|
||||
}
|
||||
}
|
||||
@@ -150,9 +151,9 @@ validate_tab_stops (uintmax_t const *tabs, size_t entries)
|
||||
for (i = 0; i < entries; i++)
|
||||
{
|
||||
if (tabs[i] == 0)
|
||||
error (EXIT_FAILURE, 0, _("tab size cannot be 0"));
|
||||
die (EXIT_FAILURE, 0, _("tab size cannot be 0"));
|
||||
if (tabs[i] <= prev_tab)
|
||||
error (EXIT_FAILURE, 0, _("tab sizes must be ascending"));
|
||||
die (EXIT_FAILURE, 0, _("tab sizes must be ascending"));
|
||||
prev_tab = tabs[i];
|
||||
}
|
||||
}
|
||||
@@ -270,5 +271,5 @@ extern void
|
||||
cleanup_file_list_stdin (void)
|
||||
{
|
||||
if (have_read_stdin && fclose (stdin) != 0)
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
die (EXIT_FAILURE, errno, "-");
|
||||
}
|
||||
+5
-5
@@ -38,7 +38,7 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "die.h"
|
||||
#include "xstrndup.h"
|
||||
|
||||
#include "expand-common.h"
|
||||
@@ -145,11 +145,11 @@ expand (void)
|
||||
next_tab_column = column + 1;
|
||||
|
||||
if (next_tab_column < column)
|
||||
error (EXIT_FAILURE, 0, _("input line is too long"));
|
||||
die (EXIT_FAILURE, 0, _("input line is too long"));
|
||||
|
||||
while (++column < next_tab_column)
|
||||
if (putchar (' ') < 0)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
c = ' ';
|
||||
}
|
||||
@@ -164,7 +164,7 @@ expand (void)
|
||||
{
|
||||
column++;
|
||||
if (!column)
|
||||
error (EXIT_FAILURE, 0, _("input line is too long"));
|
||||
die (EXIT_FAILURE, 0, _("input line is too long"));
|
||||
}
|
||||
|
||||
convert &= convert_entire_line || !! isblank (c);
|
||||
@@ -174,7 +174,7 @@ expand (void)
|
||||
return;
|
||||
|
||||
if (putchar (c) < 0)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
while (c != '\n');
|
||||
}
|
||||
|
||||
+15
-14
@@ -34,6 +34,7 @@
|
||||
#include "system.h"
|
||||
|
||||
#include <regex.h>
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "strnumcmp.h"
|
||||
@@ -273,7 +274,7 @@ or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred.\n\
|
||||
static void
|
||||
syntax_error (void)
|
||||
{
|
||||
error (EXPR_INVALID, 0, _("syntax error"));
|
||||
die (EXPR_INVALID, 0, _("syntax error"));
|
||||
}
|
||||
|
||||
#if ! HAVE_GMP
|
||||
@@ -281,7 +282,7 @@ syntax_error (void)
|
||||
static void
|
||||
integer_overflow (char op)
|
||||
{
|
||||
error (EXPR_FAILURE, ERANGE, "%c", op);
|
||||
die (EXPR_FAILURE, ERANGE, "%c", op);
|
||||
abort (); /* notreached */
|
||||
}
|
||||
#endif
|
||||
@@ -465,7 +466,7 @@ toarith (VALUE *v)
|
||||
if (! looks_like_integer (s))
|
||||
return false;
|
||||
if (mpz_init_set_str (v->u.i, s, 10) != 0 && !HAVE_GMP)
|
||||
error (EXPR_FAILURE, ERANGE, "%s", (s));
|
||||
die (EXPR_FAILURE, ERANGE, "%s", (s));
|
||||
free (s);
|
||||
v->type = integer;
|
||||
return true;
|
||||
@@ -561,7 +562,7 @@ docolon (VALUE *sv, VALUE *pv)
|
||||
RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES;
|
||||
errmsg = re_compile_pattern (pv->u.s, strlen (pv->u.s), &re_buffer);
|
||||
if (errmsg)
|
||||
error (EXPR_INVALID, 0, "%s", (errmsg));
|
||||
die (EXPR_INVALID, 0, "%s", (errmsg));
|
||||
re_buffer.newline_anchor = 0;
|
||||
|
||||
matchlen = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
|
||||
@@ -585,9 +586,9 @@ docolon (VALUE *sv, VALUE *pv)
|
||||
v = int_value (0);
|
||||
}
|
||||
else
|
||||
error (EXPR_FAILURE,
|
||||
(matchlen == -2 ? errno : EOVERFLOW),
|
||||
_("error in regular expression matcher"));
|
||||
die (EXPR_FAILURE,
|
||||
(matchlen == -2 ? errno : EOVERFLOW),
|
||||
_("error in regular expression matcher"));
|
||||
|
||||
if (0 < re_regs.num_regs)
|
||||
{
|
||||
@@ -779,9 +780,9 @@ eval4 (bool evaluate)
|
||||
if (evaluate)
|
||||
{
|
||||
if (!toarith (l) || !toarith (r))
|
||||
error (EXPR_INVALID, 0, _("non-integer argument"));
|
||||
die (EXPR_INVALID, 0, _("non-integer argument"));
|
||||
if (fxn != multiply && mpz_sgn (r->u.i) == 0)
|
||||
error (EXPR_INVALID, 0, _("division by zero"));
|
||||
die (EXPR_INVALID, 0, _("division by zero"));
|
||||
((fxn == multiply ? mpz_mul
|
||||
: fxn == divide ? mpz_tdiv_q
|
||||
: mpz_tdiv_r)
|
||||
@@ -816,7 +817,7 @@ eval3 (bool evaluate)
|
||||
if (evaluate)
|
||||
{
|
||||
if (!toarith (l) || !toarith (r))
|
||||
error (EXPR_INVALID, 0, _("non-integer argument"));
|
||||
die (EXPR_INVALID, 0, _("non-integer argument"));
|
||||
(fxn == plus ? mpz_add : mpz_sub) (l->u.i, l->u.i, r->u.i);
|
||||
}
|
||||
freev (r);
|
||||
@@ -876,10 +877,10 @@ eval2 (bool evaluate)
|
||||
{
|
||||
error (0, errno, _("string comparison failed"));
|
||||
error (0, 0, _("set LC_ALL='C' to work around the problem"));
|
||||
error (EXPR_INVALID, 0,
|
||||
_("the strings compared were %s and %s"),
|
||||
quotearg_n_style (0, locale_quoting_style, l->u.s),
|
||||
quotearg_n_style (1, locale_quoting_style, r->u.s));
|
||||
die (EXPR_INVALID, 0,
|
||||
_("the strings compared were %s and %s"),
|
||||
quotearg_n_style (0, locale_quoting_style, l->u.s),
|
||||
quotearg_n_style (1, locale_quoting_style, r->u.s));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -114,6 +114,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "full-write.h"
|
||||
#include "quote.h"
|
||||
@@ -2079,7 +2080,7 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, struct factors *factors)
|
||||
if (g <= L)
|
||||
{
|
||||
if (qpos >= QUEUE_SIZE)
|
||||
error (EXIT_FAILURE, 0, _("squfof queue overflow"));
|
||||
die (EXIT_FAILURE, 0, _("squfof queue overflow"));
|
||||
queue[qpos].Q = g;
|
||||
queue[qpos].P = P % g;
|
||||
qpos++;
|
||||
@@ -2363,7 +2364,7 @@ lbuf_flush (void)
|
||||
{
|
||||
size_t size = lbuf.end - lbuf.buf;
|
||||
if (full_write (STDOUT_FILENO, lbuf.buf, size) != size)
|
||||
error (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
die (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
lbuf.end = lbuf.buf;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "save-cwd.h"
|
||||
#include "xgetcwd.h"
|
||||
@@ -102,8 +103,8 @@ done:
|
||||
{
|
||||
int save_errno = errno;
|
||||
if (restore_cwd (&cwd) != 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("failed to return to initial working directory"));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("failed to return to initial working directory"));
|
||||
free_cwd (&cwd);
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "xdectoint.h"
|
||||
@@ -302,7 +303,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
die (EXIT_FAILURE, errno, "-");
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
+6
-6
@@ -25,7 +25,7 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "die.h"
|
||||
#include "group-list.h"
|
||||
#include "quote.h"
|
||||
|
||||
@@ -103,17 +103,17 @@ main (int argc, char **argv)
|
||||
errno = 0;
|
||||
ruid = getuid ();
|
||||
if (ruid == NO_UID && errno)
|
||||
error (EXIT_FAILURE, errno, _("cannot get real UID"));
|
||||
die (EXIT_FAILURE, errno, _("cannot get real UID"));
|
||||
|
||||
errno = 0;
|
||||
egid = getegid ();
|
||||
if (egid == NO_GID && errno)
|
||||
error (EXIT_FAILURE, errno, _("cannot get effective GID"));
|
||||
die (EXIT_FAILURE, errno, _("cannot get effective GID"));
|
||||
|
||||
errno = 0;
|
||||
rgid = getgid ();
|
||||
if (rgid == NO_GID && errno)
|
||||
error (EXIT_FAILURE, errno, _("cannot get real GID"));
|
||||
die (EXIT_FAILURE, errno, _("cannot get real GID"));
|
||||
|
||||
if (!print_group_list (NULL, ruid, rgid, egid, true, ' '))
|
||||
ok = false;
|
||||
@@ -126,8 +126,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
struct passwd *pwd = getpwnam (argv[optind]);
|
||||
if (pwd == NULL)
|
||||
error (EXIT_FAILURE, 0, _("%s: no such user"),
|
||||
quote (argv[optind]));
|
||||
die (EXIT_FAILURE, 0, _("%s: no such user"),
|
||||
quote (argv[optind]));
|
||||
ruid = pwd->pw_uid;
|
||||
rgid = egid = pwd->pw_gid;
|
||||
|
||||
|
||||
+8
-7
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "full-read.h"
|
||||
#include "quote.h"
|
||||
@@ -180,8 +181,8 @@ xwrite_stdout (char const *buffer, size_t n_bytes)
|
||||
if (n_bytes > 0 && fwrite (buffer, 1, n_bytes, stdout) < n_bytes)
|
||||
{
|
||||
clearerr (stdout); /* To avoid redundant close_stdout diagnostic. */
|
||||
error (EXIT_FAILURE, errno, _("error writing %s"),
|
||||
quoteaf ("standard output"));
|
||||
die (EXIT_FAILURE, errno, _("error writing %s"),
|
||||
quoteaf ("standard output"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,8 +271,8 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0,
|
||||
if (SIZE_MAX < n_elide_0 + READ_BUFSIZE)
|
||||
{
|
||||
char umax_buf[INT_BUFSIZE_BOUND (n_elide_0)];
|
||||
error (EXIT_FAILURE, 0, _("%s: number of bytes is too large"),
|
||||
umaxtostr (n_elide_0, umax_buf));
|
||||
die (EXIT_FAILURE, 0, _("%s: number of bytes is too large"),
|
||||
umaxtostr (n_elide_0, umax_buf));
|
||||
}
|
||||
|
||||
/* Two cases to consider...
|
||||
@@ -1074,8 +1075,8 @@ main (int argc, char **argv)
|
||||
if ( ! count_lines && elide_from_end && OFF_T_MAX < n_units)
|
||||
{
|
||||
char umax_buf[INT_BUFSIZE_BOUND (n_units)];
|
||||
error (EXIT_FAILURE, EOVERFLOW, "%s: %s", _("invalid number of bytes"),
|
||||
quote (umaxtostr (n_units, umax_buf)));
|
||||
die (EXIT_FAILURE, EOVERFLOW, "%s: %s", _("invalid number of bytes"),
|
||||
quote (umaxtostr (n_units, umax_buf)));
|
||||
}
|
||||
|
||||
file_list = (optind < argc
|
||||
@@ -1089,7 +1090,7 @@ main (int argc, char **argv)
|
||||
ok &= head_file (file_list[i], n_units, count_lines, elide_from_end);
|
||||
|
||||
if (have_read_stdin && close (STDIN_FILENO) < 0)
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
die (EXIT_FAILURE, errno, "-");
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
+6
-5
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "xgethostname.h"
|
||||
@@ -91,11 +92,11 @@ main (int argc, char **argv)
|
||||
/* Set hostname to operand. */
|
||||
char const *name = argv[optind];
|
||||
if (sethostname (name, strlen (name)) != 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot set name to %s"),
|
||||
quote (name));
|
||||
die (EXIT_FAILURE, errno, _("cannot set name to %s"),
|
||||
quote (name));
|
||||
#else
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot set hostname; this system lacks the functionality"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot set hostname; this system lacks the functionality"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -103,7 +104,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
hostname = xgethostname ();
|
||||
if (hostname == NULL)
|
||||
error (EXIT_FAILURE, errno, _("cannot determine hostname"));
|
||||
die (EXIT_FAILURE, errno, _("cannot determine hostname"));
|
||||
printf ("%s\n", hostname);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <selinux/selinux.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "mgetgroups.h"
|
||||
#include "quote.h"
|
||||
@@ -147,13 +148,13 @@ main (int argc, char **argv)
|
||||
/* politely decline if we're not on a SELinux/SMACK-enabled kernel. */
|
||||
#ifdef HAVE_SMACK
|
||||
if (!selinux_enabled && !smack_enabled)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("--context (-Z) works only on "
|
||||
"an SELinux/SMACK-enabled kernel"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("--context (-Z) works only on "
|
||||
"an SELinux/SMACK-enabled kernel"));
|
||||
#else
|
||||
if (!selinux_enabled)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("--context (-Z) works only on an SELinux-enabled kernel"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("--context (-Z) works only on an SELinux-enabled kernel"));
|
||||
#endif
|
||||
just_context = true;
|
||||
break;
|
||||
@@ -191,11 +192,11 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (n_ids && just_context)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot print security context when user specified"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot print security context when user specified"));
|
||||
|
||||
if (just_user + just_group + just_group_list + just_context > 1)
|
||||
error (EXIT_FAILURE, 0, _("cannot print \"only\" of more than one choice"));
|
||||
die (EXIT_FAILURE, 0, _("cannot print \"only\" of more than one choice"));
|
||||
|
||||
bool default_format = ! (just_user
|
||||
|| just_group
|
||||
@@ -203,12 +204,12 @@ main (int argc, char **argv)
|
||||
|| just_context);
|
||||
|
||||
if (default_format && (use_real || use_name))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot print only names or real IDs in default format"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot print only names or real IDs in default format"));
|
||||
|
||||
if (default_format && opt_zero)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("option --zero not permitted in default format"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("option --zero not permitted in default format"));
|
||||
|
||||
/* If we are on a SELinux/SMACK-enabled kernel, no user is specified, and
|
||||
either --context is specified or none of (-u,-g,-G) is specified,
|
||||
@@ -224,7 +225,7 @@ main (int argc, char **argv)
|
||||
|| (smack_enabled
|
||||
&& smack_new_label_from_self (&context) < 0
|
||||
&& just_context))
|
||||
error (EXIT_FAILURE, 0, _("can't get process context"));
|
||||
die (EXIT_FAILURE, 0, _("can't get process context"));
|
||||
}
|
||||
|
||||
if (n_ids == 1)
|
||||
@@ -245,10 +246,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
if (pwd == NULL)
|
||||
{
|
||||
error (0, 0, _("%s: no such user"), quote (spec));
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
die (EXIT_FAILURE, 0, _("%s: no such user"), quote (spec));
|
||||
pw_name = xstrdup (pwd->pw_name);
|
||||
ruid = euid = pwd->pw_uid;
|
||||
rgid = egid = pwd->pw_gid;
|
||||
@@ -267,7 +265,7 @@ main (int argc, char **argv)
|
||||
errno = 0;
|
||||
euid = geteuid ();
|
||||
if (euid == NO_UID && errno)
|
||||
error (EXIT_FAILURE, errno, _("cannot get effective UID"));
|
||||
die (EXIT_FAILURE, errno, _("cannot get effective UID"));
|
||||
}
|
||||
|
||||
if (just_user ? use_real
|
||||
@@ -276,7 +274,7 @@ main (int argc, char **argv)
|
||||
errno = 0;
|
||||
ruid = getuid ();
|
||||
if (ruid == NO_UID && errno)
|
||||
error (EXIT_FAILURE, errno, _("cannot get real UID"));
|
||||
die (EXIT_FAILURE, errno, _("cannot get real UID"));
|
||||
}
|
||||
|
||||
if (!just_user && (just_group || just_group_list || !just_context))
|
||||
@@ -284,12 +282,12 @@ main (int argc, char **argv)
|
||||
errno = 0;
|
||||
egid = getegid ();
|
||||
if (egid == NO_GID && errno)
|
||||
error (EXIT_FAILURE, errno, _("cannot get effective GID"));
|
||||
die (EXIT_FAILURE, errno, _("cannot get effective GID"));
|
||||
|
||||
errno = 0;
|
||||
rgid = getgid ();
|
||||
if (rgid == NO_GID && errno)
|
||||
error (EXIT_FAILURE, errno, _("cannot get real GID"));
|
||||
die (EXIT_FAILURE, errno, _("cannot get real GID"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+29
-29
@@ -403,10 +403,10 @@ target_directory_operand (char const *file)
|
||||
int err = (stat (file, &st) == 0 ? 0 : errno);
|
||||
bool is_a_dir = !err && S_ISDIR (st.st_mode);
|
||||
if (err && err != ENOENT)
|
||||
error (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file));
|
||||
die (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file));
|
||||
if (is_a_dir < looks_like_a_dir)
|
||||
error (EXIT_FAILURE, err, _("target %s is not a directory"),
|
||||
quoteaf (file));
|
||||
die (EXIT_FAILURE, err, _("target %s is not a directory"),
|
||||
quoteaf (file));
|
||||
return is_a_dir;
|
||||
}
|
||||
|
||||
@@ -585,8 +585,8 @@ get_ids (void)
|
||||
unsigned long int tmp;
|
||||
if (xstrtoul (owner_name, NULL, 0, &tmp, NULL) != LONGINT_OK
|
||||
|| UID_T_MAX < tmp)
|
||||
error (EXIT_FAILURE, 0, _("invalid user %s"),
|
||||
quote (owner_name));
|
||||
die (EXIT_FAILURE, 0, _("invalid user %s"),
|
||||
quote (owner_name));
|
||||
owner_id = tmp;
|
||||
}
|
||||
else
|
||||
@@ -604,8 +604,8 @@ get_ids (void)
|
||||
unsigned long int tmp;
|
||||
if (xstrtoul (group_name, NULL, 0, &tmp, NULL) != LONGINT_OK
|
||||
|| GID_T_MAX < tmp)
|
||||
error (EXIT_FAILURE, 0, _("invalid group %s"),
|
||||
quote (group_name));
|
||||
die (EXIT_FAILURE, 0, _("invalid group %s"),
|
||||
quote (group_name));
|
||||
group_id = tmp;
|
||||
}
|
||||
else
|
||||
@@ -719,7 +719,7 @@ install_file_in_file (const char *from, const char *to,
|
||||
if (! strip (to))
|
||||
{
|
||||
if (unlink (to) != 0) /* Cleanup. */
|
||||
error (EXIT_FAILURE, errno, _("cannot unlink %s"), quoteaf (to));
|
||||
die (EXIT_FAILURE, errno, _("cannot unlink %s"), quoteaf (to));
|
||||
return false;
|
||||
}
|
||||
if (x->preserve_timestamps && (strip_files || ! S_ISREG (from_sb.st_mode))
|
||||
@@ -893,8 +893,8 @@ main (int argc, char **argv)
|
||||
break;
|
||||
case 't':
|
||||
if (target_directory)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("multiple target directories specified"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("multiple target directories specified"));
|
||||
target_directory = optarg;
|
||||
break;
|
||||
case 'T':
|
||||
@@ -943,22 +943,22 @@ main (int argc, char **argv)
|
||||
|
||||
/* Check for invalid combinations of arguments. */
|
||||
if (dir_arg && strip_files)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("the strip option may not be used when installing a directory"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("the strip option may not be used when installing a directory"));
|
||||
if (dir_arg && target_directory)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("target directory not allowed when installing a directory"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("target directory not allowed when installing a directory"));
|
||||
|
||||
if (target_directory)
|
||||
{
|
||||
struct stat st;
|
||||
bool stat_success = stat (target_directory, &st) == 0 ? true : false;
|
||||
if (! mkdir_and_install && ! stat_success)
|
||||
error (EXIT_FAILURE, errno, _("failed to access %s"),
|
||||
quoteaf (target_directory));
|
||||
die (EXIT_FAILURE, errno, _("failed to access %s"),
|
||||
quoteaf (target_directory));
|
||||
if (stat_success && ! S_ISDIR (st.st_mode))
|
||||
error (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (target_directory));
|
||||
die (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (target_directory));
|
||||
}
|
||||
|
||||
if (backup_suffix_string)
|
||||
@@ -970,13 +970,13 @@ main (int argc, char **argv)
|
||||
: no_backups);
|
||||
|
||||
if (x.preserve_security_context && (x.set_security_context || scontext))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot set target context and preserve it"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot set target context and preserve it"));
|
||||
|
||||
if (scontext && setfscreatecon (se_const (scontext)) < 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (scontext));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (scontext));
|
||||
|
||||
n_files = argc - optind;
|
||||
file = argv + optind;
|
||||
@@ -994,9 +994,9 @@ main (int argc, char **argv)
|
||||
if (no_target_directory)
|
||||
{
|
||||
if (target_directory)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot combine --target-directory (-t) "
|
||||
"and --no-target-directory (-T)"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot combine --target-directory (-t) "
|
||||
"and --no-target-directory (-T)"));
|
||||
if (2 < n_files)
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quoteaf (file[2]));
|
||||
@@ -1008,15 +1008,15 @@ main (int argc, char **argv)
|
||||
if (2 <= n_files && target_directory_operand (file[n_files - 1]))
|
||||
target_directory = file[--n_files];
|
||||
else if (2 < n_files)
|
||||
error (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (file[n_files - 1]));
|
||||
die (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (file[n_files - 1]));
|
||||
}
|
||||
|
||||
if (specified_mode)
|
||||
{
|
||||
struct mode_change *change = mode_compile (specified_mode);
|
||||
if (!change)
|
||||
error (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode));
|
||||
die (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode));
|
||||
mode = mode_adjust (0, false, 0, change, NULL);
|
||||
dir_mode = mode_adjust (0, true, 0, change, &dir_mode_bits);
|
||||
free (change);
|
||||
|
||||
+21
-20
@@ -23,6 +23,7 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "hard-locale.h"
|
||||
@@ -461,7 +462,7 @@ get_line (FILE *fp, struct line **linep, int which)
|
||||
if (! readlinebuffer_delim (&line->buf, fp, eolchar))
|
||||
{
|
||||
if (ferror (fp))
|
||||
error (EXIT_FAILURE, errno, _("read error"));
|
||||
die (EXIT_FAILURE, errno, _("read error"));
|
||||
freeline (line);
|
||||
return false;
|
||||
}
|
||||
@@ -850,7 +851,7 @@ string_to_join_field (char const *str)
|
||||
if (s_err == LONGINT_OVERFLOW || (s_err == LONGINT_OK && SIZE_MAX < val))
|
||||
val = SIZE_MAX;
|
||||
else if (s_err != LONGINT_OK || val == 0)
|
||||
error (EXIT_FAILURE, 0, _("invalid field number: %s"), quote (str));
|
||||
die (EXIT_FAILURE, 0, _("invalid field number: %s"), quote (str));
|
||||
|
||||
result = val - 1;
|
||||
|
||||
@@ -871,7 +872,7 @@ decode_field_spec (const char *s, int *file_index, size_t *field_index)
|
||||
if (s[1])
|
||||
{
|
||||
/* '0' must be all alone -- no '.FIELD'. */
|
||||
error (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s));
|
||||
die (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s));
|
||||
}
|
||||
*file_index = 0;
|
||||
*field_index = 0;
|
||||
@@ -880,14 +881,14 @@ decode_field_spec (const char *s, int *file_index, size_t *field_index)
|
||||
case '1':
|
||||
case '2':
|
||||
if (s[1] != '.')
|
||||
error (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s));
|
||||
die (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s));
|
||||
*file_index = s[0] - '0';
|
||||
*field_index = string_to_join_field (s + 2);
|
||||
break;
|
||||
|
||||
default:
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid file number in field spec: %s"), quote (s));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid file number in field spec: %s"), quote (s));
|
||||
|
||||
/* Tell gcc -W -Wall that we can't get beyond this point.
|
||||
This avoids a warning (otherwise legit) that the caller's copies
|
||||
@@ -930,8 +931,8 @@ set_join_field (size_t *var, size_t val)
|
||||
{
|
||||
unsigned long int var1 = *var + 1;
|
||||
unsigned long int val1 = val + 1;
|
||||
error (EXIT_FAILURE, 0, _("incompatible join fields %lu, %lu"),
|
||||
var1, val1);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("incompatible join fields %lu, %lu"), var1, val1);
|
||||
}
|
||||
*var = val;
|
||||
}
|
||||
@@ -1047,8 +1048,8 @@ main (int argc, char **argv)
|
||||
unsigned long int val;
|
||||
if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK
|
||||
|| (val != 1 && val != 2))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid field number: %s"), quote (optarg));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid field number: %s"), quote (optarg));
|
||||
if (val == 1)
|
||||
print_unpairables_1 = true;
|
||||
else
|
||||
@@ -1058,8 +1059,8 @@ main (int argc, char **argv)
|
||||
|
||||
case 'e':
|
||||
if (empty_filler && ! STREQ (empty_filler, optarg))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("conflicting empty-field replacement strings"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("conflicting empty-field replacement strings"));
|
||||
empty_filler = optarg;
|
||||
break;
|
||||
|
||||
@@ -1111,11 +1112,11 @@ main (int argc, char **argv)
|
||||
if (STREQ (optarg, "\\0"))
|
||||
newtab = '\0';
|
||||
else
|
||||
error (EXIT_FAILURE, 0, _("multi-character tab %s"),
|
||||
quote (optarg));
|
||||
die (EXIT_FAILURE, 0, _("multi-character tab %s"),
|
||||
quote (optarg));
|
||||
}
|
||||
if (0 <= tab && tab != newtab)
|
||||
error (EXIT_FAILURE, 0, _("incompatible tabs"));
|
||||
die (EXIT_FAILURE, 0, _("incompatible tabs"));
|
||||
tab = newtab;
|
||||
}
|
||||
break;
|
||||
@@ -1183,18 +1184,18 @@ main (int argc, char **argv)
|
||||
|
||||
fp1 = STREQ (g_names[0], "-") ? stdin : fopen (g_names[0], "r");
|
||||
if (!fp1)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (g_names[0]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (g_names[0]));
|
||||
fp2 = STREQ (g_names[1], "-") ? stdin : fopen (g_names[1], "r");
|
||||
if (!fp2)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (g_names[1]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (g_names[1]));
|
||||
if (fp1 == fp2)
|
||||
error (EXIT_FAILURE, errno, _("both files cannot be standard input"));
|
||||
die (EXIT_FAILURE, errno, _("both files cannot be standard input"));
|
||||
join (fp1, fp2);
|
||||
|
||||
if (fclose (fp1) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (g_names[0]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (g_names[0]));
|
||||
if (fclose (fp2) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (g_names[1]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (g_names[1]));
|
||||
|
||||
if (issued_disorder_warning[0] || issued_disorder_warning[1])
|
||||
return EXIT_FAILURE;
|
||||
|
||||
+3
-2
@@ -26,6 +26,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
@@ -87,8 +88,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (link (argv[optind], argv[optind + 1]) != 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot create link %s to %s"),
|
||||
quoteaf_n (0, argv[optind + 1]), quoteaf_n (1, argv[optind]));
|
||||
die (EXIT_FAILURE, errno, _("cannot create link %s to %s"),
|
||||
quoteaf_n (0, argv[optind + 1]), quoteaf_n (1, argv[optind]));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "backupfile.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "filenamecat.h"
|
||||
#include "file-set.h"
|
||||
@@ -129,10 +130,10 @@ target_directory_operand (char const *file)
|
||||
int err = (stat_result == 0 ? 0 : errno);
|
||||
bool is_a_dir = !err && S_ISDIR (st.st_mode);
|
||||
if (err && ! errno_nonexisting (errno))
|
||||
error (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file));
|
||||
die (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file));
|
||||
if (is_a_dir < looks_like_a_dir)
|
||||
error (EXIT_FAILURE, err, _("target %s is not a directory"),
|
||||
quoteaf (file));
|
||||
die (EXIT_FAILURE, err, _("target %s is not a directory"),
|
||||
quoteaf (file));
|
||||
return is_a_dir;
|
||||
}
|
||||
|
||||
@@ -525,16 +526,16 @@ main (int argc, char **argv)
|
||||
break;
|
||||
case 't':
|
||||
if (target_directory)
|
||||
error (EXIT_FAILURE, 0, _("multiple target directories specified"));
|
||||
die (EXIT_FAILURE, 0, _("multiple target directories specified"));
|
||||
else
|
||||
{
|
||||
struct stat st;
|
||||
if (stat (optarg, &st) != 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to access %s"),
|
||||
quoteaf (optarg));
|
||||
die (EXIT_FAILURE, errno, _("failed to access %s"),
|
||||
quoteaf (optarg));
|
||||
if (! S_ISDIR (st.st_mode))
|
||||
error (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (optarg));
|
||||
die (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (optarg));
|
||||
}
|
||||
target_directory = optarg;
|
||||
break;
|
||||
@@ -568,9 +569,9 @@ main (int argc, char **argv)
|
||||
if (no_target_directory)
|
||||
{
|
||||
if (target_directory)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot combine --target-directory "
|
||||
"and --no-target-directory"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot combine --target-directory "
|
||||
"and --no-target-directory"));
|
||||
if (n_files != 2)
|
||||
{
|
||||
if (n_files < 2)
|
||||
@@ -589,8 +590,8 @@ main (int argc, char **argv)
|
||||
else if (2 <= n_files && target_directory_operand (file[n_files - 1]))
|
||||
target_directory = file[--n_files];
|
||||
else if (2 < n_files)
|
||||
error (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (file[n_files - 1]));
|
||||
die (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (file[n_files - 1]));
|
||||
}
|
||||
|
||||
if (backup_suffix_string)
|
||||
@@ -602,8 +603,8 @@ main (int argc, char **argv)
|
||||
|
||||
if (relative && !symbolic_link)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot do --relative without --symbolic"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot do --relative without --symbolic"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
@@ -76,7 +77,7 @@ main (int argc, char **argv)
|
||||
using a fallback technique. */
|
||||
cp = getlogin ();
|
||||
if (! cp)
|
||||
error (EXIT_FAILURE, 0, _("no login name"));
|
||||
die (EXIT_FAILURE, 0, _("no login name"));
|
||||
|
||||
puts (cp);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -87,6 +87,7 @@
|
||||
#include "acl.h"
|
||||
#include "argmatch.h"
|
||||
#include "dev-ino.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "filenamecat.h"
|
||||
#include "hard-locale.h"
|
||||
@@ -1843,8 +1844,8 @@ decode_switches (int argc, char **argv)
|
||||
|
||||
case 'w':
|
||||
if (! set_line_length (optarg))
|
||||
error (LS_FAILURE, 0, "%s: %s", _("invalid line width"),
|
||||
quote (optarg));
|
||||
die (LS_FAILURE, 0, "%s: %s", _("invalid line width"),
|
||||
quote (optarg));
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
@@ -2122,8 +2123,8 @@ decode_switches (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
if (strchr (p1 + 1, '\n'))
|
||||
error (LS_FAILURE, 0, _("invalid time style format %s"),
|
||||
quote (p0));
|
||||
die (LS_FAILURE, 0, _("invalid time style format %s"),
|
||||
quote (p0));
|
||||
*p1++ = '\0';
|
||||
}
|
||||
long_time_format[0] = p0;
|
||||
|
||||
+4
-3
@@ -35,6 +35,7 @@
|
||||
#if HASH_ALGO_SHA512 || HASH_ALGO_SHA384
|
||||
# include "sha512.h"
|
||||
#endif
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "stdio--.h"
|
||||
@@ -564,8 +565,8 @@ digest_check (const char *checkfile_name)
|
||||
|
||||
++line_number;
|
||||
if (line_number == 0)
|
||||
error (EXIT_FAILURE, 0, _("%s: too many checksum lines"),
|
||||
quotef (checkfile_name));
|
||||
die (EXIT_FAILURE, 0, _("%s: too many checksum lines"),
|
||||
quotef (checkfile_name));
|
||||
|
||||
line_length = getline (&line, &line_chars_allocated, checkfile_stream);
|
||||
if (line_length <= 0)
|
||||
@@ -927,7 +928,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("standard input"));
|
||||
die (EXIT_FAILURE, errno, _("standard input"));
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
+6
-5
@@ -23,6 +23,7 @@
|
||||
#include <selinux/selinux.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "mkdir-p.h"
|
||||
#include "modechange.h"
|
||||
@@ -264,9 +265,9 @@ main (int argc, char **argv)
|
||||
ret = setfscreatecon (se_const (scontext));
|
||||
|
||||
if (ret < 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (scontext));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (scontext));
|
||||
}
|
||||
|
||||
|
||||
@@ -280,8 +281,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
struct mode_change *change = mode_compile (specified_mode);
|
||||
if (!change)
|
||||
error (EXIT_FAILURE, 0, _("invalid mode %s"),
|
||||
quote (specified_mode));
|
||||
die (EXIT_FAILURE, 0, _("invalid mode %s"),
|
||||
quote (specified_mode));
|
||||
options.mode = mode_adjust (S_IRWXUGO, true, umask_value, change,
|
||||
&options.mode_bits);
|
||||
free (change);
|
||||
|
||||
+7
-6
@@ -23,6 +23,7 @@
|
||||
#include <selinux/selinux.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "modechange.h"
|
||||
#include "quote.h"
|
||||
@@ -139,9 +140,9 @@ main (int argc, char **argv)
|
||||
ret = setfscreatecon (se_const (scontext));
|
||||
|
||||
if (ret < 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (scontext));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (scontext));
|
||||
}
|
||||
|
||||
newmode = MODE_RW_UGO;
|
||||
@@ -150,14 +151,14 @@ main (int argc, char **argv)
|
||||
mode_t umask_value;
|
||||
struct mode_change *change = mode_compile (specified_mode);
|
||||
if (!change)
|
||||
error (EXIT_FAILURE, 0, _("invalid mode"));
|
||||
die (EXIT_FAILURE, 0, _("invalid mode"));
|
||||
umask_value = umask (0);
|
||||
umask (umask_value);
|
||||
newmode = mode_adjust (newmode, false, umask_value, change, NULL);
|
||||
free (change);
|
||||
if (newmode & ~S_IRWXUGO)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("mode must specify only file permission bits"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("mode must specify only file permission bits"));
|
||||
}
|
||||
|
||||
for (; optind < argc; ++optind)
|
||||
|
||||
+19
-18
@@ -23,6 +23,7 @@
|
||||
#include <selinux/selinux.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "modechange.h"
|
||||
#include "quote.h"
|
||||
@@ -147,14 +148,14 @@ main (int argc, char **argv)
|
||||
mode_t umask_value;
|
||||
struct mode_change *change = mode_compile (specified_mode);
|
||||
if (!change)
|
||||
error (EXIT_FAILURE, 0, _("invalid mode"));
|
||||
die (EXIT_FAILURE, 0, _("invalid mode"));
|
||||
umask_value = umask (0);
|
||||
umask (umask_value);
|
||||
newmode = mode_adjust (newmode, false, umask_value, change, NULL);
|
||||
free (change);
|
||||
if (newmode & ~S_IRWXUGO)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("mode must specify only file permission bits"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("mode must specify only file permission bits"));
|
||||
}
|
||||
|
||||
/* If the number of arguments is 0 or 1,
|
||||
@@ -195,9 +196,9 @@ main (int argc, char **argv)
|
||||
ret = setfscreatecon (se_const (scontext));
|
||||
|
||||
if (ret < 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (scontext));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (scontext));
|
||||
}
|
||||
|
||||
/* Only check the first character, to allow mnemonic usage like
|
||||
@@ -207,7 +208,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
case 'b': /* 'block' or 'buffered' */
|
||||
#ifndef S_IFBLK
|
||||
error (EXIT_FAILURE, 0, _("block special files not supported"));
|
||||
die (EXIT_FAILURE, 0, _("block special files not supported"));
|
||||
#else
|
||||
node_type = S_IFBLK;
|
||||
#endif
|
||||
@@ -216,7 +217,7 @@ main (int argc, char **argv)
|
||||
case 'c': /* 'character' */
|
||||
case 'u': /* 'unbuffered' */
|
||||
#ifndef S_IFCHR
|
||||
error (EXIT_FAILURE, 0, _("character special files not supported"));
|
||||
die (EXIT_FAILURE, 0, _("character special files not supported"));
|
||||
#else
|
||||
node_type = S_IFCHR;
|
||||
#endif
|
||||
@@ -231,26 +232,26 @@ main (int argc, char **argv)
|
||||
|
||||
if (xstrtoumax (s_major, NULL, 0, &i_major, NULL) != LONGINT_OK
|
||||
|| i_major != (major_t) i_major)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid major device number %s"), quote (s_major));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid major device number %s"), quote (s_major));
|
||||
|
||||
if (xstrtoumax (s_minor, NULL, 0, &i_minor, NULL) != LONGINT_OK
|
||||
|| i_minor != (minor_t) i_minor)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid minor device number %s"), quote (s_minor));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid minor device number %s"), quote (s_minor));
|
||||
|
||||
device = makedev (i_major, i_minor);
|
||||
#ifdef NODEV
|
||||
if (device == NODEV)
|
||||
error (EXIT_FAILURE, 0, _("invalid device %s %s"),
|
||||
s_major, s_minor);
|
||||
die (EXIT_FAILURE, 0, _("invalid device %s %s"),
|
||||
s_major, s_minor);
|
||||
#endif
|
||||
|
||||
if (set_security_context)
|
||||
defaultcon (argv[optind], node_type);
|
||||
|
||||
if (mknod (argv[optind], newmode | node_type, device) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -258,7 +259,7 @@ main (int argc, char **argv)
|
||||
if (set_security_context)
|
||||
defaultcon (argv[optind], S_IFIFO);
|
||||
if (mkfifo (argv[optind], newmode) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -267,8 +268,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (specified_mode && lchmod (argv[optind], newmode) != 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot set permissions of %s"),
|
||||
quoteaf (argv[optind]));
|
||||
die (EXIT_FAILURE, errno, _("cannot set permissions of %s"),
|
||||
quoteaf (argv[optind]));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+15
-14
@@ -23,6 +23,7 @@
|
||||
#include "system.h"
|
||||
|
||||
#include "close-stream.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "filenamecat.h"
|
||||
#include "quote.h"
|
||||
@@ -226,9 +227,9 @@ main (int argc, char **argv)
|
||||
size_t len = strlen (template);
|
||||
if (!len || template[len - 1] != 'X')
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("with --suffix, template %s must end in X"),
|
||||
quote (template));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("with --suffix, template %s must end in X"),
|
||||
quote (template));
|
||||
}
|
||||
suffix_len = strlen (suffix);
|
||||
dest_name = xcharalloc (len + suffix_len + 1);
|
||||
@@ -251,13 +252,13 @@ main (int argc, char **argv)
|
||||
/* At this point, template is malloc'd, and suffix points into template. */
|
||||
if (suffix_len && last_component (suffix) != suffix)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid suffix %s, contains directory separator"),
|
||||
quote (suffix));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid suffix %s, contains directory separator"),
|
||||
quote (suffix));
|
||||
}
|
||||
x_count = count_consecutive_X_s (template, suffix - template);
|
||||
if (x_count < 3)
|
||||
error (EXIT_FAILURE, 0, _("too few X's in template %s"), quote (template));
|
||||
die (EXIT_FAILURE, 0, _("too few X's in template %s"), quote (template));
|
||||
|
||||
if (use_dest_dir)
|
||||
{
|
||||
@@ -272,9 +273,9 @@ main (int argc, char **argv)
|
||||
dest_dir = "/tmp";
|
||||
|
||||
if (last_component (template) != template)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid template, %s, contains directory separator"),
|
||||
quote (template));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid template, %s, contains directory separator"),
|
||||
quote (template));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -286,10 +287,10 @@ main (int argc, char **argv)
|
||||
dest_dir = (env && *env ? env : "/tmp");
|
||||
}
|
||||
if (IS_ABSOLUTE_FILE_NAME (template))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid template, %s; with --tmpdir,"
|
||||
" it may not be absolute"),
|
||||
quote (template));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid template, %s; with --tmpdir,"
|
||||
" it may not be absolute"),
|
||||
quote (template));
|
||||
}
|
||||
|
||||
dest_name = file_name_concat (dest_dir, template, NULL);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "backupfile.h"
|
||||
#include "copy.h"
|
||||
#include "cp-hash.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "filenamecat.h"
|
||||
#include "remove.h"
|
||||
@@ -94,8 +95,8 @@ rm_option_init (struct rm_options *x)
|
||||
static struct dev_ino dev_ino_buf;
|
||||
x->root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (x->root_dev_ino == NULL)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +153,7 @@ target_directory_operand (char const *file)
|
||||
int err = (stat (file, &st) == 0 ? 0 : errno);
|
||||
bool is_a_dir = !err && S_ISDIR (st.st_mode);
|
||||
if (err && err != ENOENT)
|
||||
error (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file));
|
||||
die (EXIT_FAILURE, err, _("failed to access %s"), quoteaf (file));
|
||||
return is_a_dir;
|
||||
}
|
||||
|
||||
@@ -396,16 +397,16 @@ main (int argc, char **argv)
|
||||
break;
|
||||
case 't':
|
||||
if (target_directory)
|
||||
error (EXIT_FAILURE, 0, _("multiple target directories specified"));
|
||||
die (EXIT_FAILURE, 0, _("multiple target directories specified"));
|
||||
else
|
||||
{
|
||||
struct stat st;
|
||||
if (stat (optarg, &st) != 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to access %s"),
|
||||
quoteaf (optarg));
|
||||
die (EXIT_FAILURE, errno, _("failed to access %s"),
|
||||
quoteaf (optarg));
|
||||
if (! S_ISDIR (st.st_mode))
|
||||
error (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (optarg));
|
||||
die (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (optarg));
|
||||
}
|
||||
target_directory = optarg;
|
||||
break;
|
||||
@@ -454,9 +455,9 @@ main (int argc, char **argv)
|
||||
if (no_target_directory)
|
||||
{
|
||||
if (target_directory)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot combine --target-directory (-t) "
|
||||
"and --no-target-directory (-T)"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot combine --target-directory (-t) "
|
||||
"and --no-target-directory (-T)"));
|
||||
if (2 < n_files)
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quoteaf (file[2]));
|
||||
@@ -469,8 +470,8 @@ main (int argc, char **argv)
|
||||
if (target_directory_operand (file[n_files - 1]))
|
||||
target_directory = file[--n_files];
|
||||
else if (2 < n_files)
|
||||
error (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (file[n_files - 1]));
|
||||
die (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (file[n_files - 1]));
|
||||
}
|
||||
|
||||
if (make_backups && x.interactive == I_ALWAYS_NO)
|
||||
|
||||
+5
-4
@@ -29,6 +29,7 @@
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "xstrtol.h"
|
||||
@@ -169,8 +170,8 @@ main (int argc, char **argv)
|
||||
enum { MIN_ADJUSTMENT = 1 - 2 * NZERO, MAX_ADJUSTMENT = 2 * NZERO - 1 };
|
||||
long int tmp;
|
||||
if (LONGINT_OVERFLOW < xstrtol (adjustment_given, NULL, 10, &tmp, ""))
|
||||
error (EXIT_CANCELED, 0, _("invalid adjustment %s"),
|
||||
quote (adjustment_given));
|
||||
die (EXIT_CANCELED, 0, _("invalid adjustment %s"),
|
||||
quote (adjustment_given));
|
||||
adjustment = MAX (MIN_ADJUSTMENT, MIN (tmp, MAX_ADJUSTMENT));
|
||||
}
|
||||
|
||||
@@ -185,7 +186,7 @@ main (int argc, char **argv)
|
||||
errno = 0;
|
||||
current_niceness = GET_NICENESS ();
|
||||
if (current_niceness == -1 && errno != 0)
|
||||
error (EXIT_CANCELED, errno, _("cannot get niceness"));
|
||||
die (EXIT_CANCELED, errno, _("cannot get niceness"));
|
||||
printf ("%d\n", current_niceness);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -196,7 +197,7 @@ main (int argc, char **argv)
|
||||
#else
|
||||
current_niceness = GET_NICENESS ();
|
||||
if (current_niceness == -1 && errno != 0)
|
||||
error (EXIT_CANCELED, errno, _("cannot get niceness"));
|
||||
die (EXIT_CANCELED, errno, _("cannot get niceness"));
|
||||
ok = (setpriority (PRIO_PROCESS, 0, current_niceness + adjustment) == 0);
|
||||
#endif
|
||||
if (!ok)
|
||||
|
||||
@@ -256,7 +256,7 @@ build_type_arg (char const **typep,
|
||||
RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES;
|
||||
errmsg = re_compile_pattern (optarg, strlen (optarg), regexp);
|
||||
if (errmsg)
|
||||
error (EXIT_FAILURE, 0, "%s", (errmsg));
|
||||
die (EXIT_FAILURE, 0, "%s", (errmsg));
|
||||
break;
|
||||
default:
|
||||
rval = false;
|
||||
@@ -276,7 +276,7 @@ print_lineno (void)
|
||||
|
||||
next_line_no = line_no + page_incr;
|
||||
if (next_line_no < line_no)
|
||||
error (EXIT_FAILURE, 0, _("line number overflow"));
|
||||
die (EXIT_FAILURE, 0, _("line number overflow"));
|
||||
line_no = next_line_no;
|
||||
}
|
||||
|
||||
@@ -589,7 +589,7 @@ main (int argc, char **argv)
|
||||
ok &= nl_file (argv[optind]);
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
die (EXIT_FAILURE, errno, "-");
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
+27
-26
@@ -24,6 +24,7 @@
|
||||
#include "mbsalign.h"
|
||||
#include "argmatch.h"
|
||||
#include "c-ctype.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "system.h"
|
||||
@@ -752,8 +753,8 @@ double_to_human (long double val, int precision,
|
||||
|
||||
num_size = snprintf (buf, buf_size, fmt, precision, val);
|
||||
if (num_size < 0 || num_size >= (int) buf_size)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("failed to prepare value '%Lf' for printing"), val);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("failed to prepare value '%Lf' for printing"), val);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -804,8 +805,8 @@ double_to_human (long double val, int precision,
|
||||
num_size = snprintf (buf, buf_size - 1, fmt, prec, val,
|
||||
suffix_power_char (power));
|
||||
if (num_size < 0 || num_size >= (int) buf_size - 1)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("failed to prepare value '%Lf' for printing"), val);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("failed to prepare value '%Lf' for printing"), val);
|
||||
|
||||
if (scale == scale_IEC_I && power > 0)
|
||||
strncat (buf, "i", buf_size - num_size - 1);
|
||||
@@ -854,7 +855,7 @@ unit_to_umax (const char *n_string)
|
||||
if (s_err != LONGINT_OK || *end || n == 0)
|
||||
{
|
||||
free (t_string);
|
||||
error (EXIT_FAILURE, 0, _("invalid unit size: %s"), quote (n_string));
|
||||
die (EXIT_FAILURE, 0, _("invalid unit size: %s"), quote (n_string));
|
||||
}
|
||||
|
||||
free (t_string);
|
||||
@@ -1054,8 +1055,8 @@ parse_format_string (char const *fmt)
|
||||
for (i = 0; !(fmt[i] == '%' && fmt[i + 1] != '%'); i += (fmt[i] == '%') + 1)
|
||||
{
|
||||
if (!fmt[i])
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("format %s has no %% directive"), quote (fmt));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("format %s has no %% directive"), quote (fmt));
|
||||
prefix_len++;
|
||||
}
|
||||
|
||||
@@ -1081,8 +1082,8 @@ parse_format_string (char const *fmt)
|
||||
errno = 0;
|
||||
pad = strtol (fmt + i, &endptr, 10);
|
||||
if (errno == ERANGE)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid format %s (width overflow)"), quote (fmt));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid format %s (width overflow)"), quote (fmt));
|
||||
|
||||
if (endptr != (fmt + i) && pad != 0)
|
||||
{
|
||||
@@ -1106,7 +1107,7 @@ parse_format_string (char const *fmt)
|
||||
i = endptr - fmt;
|
||||
|
||||
if (fmt[i] == '\0')
|
||||
error (EXIT_FAILURE, 0, _("format %s ends in %%"), quote (fmt));
|
||||
die (EXIT_FAILURE, 0, _("format %s ends in %%"), quote (fmt));
|
||||
|
||||
if (fmt[i] == '.')
|
||||
{
|
||||
@@ -1121,23 +1122,23 @@ parse_format_string (char const *fmt)
|
||||
negative precision is only supported (and ignored)
|
||||
when used with '.*f'. glibc at least will malform
|
||||
output when passed a direct negative precision. */
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid precision in format %s"), quote (fmt));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid precision in format %s"), quote (fmt));
|
||||
}
|
||||
i = endptr - fmt;
|
||||
}
|
||||
|
||||
if (fmt[i] != 'f')
|
||||
error (EXIT_FAILURE, 0, _("invalid format %s,"
|
||||
" directive must be %%[0]['][-][N][.][N]f"),
|
||||
quote (fmt));
|
||||
die (EXIT_FAILURE, 0, _("invalid format %s,"
|
||||
" directive must be %%[0]['][-][N][.][N]f"),
|
||||
quote (fmt));
|
||||
i++;
|
||||
suffix_pos = i;
|
||||
|
||||
for (; fmt[i] != '\0'; i += (fmt[i] == '%') + 1)
|
||||
if (fmt[i] == '%' && fmt[i + 1] != '%')
|
||||
error (EXIT_FAILURE, 0, _("format %s has too many %% directives"),
|
||||
quote (fmt));
|
||||
die (EXIT_FAILURE, 0, _("format %s has too many %% directives"),
|
||||
quote (fmt));
|
||||
|
||||
if (prefix_len)
|
||||
format_str_prefix = xstrndup (fmt, prefix_len);
|
||||
@@ -1496,8 +1497,8 @@ main (int argc, char **argv)
|
||||
case PADDING_OPTION:
|
||||
if (xstrtol (optarg, NULL, 10, &padding_width, "") != LONGINT_OK
|
||||
|| padding_width == 0)
|
||||
error (EXIT_FAILURE, 0, _("invalid padding value %s"),
|
||||
quote (optarg));
|
||||
die (EXIT_FAILURE, 0, _("invalid padding value %s"),
|
||||
quote (optarg));
|
||||
if (padding_width < 0)
|
||||
{
|
||||
padding_alignment = MBS_ALIGN_LEFT;
|
||||
@@ -1509,15 +1510,15 @@ main (int argc, char **argv)
|
||||
|
||||
case FIELD_OPTION:
|
||||
if (n_frp)
|
||||
error (EXIT_FAILURE, 0, _("multiple field specifications"));
|
||||
die (EXIT_FAILURE, 0, _("multiple field specifications"));
|
||||
set_fields (optarg, SETFLD_ALLOW_DASH);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
/* Interpret -d '' to mean 'use the NUL byte as the delimiter.' */
|
||||
if (optarg[0] != '\0' && optarg[1] != '\0')
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("the delimiter must be a single character"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("the delimiter must be a single character"));
|
||||
delimiter = optarg[0];
|
||||
break;
|
||||
|
||||
@@ -1543,8 +1544,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
if (xstrtoumax (optarg, NULL, 10, &header, "") != LONGINT_OK
|
||||
|| header == 0)
|
||||
error (EXIT_FAILURE, 0, _("invalid header value %s"),
|
||||
quote (optarg));
|
||||
die (EXIT_FAILURE, 0, _("invalid header value %s"),
|
||||
quote (optarg));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1570,7 +1571,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (format_str != NULL && grouping)
|
||||
error (EXIT_FAILURE, 0, _("--grouping cannot be combined with --format"));
|
||||
die (EXIT_FAILURE, 0, _("--grouping cannot be combined with --format"));
|
||||
|
||||
if (debug && ! locale_ok)
|
||||
error (0, 0, _("failed to set locale"));
|
||||
@@ -1586,7 +1587,7 @@ main (int argc, char **argv)
|
||||
if (grouping)
|
||||
{
|
||||
if (scale_to != scale_none)
|
||||
error (EXIT_FAILURE, 0, _("grouping cannot be combined with --to"));
|
||||
die (EXIT_FAILURE, 0, _("grouping cannot be combined with --to"));
|
||||
if (debug && (strlen (nl_langinfo (THOUSEP)) == 0))
|
||||
error (0, 0, _("grouping has no effect in this locale"));
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "argmatch.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "ftoastr.h"
|
||||
#include "quote.h"
|
||||
@@ -1102,7 +1103,7 @@ skip (uintmax_t n_skip)
|
||||
}
|
||||
|
||||
if (n_skip != 0)
|
||||
error (EXIT_FAILURE, 0, _("cannot skip past end of combined input"));
|
||||
die (EXIT_FAILURE, 0, _("cannot skip past end of combined input"));
|
||||
|
||||
return ok;
|
||||
}
|
||||
@@ -1654,10 +1655,10 @@ main (int argc, char **argv)
|
||||
address_pad_len = 0;
|
||||
break;
|
||||
default:
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid output address radix '%c';\
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid output address radix '%c';\
|
||||
it must be one character from [doxn]"),
|
||||
optarg[0]);
|
||||
optarg[0]);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -1692,7 +1693,7 @@ main (int argc, char **argv)
|
||||
/* The minimum string length may be no larger than SIZE_MAX,
|
||||
since we may allocate a buffer of this size. */
|
||||
if (SIZE_MAX < tmp)
|
||||
error (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
|
||||
die (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
|
||||
|
||||
string_min = tmp;
|
||||
}
|
||||
@@ -1773,7 +1774,7 @@ main (int argc, char **argv)
|
||||
if (s_err != LONGINT_OK)
|
||||
xstrtol_fatal (s_err, oi, c, long_options, optarg);
|
||||
if (SIZE_MAX < w_tmp)
|
||||
error (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
|
||||
die (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
|
||||
desired_width = w_tmp;
|
||||
}
|
||||
break;
|
||||
@@ -1792,8 +1793,8 @@ main (int argc, char **argv)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (flag_dump_strings && n_specs > 0)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("no type may be specified when dumping strings"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("no type may be specified when dumping strings"));
|
||||
|
||||
n_files = argc - optind;
|
||||
|
||||
@@ -1889,7 +1890,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
end_offset = n_bytes_to_skip + max_bytes_to_format;
|
||||
if (end_offset < n_bytes_to_skip)
|
||||
error (EXIT_FAILURE, 0, _("skip-bytes + read-bytes is too large"));
|
||||
die (EXIT_FAILURE, 0, _("skip-bytes + read-bytes is too large"));
|
||||
}
|
||||
|
||||
if (n_specs == 0)
|
||||
@@ -1979,7 +1980,7 @@ main (int argc, char **argv)
|
||||
cleanup:
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("standard input"));
|
||||
die (EXIT_FAILURE, errno, _("standard input"));
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
+8
-7
@@ -41,6 +41,7 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
|
||||
@@ -159,7 +160,7 @@ static void write_error (void) ATTRIBUTE_NORETURN;
|
||||
static void
|
||||
write_error (void)
|
||||
{
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
abort ();
|
||||
}
|
||||
|
||||
@@ -211,7 +212,7 @@ paste_parallel (size_t nfiles, char **fnamptr)
|
||||
{
|
||||
fileptr[files_open] = fopen (fnamptr[files_open], "r");
|
||||
if (fileptr[files_open] == NULL)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (fnamptr[files_open]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (fnamptr[files_open]));
|
||||
else if (fileno (fileptr[files_open]) == STDIN_FILENO)
|
||||
opened_stdin = true;
|
||||
fadvise (fileptr[files_open], FADVISE_SEQUENTIAL);
|
||||
@@ -219,7 +220,7 @@ paste_parallel (size_t nfiles, char **fnamptr)
|
||||
}
|
||||
|
||||
if (opened_stdin && have_read_stdin)
|
||||
error (EXIT_FAILURE, 0, _("standard input is closed"));
|
||||
die (EXIT_FAILURE, 0, _("standard input is closed"));
|
||||
|
||||
/* Read a line from each file and output it to stdout separated by a
|
||||
delimiter, until we go through the loop without successfully
|
||||
@@ -515,9 +516,9 @@ main (int argc, char **argv)
|
||||
{
|
||||
/* Don't use the quote() quoting style, because that would double the
|
||||
number of displayed backslashes, making the diagnostic look bogus. */
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("delimiter list ends with an unescaped backslash: %s"),
|
||||
quotearg_n_style_colon (0, c_maybe_quoting_style, delim_arg));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("delimiter list ends with an unescaped backslash: %s"),
|
||||
quotearg_n_style_colon (0, c_maybe_quoting_style, delim_arg));
|
||||
}
|
||||
|
||||
bool ok = ((serial_merge ? paste_serial : paste_parallel)
|
||||
@@ -526,6 +527,6 @@ main (int argc, char **argv)
|
||||
free (delims);
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
die (EXIT_FAILURE, errno, "-");
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
+2
-1
@@ -25,6 +25,7 @@
|
||||
#include "system.h"
|
||||
|
||||
#include "canon-host.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "hard-locale.h"
|
||||
#include "readutmp.h"
|
||||
@@ -466,7 +467,7 @@ short_pinky (const char *filename,
|
||||
STRUCT_UTMP *utmp_buf = NULL;
|
||||
|
||||
if (read_utmp (filename, &n_users, &utmp_buf, 0) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
|
||||
scan_entries (n_users, utmp_buf, argc_names, argv_names);
|
||||
|
||||
|
||||
@@ -312,6 +312,7 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "hard-locale.h"
|
||||
@@ -903,11 +904,11 @@ main (int argc, char **argv)
|
||||
case PAGES_OPTION: /* --pages=FIRST_PAGE[:LAST_PAGE] */
|
||||
{ /* dominates old opt +... */
|
||||
if (! optarg)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("'--pages=FIRST_PAGE[:LAST_PAGE]' missing argument"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("'--pages=FIRST_PAGE[:LAST_PAGE]' missing argument"));
|
||||
else if (! first_last_page (oi, 0, optarg))
|
||||
error (EXIT_FAILURE, 0, _("invalid page range %s"),
|
||||
quote (optarg));
|
||||
die (EXIT_FAILURE, 0, _("invalid page range %s"),
|
||||
quote (optarg));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1059,11 +1060,11 @@ main (int argc, char **argv)
|
||||
first_page_number = 1;
|
||||
|
||||
if (parallel_files && explicit_columns)
|
||||
error (EXIT_FAILURE, 0,
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot specify number of columns when printing in parallel"));
|
||||
|
||||
if (parallel_files && print_across_flag)
|
||||
error (EXIT_FAILURE, 0,
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot specify both printing across and printing in parallel"));
|
||||
|
||||
/* Translate some old short options to new/long options.
|
||||
@@ -1137,7 +1138,7 @@ main (int argc, char **argv)
|
||||
IF_LINT (free (file_names));
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("standard input"));
|
||||
die (EXIT_FAILURE, errno, _("standard input"));
|
||||
return failed_opens ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1265,7 +1266,7 @@ init_parameters (int number_of_files)
|
||||
- (columns - 1) * col_sep_length) / columns;
|
||||
|
||||
if (chars_per_column < 1)
|
||||
error (EXIT_FAILURE, 0, _("page width too narrow"));
|
||||
die (EXIT_FAILURE, 0, _("page width too narrow"));
|
||||
|
||||
if (numbered_lines)
|
||||
{
|
||||
@@ -1493,9 +1494,9 @@ close_file (COLUMN *p)
|
||||
if (p->status == CLOSED)
|
||||
return;
|
||||
if (ferror (p->fp))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (p->name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (p->name));
|
||||
if (fileno (p->fp) != STDIN_FILENO && fclose (p->fp) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (p->name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (p->name));
|
||||
|
||||
if (!parallel_files)
|
||||
{
|
||||
@@ -2352,7 +2353,7 @@ print_header (void)
|
||||
print_white_space ();
|
||||
|
||||
if (page_number == 0)
|
||||
error (EXIT_FAILURE, 0, _("page number overflow"));
|
||||
die (EXIT_FAILURE, 0, _("page number overflow"));
|
||||
|
||||
/* The translator must ensure that formatting the translation of
|
||||
"Page %"PRIuMAX does not generate more than (sizeof page_text - 1)
|
||||
|
||||
+12
-11
@@ -56,6 +56,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "c-strtod.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "unicodeio.h"
|
||||
@@ -250,7 +251,7 @@ print_esc (const char *escstart, bool octal_0)
|
||||
++esc_length, ++p)
|
||||
esc_value = esc_value * 16 + hextobin (*p);
|
||||
if (esc_length == 0)
|
||||
error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
|
||||
die (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
|
||||
putchar (esc_value);
|
||||
}
|
||||
else if (isodigit (*p))
|
||||
@@ -277,7 +278,7 @@ print_esc (const char *escstart, bool octal_0)
|
||||
--esc_length, ++p)
|
||||
{
|
||||
if (! isxdigit (to_uchar (*p)))
|
||||
error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
|
||||
die (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
|
||||
uni_value = uni_value * 16 + hextobin (*p);
|
||||
}
|
||||
|
||||
@@ -289,8 +290,8 @@ print_esc (const char *escstart, bool octal_0)
|
||||
if ((uni_value <= 0x9f
|
||||
&& uni_value != 0x24 && uni_value != 0x40 && uni_value != 0x60)
|
||||
|| (uni_value >= 0xd800 && uni_value <= 0xdfff))
|
||||
error (EXIT_FAILURE, 0, _("invalid universal character name \\%c%0*x"),
|
||||
esc_char, (esc_char == 'u' ? 4 : 8), uni_value);
|
||||
die (EXIT_FAILURE, 0, _("invalid universal character name \\%c%0*x"),
|
||||
esc_char, (esc_char == 'u' ? 4 : 8), uni_value);
|
||||
|
||||
print_unicode_char (stdout, uni_value, 0);
|
||||
}
|
||||
@@ -562,8 +563,8 @@ print_formatted (const char *format, int argc, char **argv)
|
||||
if (INT_MIN <= width && width <= INT_MAX)
|
||||
field_width = width;
|
||||
else
|
||||
error (EXIT_FAILURE, 0, _("invalid field width: %s"),
|
||||
quote (*argv));
|
||||
die (EXIT_FAILURE, 0, _("invalid field width: %s"),
|
||||
quote (*argv));
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
@@ -597,8 +598,8 @@ print_formatted (const char *format, int argc, char **argv)
|
||||
precision = -1;
|
||||
}
|
||||
else if (INT_MAX < prec)
|
||||
error (EXIT_FAILURE, 0, _("invalid precision: %s"),
|
||||
quote (*argv));
|
||||
die (EXIT_FAILURE, 0, _("invalid precision: %s"),
|
||||
quote (*argv));
|
||||
else
|
||||
precision = prec;
|
||||
++argv;
|
||||
@@ -623,9 +624,9 @@ print_formatted (const char *format, int argc, char **argv)
|
||||
{
|
||||
unsigned char conversion = *f;
|
||||
if (! ok[conversion])
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%.*s: invalid conversion specification"),
|
||||
(int) (f + 1 - direc_start), direc_start);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("%.*s: invalid conversion specification"),
|
||||
(int) (f + 1 - direc_start), direc_start);
|
||||
}
|
||||
|
||||
print_direc (direc_start, direc_length, *f,
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include <regex.h>
|
||||
#include "argmatch.h"
|
||||
#include "diacrit.h"
|
||||
@@ -280,8 +281,7 @@ static BLOCK reference; /* reference field for input reference mode */
|
||||
static void ATTRIBUTE_NORETURN
|
||||
matcher_error (void)
|
||||
{
|
||||
error (0, errno, _("error in regular expression matcher"));
|
||||
exit (EXIT_FAILURE);
|
||||
die (EXIT_FAILURE, errno, _("error in regular expression matcher"));
|
||||
}
|
||||
|
||||
/*------------------------------------------------------.
|
||||
@@ -416,7 +416,7 @@ compile_regex (struct regex_data *regex)
|
||||
|
||||
message = re_compile_pattern (string, strlen (string), pattern);
|
||||
if (message)
|
||||
error (EXIT_FAILURE, 0, _("%s (for regexp %s)"), message, quote (string));
|
||||
die (EXIT_FAILURE, 0, _("%s (for regexp %s)"), message, quote (string));
|
||||
|
||||
/* The fastmap should be compiled before 're_match'. The following
|
||||
call is not mandatory, because 're_search' is always called sooner,
|
||||
@@ -520,7 +520,7 @@ swallow_file_in_memory (const char *file_name, BLOCK *block)
|
||||
block->start = read_file (file_name, &used_length);
|
||||
|
||||
if (!block->start)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (using_stdin ? "-" : file_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (using_stdin ? "-" : file_name));
|
||||
|
||||
block->end = block->start + used_length;
|
||||
}
|
||||
@@ -1947,8 +1947,8 @@ main (int argc, char **argv)
|
||||
unsigned long int tmp_ulong;
|
||||
if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK
|
||||
|| ! (0 < tmp_ulong && tmp_ulong <= INT_MAX))
|
||||
error (EXIT_FAILURE, 0, _("invalid gap width: %s"),
|
||||
quote (optarg));
|
||||
die (EXIT_FAILURE, 0, _("invalid gap width: %s"),
|
||||
quote (optarg));
|
||||
gap_size = tmp_ulong;
|
||||
break;
|
||||
}
|
||||
@@ -1974,8 +1974,8 @@ main (int argc, char **argv)
|
||||
unsigned long int tmp_ulong;
|
||||
if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK
|
||||
|| ! (0 < tmp_ulong && tmp_ulong <= INT_MAX))
|
||||
error (EXIT_FAILURE, 0, _("invalid line width: %s"),
|
||||
quote (optarg));
|
||||
die (EXIT_FAILURE, 0, _("invalid line width: %s"),
|
||||
quote (optarg));
|
||||
line_width = tmp_ulong;
|
||||
break;
|
||||
}
|
||||
@@ -2076,7 +2076,7 @@ main (int argc, char **argv)
|
||||
if (optind < argc)
|
||||
{
|
||||
if (! freopen (argv[optind], "w", stdout))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
|
||||
optind++;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "root-dev-ino.h"
|
||||
@@ -161,17 +162,17 @@ find_dir_entry (struct stat *dot_sb, struct file_name *file_name,
|
||||
|
||||
dirp = opendir ("..");
|
||||
if (dirp == NULL)
|
||||
error (EXIT_FAILURE, errno, _("cannot open directory %s"),
|
||||
quote (nth_parent (parent_height)));
|
||||
die (EXIT_FAILURE, errno, _("cannot open directory %s"),
|
||||
quote (nth_parent (parent_height)));
|
||||
|
||||
fd = dirfd (dirp);
|
||||
if ((0 <= fd ? fchdir (fd) : chdir ("..")) < 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to chdir to %s"),
|
||||
quote (nth_parent (parent_height)));
|
||||
die (EXIT_FAILURE, errno, _("failed to chdir to %s"),
|
||||
quote (nth_parent (parent_height)));
|
||||
|
||||
if ((0 <= fd ? fstat (fd, &parent_sb) : stat (".", &parent_sb)) < 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to stat %s"),
|
||||
quote (nth_parent (parent_height)));
|
||||
die (EXIT_FAILURE, errno, _("failed to stat %s"),
|
||||
quote (nth_parent (parent_height)));
|
||||
|
||||
/* If parent and child directory are on different devices, then we
|
||||
can't rely on d_ino for useful i-node numbers; use lstat instead. */
|
||||
@@ -229,14 +230,14 @@ find_dir_entry (struct stat *dot_sb, struct file_name *file_name,
|
||||
{
|
||||
/* Note that this diagnostic serves for both readdir
|
||||
and closedir failures. */
|
||||
error (EXIT_FAILURE, errno, _("reading directory %s"),
|
||||
quote (nth_parent (parent_height)));
|
||||
die (EXIT_FAILURE, errno, _("reading directory %s"),
|
||||
quote (nth_parent (parent_height)));
|
||||
}
|
||||
|
||||
if ( ! found)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("couldn't find directory entry in %s with matching i-node"),
|
||||
quote (nth_parent (parent_height)));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("couldn't find directory entry in %s with matching i-node"),
|
||||
quote (nth_parent (parent_height)));
|
||||
|
||||
*dot_sb = parent_sb;
|
||||
}
|
||||
@@ -273,11 +274,11 @@ robust_getcwd (struct file_name *file_name)
|
||||
struct stat dot_sb;
|
||||
|
||||
if (root_dev_ino == NULL)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
|
||||
if (stat (".", &dot_sb) < 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to stat %s"), quoteaf ("."));
|
||||
die (EXIT_FAILURE, errno, _("failed to stat %s"), quoteaf ("."));
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
+6
-5
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "canonicalize.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "relpath.h"
|
||||
|
||||
@@ -142,7 +143,7 @@ isdir (const char *path)
|
||||
{
|
||||
struct stat sb;
|
||||
if (stat (path, &sb) != 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot stat %s"), quoteaf (path));
|
||||
die (EXIT_FAILURE, errno, _("cannot stat %s"), quoteaf (path));
|
||||
return S_ISDIR (sb.st_mode);
|
||||
}
|
||||
|
||||
@@ -245,9 +246,9 @@ main (int argc, char **argv)
|
||||
{
|
||||
can_relative_to = realpath_canon (relative_to, can_mode);
|
||||
if (!can_relative_to)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (relative_to));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (relative_to));
|
||||
if (need_dir && !isdir (can_relative_to))
|
||||
error (EXIT_FAILURE, ENOTDIR, "%s", quotef (relative_to));
|
||||
die (EXIT_FAILURE, ENOTDIR, "%s", quotef (relative_to));
|
||||
}
|
||||
if (relative_base == relative_to)
|
||||
can_relative_base = can_relative_to;
|
||||
@@ -255,9 +256,9 @@ main (int argc, char **argv)
|
||||
{
|
||||
char *base = realpath_canon (relative_base, can_mode);
|
||||
if (!base)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (relative_base));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (relative_base));
|
||||
if (need_dir && !isdir (base))
|
||||
error (EXIT_FAILURE, ENOTDIR, "%s", quotef (relative_base));
|
||||
die (EXIT_FAILURE, ENOTDIR, "%s", quotef (relative_base));
|
||||
/* --relative-to is a no-op if it does not have --relative-base
|
||||
as a prefix */
|
||||
if (path_prefix (base, can_relative_to))
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "argmatch.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "remove.h"
|
||||
#include "root-dev-ino.h"
|
||||
@@ -288,8 +289,8 @@ main (int argc, char **argv)
|
||||
|
||||
case NO_PRESERVE_ROOT:
|
||||
if (! STREQ (argv[optind - 1], "--no-preserve-root"))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("you may not abbreviate the --no-preserve-root option"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("you may not abbreviate the --no-preserve-root option"));
|
||||
preserve_root = false;
|
||||
break;
|
||||
|
||||
@@ -329,8 +330,8 @@ main (int argc, char **argv)
|
||||
static struct dev_ino dev_ino_buf;
|
||||
x.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (x.root_dev_ino == NULL)
|
||||
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
|
||||
uintmax_t n_files = argc - optind;
|
||||
|
||||
+29
-28
@@ -47,6 +47,7 @@
|
||||
#include <selinux/context.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
@@ -135,22 +136,22 @@ main (int argc, char **argv)
|
||||
{
|
||||
case 'r':
|
||||
if (role)
|
||||
error (EXIT_FAILURE, 0, _("multiple roles"));
|
||||
die (EXIT_FAILURE, 0, _("multiple roles"));
|
||||
role = optarg;
|
||||
break;
|
||||
case 't':
|
||||
if (type)
|
||||
error (EXIT_FAILURE, 0, _("multiple types"));
|
||||
die (EXIT_FAILURE, 0, _("multiple types"));
|
||||
type = optarg;
|
||||
break;
|
||||
case 'u':
|
||||
if (user)
|
||||
error (EXIT_FAILURE, 0, _("multiple users"));
|
||||
die (EXIT_FAILURE, 0, _("multiple users"));
|
||||
user = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
if (range)
|
||||
error (EXIT_FAILURE, 0, _("multiple levelranges"));
|
||||
die (EXIT_FAILURE, 0, _("multiple levelranges"));
|
||||
range = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
@@ -168,7 +169,7 @@ main (int argc, char **argv)
|
||||
if (argc - optind == 0)
|
||||
{
|
||||
if (getcon (&cur_context) < 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to get current context"));
|
||||
die (EXIT_FAILURE, errno, _("failed to get current context"));
|
||||
fputs (cur_context, stdout);
|
||||
fputc ('\n', stdout);
|
||||
return EXIT_SUCCESS;
|
||||
@@ -191,34 +192,34 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (is_selinux_enabled () != 1)
|
||||
error (EXIT_FAILURE, 0, _("%s may be used only on a SELinux kernel"),
|
||||
program_name);
|
||||
die (EXIT_FAILURE, 0, _("%s may be used only on a SELinux kernel"),
|
||||
program_name);
|
||||
|
||||
if (context)
|
||||
{
|
||||
con = context_new (context);
|
||||
if (!con)
|
||||
error (EXIT_FAILURE, errno, _("failed to create security context: %s"),
|
||||
quote (context));
|
||||
die (EXIT_FAILURE, errno, _("failed to create security context: %s"),
|
||||
quote (context));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getcon (&cur_context) < 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to get current context"));
|
||||
die (EXIT_FAILURE, errno, _("failed to get current context"));
|
||||
|
||||
/* We will generate context based on process transition */
|
||||
if (compute_trans)
|
||||
{
|
||||
/* Get context of file to be executed */
|
||||
if (getfilecon (argv[optind], &file_context) == -1)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("failed to get security context of %s"),
|
||||
quoteaf (argv[optind]));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("failed to get security context of %s"),
|
||||
quoteaf (argv[optind]));
|
||||
/* compute result of process transition */
|
||||
if (security_compute_create (cur_context, file_context,
|
||||
string_to_security_class ("process"),
|
||||
&new_context) != 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to compute a new context"));
|
||||
die (EXIT_FAILURE, errno, _("failed to compute a new context"));
|
||||
/* free contexts */
|
||||
freecon (file_context);
|
||||
freecon (cur_context);
|
||||
@@ -229,29 +230,29 @@ main (int argc, char **argv)
|
||||
|
||||
con = context_new (cur_context);
|
||||
if (!con)
|
||||
error (EXIT_FAILURE, errno, _("failed to create security context: %s"),
|
||||
quote (cur_context));
|
||||
die (EXIT_FAILURE, errno, _("failed to create security context: %s"),
|
||||
quote (cur_context));
|
||||
if (user && context_user_set (con, user))
|
||||
error (EXIT_FAILURE, errno, _("failed to set new user: %s"),
|
||||
quote (user));
|
||||
die (EXIT_FAILURE, errno, _("failed to set new user: %s"),
|
||||
quote (user));
|
||||
if (type && context_type_set (con, type))
|
||||
error (EXIT_FAILURE, errno, _("failed to set new type: %s"),
|
||||
quote (type));
|
||||
die (EXIT_FAILURE, errno, _("failed to set new type: %s"),
|
||||
quote (type));
|
||||
if (range && context_range_set (con, range))
|
||||
error (EXIT_FAILURE, errno, _("failed to set new range: %s"),
|
||||
quote (range));
|
||||
die (EXIT_FAILURE, errno, _("failed to set new range: %s"),
|
||||
quote (range));
|
||||
if (role && context_role_set (con, role))
|
||||
error (EXIT_FAILURE, errno, _("failed to set new role: %s"),
|
||||
quote (role));
|
||||
die (EXIT_FAILURE, errno, _("failed to set new role: %s"),
|
||||
quote (role));
|
||||
}
|
||||
|
||||
if (security_check_context (context_str (con)) < 0)
|
||||
error (EXIT_FAILURE, errno, _("invalid context: %s"),
|
||||
quote (context_str (con)));
|
||||
die (EXIT_FAILURE, errno, _("invalid context: %s"),
|
||||
quote (context_str (con)));
|
||||
|
||||
if (setexeccon (context_str (con)) != 0)
|
||||
error (EXIT_FAILURE, errno, _("unable to set security context %s"),
|
||||
quote (context_str (con)));
|
||||
die (EXIT_FAILURE, errno, _("unable to set security context %s"),
|
||||
quote (context_str (con)));
|
||||
if (cur_context != NULL)
|
||||
freecon (cur_context);
|
||||
|
||||
|
||||
+5
-4
@@ -21,6 +21,7 @@
|
||||
#include <selinux/context.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "system.h"
|
||||
#include "canonicalize.h"
|
||||
@@ -123,8 +124,8 @@ defaultcon (char const *path, mode_t mode)
|
||||
with libselinux < 2.1.5 2011-0826. */
|
||||
newpath = canonicalize_filename_mode (path, CAN_MISSING);
|
||||
if (! newpath)
|
||||
error (EXIT_FAILURE, errno, _("error canonicalizing %s"),
|
||||
quoteaf (path));
|
||||
die (EXIT_FAILURE, errno, _("error canonicalizing %s"),
|
||||
quoteaf (path));
|
||||
path = newpath;
|
||||
}
|
||||
|
||||
@@ -296,8 +297,8 @@ restorecon (char const *path, bool recurse, bool local)
|
||||
fts entries, which may be quicker to process in any case. */
|
||||
newpath = canonicalize_filename_mode (path, CAN_MISSING);
|
||||
if (! newpath)
|
||||
error (EXIT_FAILURE, errno, _("error canonicalizing %s"),
|
||||
quoteaf (path));
|
||||
die (EXIT_FAILURE, errno, _("error canonicalizing %s"),
|
||||
quoteaf (path));
|
||||
}
|
||||
|
||||
const char *ftspath[2] = { newpath ? newpath : path, NULL };
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "c-strtod.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
@@ -235,8 +236,8 @@ long_double_format (char const *fmt, struct layout *layout)
|
||||
for (i = 0; ! (fmt[i] == '%' && fmt[i + 1] != '%'); i += (fmt[i] == '%') + 1)
|
||||
{
|
||||
if (!fmt[i])
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("format %s has no %% directive"), quote (fmt));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("format %s has no %% directive"), quote (fmt));
|
||||
prefix_len++;
|
||||
}
|
||||
|
||||
@@ -253,15 +254,15 @@ long_double_format (char const *fmt, struct layout *layout)
|
||||
has_L = (fmt[i] == 'L');
|
||||
i += has_L;
|
||||
if (fmt[i] == '\0')
|
||||
error (EXIT_FAILURE, 0, _("format %s ends in %%"), quote (fmt));
|
||||
die (EXIT_FAILURE, 0, _("format %s ends in %%"), quote (fmt));
|
||||
if (! strchr ("efgaEFGA", fmt[i]))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("format %s has unknown %%%c directive"), quote (fmt), fmt[i]);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("format %s has unknown %%%c directive"), quote (fmt), fmt[i]);
|
||||
|
||||
for (i++; ; i += (fmt[i] == '%') + 1)
|
||||
if (fmt[i] == '%' && fmt[i + 1] != '%')
|
||||
error (EXIT_FAILURE, 0, _("format %s has too many %% directives"),
|
||||
quote (fmt));
|
||||
die (EXIT_FAILURE, 0, _("format %s has too many %% directives"),
|
||||
quote (fmt));
|
||||
else if (fmt[i])
|
||||
suffix_len++;
|
||||
else
|
||||
@@ -282,9 +283,8 @@ static void ATTRIBUTE_NORETURN
|
||||
io_error (void)
|
||||
{
|
||||
/* FIXME: consider option to silently ignore errno=EPIPE */
|
||||
error (0, errno, _("standard output"));
|
||||
clearerr (stdout);
|
||||
exit (EXIT_FAILURE);
|
||||
die (EXIT_FAILURE, errno, _("standard output"));
|
||||
}
|
||||
|
||||
/* Actually print the sequence of numbers in the specified range, with the
|
||||
|
||||
+3
-2
@@ -87,6 +87,7 @@
|
||||
#include "system.h"
|
||||
#include "argmatch.h"
|
||||
#include "xdectoint.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fcntl--.h"
|
||||
#include "human.h"
|
||||
@@ -1252,7 +1253,7 @@ main (int argc, char **argv)
|
||||
|
||||
case RANDOM_SOURCE_OPTION:
|
||||
if (random_source && !STREQ (random_source, optarg))
|
||||
error (EXIT_FAILURE, 0, _("multiple random sources specified"));
|
||||
die (EXIT_FAILURE, 0, _("multiple random sources specified"));
|
||||
random_source = optarg;
|
||||
break;
|
||||
|
||||
@@ -1301,7 +1302,7 @@ main (int argc, char **argv)
|
||||
|
||||
randint_source = randint_all_new (random_source, SIZE_MAX);
|
||||
if (! randint_source)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (random_source));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (random_source));
|
||||
atexit (clear_random_data);
|
||||
|
||||
for (i = 0; i < n_files; i++)
|
||||
|
||||
+17
-16
@@ -22,6 +22,7 @@
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "getopt.h"
|
||||
@@ -222,14 +223,14 @@ read_input_reservoir_sampling (FILE *in, char eolbyte, size_t k,
|
||||
while (readlinebuffer_delim (line, in, eolbyte) != NULL && n_lines++);
|
||||
|
||||
if (! n_lines)
|
||||
error (EXIT_FAILURE, EOVERFLOW, _("too many input lines"));
|
||||
die (EXIT_FAILURE, EOVERFLOW, _("too many input lines"));
|
||||
|
||||
freebuffer (&dummy);
|
||||
}
|
||||
|
||||
/* no more input lines, or an input error. */
|
||||
if (ferror (in))
|
||||
error (EXIT_FAILURE, errno, _("read error"));
|
||||
die (EXIT_FAILURE, errno, _("read error"));
|
||||
|
||||
*out_rsrv = rsrv;
|
||||
return MIN (k, n_lines);
|
||||
@@ -278,7 +279,7 @@ read_input (FILE *in, char eolbyte, char ***pline)
|
||||
avoiding the reservoir CPU overhead when reading < RESERVOIR_MIN_INPUT
|
||||
from a pipe, and allow us to dispense with the input_size() function. */
|
||||
if (!(buf = fread_file (in, &used)))
|
||||
error (EXIT_FAILURE, errno, _("read error"));
|
||||
die (EXIT_FAILURE, errno, _("read error"));
|
||||
|
||||
if (used && buf[used - 1] != eolbyte)
|
||||
buf[used++] = eolbyte;
|
||||
@@ -424,7 +425,7 @@ main (int argc, char **argv)
|
||||
bool invalid = !p;
|
||||
|
||||
if (input_range)
|
||||
error (EXIT_FAILURE, 0, _("multiple -i options specified"));
|
||||
die (EXIT_FAILURE, 0, _("multiple -i options specified"));
|
||||
input_range = true;
|
||||
|
||||
if (p)
|
||||
@@ -442,8 +443,8 @@ main (int argc, char **argv)
|
||||
n_lines = hi_input - lo_input + 1;
|
||||
invalid |= ((lo_input <= hi_input) == (n_lines == 0));
|
||||
if (invalid)
|
||||
error (EXIT_FAILURE, errno, "%s: %s", _("invalid input range"),
|
||||
quote (optarg));
|
||||
die (EXIT_FAILURE, errno, "%s: %s", _("invalid input range"),
|
||||
quote (optarg));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -455,20 +456,20 @@ main (int argc, char **argv)
|
||||
if (e == LONGINT_OK)
|
||||
head_lines = MIN (head_lines, argval);
|
||||
else if (e != LONGINT_OVERFLOW)
|
||||
error (EXIT_FAILURE, 0, _("invalid line count: %s"),
|
||||
quote (optarg));
|
||||
die (EXIT_FAILURE, 0, _("invalid line count: %s"),
|
||||
quote (optarg));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
if (outfile && !STREQ (outfile, optarg))
|
||||
error (EXIT_FAILURE, 0, _("multiple output files specified"));
|
||||
die (EXIT_FAILURE, 0, _("multiple output files specified"));
|
||||
outfile = optarg;
|
||||
break;
|
||||
|
||||
case RANDOM_SOURCE_OPTION:
|
||||
if (random_source && !STREQ (random_source, optarg))
|
||||
error (EXIT_FAILURE, 0, _("multiple random sources specified"));
|
||||
die (EXIT_FAILURE, 0, _("multiple random sources specified"));
|
||||
random_source = optarg;
|
||||
break;
|
||||
|
||||
@@ -519,7 +520,7 @@ main (int argc, char **argv)
|
||||
if (n_operands == 1)
|
||||
if (! (STREQ (operand[0], "-") || ! head_lines
|
||||
|| freopen (operand[0], "r", stdin)))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (operand[0]));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (operand[0]));
|
||||
|
||||
fadvise (stdin, FADVISE_SEQUENTIAL);
|
||||
|
||||
@@ -544,7 +545,7 @@ main (int argc, char **argv)
|
||||
? SIZE_MAX
|
||||
: randperm_bound (head_lines, n_lines)));
|
||||
if (! randint_source)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (random_source));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (random_source));
|
||||
|
||||
if (use_reservoir_sampling)
|
||||
{
|
||||
@@ -560,13 +561,13 @@ main (int argc, char **argv)
|
||||
stdin. */
|
||||
if (! (echo || input_range)
|
||||
&& (fclose (stdin) != 0))
|
||||
error (EXIT_FAILURE, errno, _("read error"));
|
||||
die (EXIT_FAILURE, errno, _("read error"));
|
||||
|
||||
if (!repeat)
|
||||
permutation = randperm_new (randint_source, head_lines, n_lines);
|
||||
|
||||
if (outfile && ! freopen (outfile, "w", stdout))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (outfile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (outfile));
|
||||
|
||||
/* Generate output according to requested method */
|
||||
if (repeat)
|
||||
@@ -576,7 +577,7 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
if (n_lines == 0)
|
||||
error (EXIT_FAILURE, 0, _("no lines to repeat"));
|
||||
die (EXIT_FAILURE, 0, _("no lines to repeat"));
|
||||
if (input_range)
|
||||
i = write_random_numbers (randint_source, head_lines,
|
||||
lo_input, hi_input, eolbyte);
|
||||
@@ -596,7 +597,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (i != 0)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
#ifdef lint
|
||||
free (permutation);
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "c-strtod.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
@@ -143,7 +144,7 @@ main (int argc, char **argv)
|
||||
usage (EXIT_FAILURE);
|
||||
|
||||
if (xnanosleep (seconds))
|
||||
error (EXIT_FAILURE, errno, _("cannot read realtime clock"));
|
||||
die (EXIT_FAILURE, errno, _("cannot read realtime clock"));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+68
-68
@@ -31,6 +31,7 @@
|
||||
#include <assert.h>
|
||||
#include "system.h"
|
||||
#include "argmatch.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "filevercmp.h"
|
||||
@@ -404,13 +405,12 @@ async_safe_die (int errnum, const char *errstr)
|
||||
/* Report MESSAGE for FILE, then clean up and exit.
|
||||
If FILE is null, it represents standard output. */
|
||||
|
||||
static void die (char const *, char const *) ATTRIBUTE_NORETURN;
|
||||
static void sort_die (char const *, char const *) ATTRIBUTE_NORETURN;
|
||||
static void
|
||||
die (char const *message, char const *file)
|
||||
sort_die (char const *message, char const *file)
|
||||
{
|
||||
error (0, errno, "%s: %s", message,
|
||||
quotef (file ? file : _("standard output")));
|
||||
exit (SORT_FAILURE);
|
||||
die (SORT_FAILURE, errno, "%s: %s", message,
|
||||
quotef (file ? file : _("standard output")));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -722,13 +722,13 @@ reap (pid_t pid)
|
||||
pid_t cpid = waitpid ((pid ? pid : -1), &status, (pid ? 0 : WNOHANG));
|
||||
|
||||
if (cpid < 0)
|
||||
error (SORT_FAILURE, errno, _("waiting for %s [-d]"),
|
||||
quoteaf (compress_program));
|
||||
die (SORT_FAILURE, errno, _("waiting for %s [-d]"),
|
||||
quoteaf (compress_program));
|
||||
else if (0 < cpid && (0 < pid || delete_proc (cpid)))
|
||||
{
|
||||
if (! WIFEXITED (status) || WEXITSTATUS (status))
|
||||
error (SORT_FAILURE, 0, _("%s [-d] terminated abnormally"),
|
||||
quoteaf (compress_program));
|
||||
die (SORT_FAILURE, 0, _("%s [-d] terminated abnormally"),
|
||||
quoteaf (compress_program));
|
||||
--nprocs;
|
||||
}
|
||||
|
||||
@@ -881,8 +881,8 @@ create_temp_file (int *pfd, bool survive_fd_exhaustion)
|
||||
if (fd < 0)
|
||||
{
|
||||
if (! (survive_fd_exhaustion && errno == EMFILE))
|
||||
error (SORT_FAILURE, errno, _("cannot create temporary file in %s"),
|
||||
quoteaf (temp_dir));
|
||||
die (SORT_FAILURE, errno, _("cannot create temporary file in %s"),
|
||||
quoteaf (temp_dir));
|
||||
free (node);
|
||||
node = NULL;
|
||||
}
|
||||
@@ -957,8 +957,8 @@ stream_open (char const *file, char const *how)
|
||||
else if (*how == 'w')
|
||||
{
|
||||
if (file && ftruncate (STDOUT_FILENO, 0) != 0)
|
||||
error (SORT_FAILURE, errno, _("%s: error truncating"),
|
||||
quotef (file));
|
||||
die (SORT_FAILURE, errno, _("%s: error truncating"),
|
||||
quotef (file));
|
||||
fp = stdout;
|
||||
}
|
||||
else
|
||||
@@ -975,7 +975,7 @@ xfopen (char const *file, char const *how)
|
||||
{
|
||||
FILE *fp = stream_open (file, how);
|
||||
if (!fp)
|
||||
die (_("open failed"), file);
|
||||
sort_die (_("open failed"), file);
|
||||
return fp;
|
||||
}
|
||||
|
||||
@@ -995,12 +995,12 @@ xfclose (FILE *fp, char const *file)
|
||||
case STDOUT_FILENO:
|
||||
/* Don't close stdout just yet. close_stdout does that. */
|
||||
if (fflush (fp) != 0)
|
||||
die (_("fflush failed"), file);
|
||||
sort_die (_("fflush failed"), file);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (fclose (fp) != 0)
|
||||
die (_("close failed"), file);
|
||||
sort_die (_("close failed"), file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1137,7 +1137,7 @@ maybe_create_temp (FILE **pfp, bool survive_fd_exhaustion)
|
||||
|
||||
*pfp = fdopen (tempfd, "w");
|
||||
if (! *pfp)
|
||||
die (_("couldn't create temporary file"), node->name);
|
||||
sort_die (_("couldn't create temporary file"), node->name);
|
||||
|
||||
return node;
|
||||
}
|
||||
@@ -1176,8 +1176,8 @@ open_temp (struct tempnode *temp)
|
||||
{
|
||||
case -1:
|
||||
if (errno != EMFILE)
|
||||
error (SORT_FAILURE, errno, _("couldn't create process for %s -d"),
|
||||
quoteaf (compress_program));
|
||||
die (SORT_FAILURE, errno, _("couldn't create process for %s -d"),
|
||||
quoteaf (compress_program));
|
||||
close (tempfd);
|
||||
errno = EMFILE;
|
||||
break;
|
||||
@@ -1337,9 +1337,9 @@ specify_nmerge (int oi, char c, char const *s)
|
||||
{
|
||||
error (0, 0, _("invalid --%s argument %s"),
|
||||
long_options[oi].name, quote (s));
|
||||
error (SORT_FAILURE, 0,
|
||||
_("minimum --%s argument is %s"),
|
||||
long_options[oi].name, quote ("2"));
|
||||
die (SORT_FAILURE, 0,
|
||||
_("minimum --%s argument is %s"),
|
||||
long_options[oi].name, quote ("2"));
|
||||
}
|
||||
else if (max_nmerge < nmerge)
|
||||
{
|
||||
@@ -1355,10 +1355,10 @@ specify_nmerge (int oi, char c, char const *s)
|
||||
char max_nmerge_buf[INT_BUFSIZE_BOUND (max_nmerge)];
|
||||
error (0, 0, _("--%s argument %s too large"),
|
||||
long_options[oi].name, quote (s));
|
||||
error (SORT_FAILURE, 0,
|
||||
_("maximum --%s argument with current rlimit is %s"),
|
||||
long_options[oi].name,
|
||||
uinttostr (max_nmerge, max_nmerge_buf));
|
||||
die (SORT_FAILURE, 0,
|
||||
_("maximum --%s argument with current rlimit is %s"),
|
||||
long_options[oi].name,
|
||||
uinttostr (max_nmerge, max_nmerge_buf));
|
||||
}
|
||||
else
|
||||
xstrtol_fatal (e, oi, c, long_options, s);
|
||||
@@ -1438,7 +1438,7 @@ specify_nthreads (int oi, char c, char const *s)
|
||||
if (SIZE_MAX < nthreads)
|
||||
nthreads = SIZE_MAX;
|
||||
if (nthreads == 0)
|
||||
error (SORT_FAILURE, 0, _("number in parallel must be nonzero"));
|
||||
die (SORT_FAILURE, 0, _("number in parallel must be nonzero"));
|
||||
return nthreads;
|
||||
}
|
||||
|
||||
@@ -1523,7 +1523,7 @@ sort_buffer_size (FILE *const *fps, size_t nfps,
|
||||
: STREQ (files[i], "-") ? fstat (STDIN_FILENO, &st)
|
||||
: stat (files[i], &st))
|
||||
!= 0)
|
||||
die (_("stat failed"), files[i]);
|
||||
sort_die (_("stat failed"), files[i]);
|
||||
|
||||
if (S_ISREG (st.st_mode))
|
||||
file_size = st.st_size;
|
||||
@@ -1785,7 +1785,7 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file)
|
||||
if (bytes_read != readsize)
|
||||
{
|
||||
if (ferror (fp))
|
||||
die (_("read failed"), file);
|
||||
sort_die (_("read failed"), file);
|
||||
if (feof (fp))
|
||||
{
|
||||
buf->eof = true;
|
||||
@@ -2084,10 +2084,10 @@ random_md5_state_init (char const *random_source)
|
||||
unsigned char buf[MD5_DIGEST_SIZE];
|
||||
struct randread_source *r = randread_new (random_source, sizeof buf);
|
||||
if (! r)
|
||||
die (_("open failed"), random_source);
|
||||
sort_die (_("open failed"), random_source);
|
||||
randread (r, buf, sizeof buf);
|
||||
if (randread_free (r) != 0)
|
||||
die (_("close failed"), random_source);
|
||||
sort_die (_("close failed"), random_source);
|
||||
md5_init_ctx (&random_md5_state);
|
||||
md5_process_bytes (buf, sizeof buf, &random_md5_state);
|
||||
}
|
||||
@@ -2104,9 +2104,9 @@ xstrxfrm (char *restrict dest, char const *restrict src, size_t destsize)
|
||||
{
|
||||
error (0, errno, _("string transformation failed"));
|
||||
error (0, 0, _("set LC_ALL='C' to work around the problem"));
|
||||
error (SORT_FAILURE, 0,
|
||||
_("the untransformed string was %s"),
|
||||
quotearg_n_style (0, locale_quoting_style, src));
|
||||
die (SORT_FAILURE, 0,
|
||||
_("the untransformed string was %s"),
|
||||
quotearg_n_style (0, locale_quoting_style, src));
|
||||
}
|
||||
|
||||
return translated_size;
|
||||
@@ -2781,7 +2781,7 @@ write_line (struct line const *line, FILE *fp, char const *output_file)
|
||||
else if (c == ebuf)
|
||||
wc = '\n';
|
||||
if (fputc (wc, fp) == EOF)
|
||||
die (_("write failed"), output_file);
|
||||
sort_die (_("write failed"), output_file);
|
||||
}
|
||||
|
||||
debug_line (line);
|
||||
@@ -2790,7 +2790,7 @@ write_line (struct line const *line, FILE *fp, char const *output_file)
|
||||
{
|
||||
ebuf[-1] = eolchar;
|
||||
if (fwrite (buf, 1, n_bytes, fp) != n_bytes)
|
||||
die (_("write failed"), output_file);
|
||||
sort_die (_("write failed"), output_file);
|
||||
ebuf[-1] = '\0';
|
||||
}
|
||||
}
|
||||
@@ -3121,7 +3121,7 @@ mergefiles (struct sortfile *files, size_t ntemps, size_t nfiles,
|
||||
FILE **fps;
|
||||
size_t nopened = open_input_files (files, nfiles, &fps);
|
||||
if (nopened < nfiles && nopened < 2)
|
||||
die (_("open failed"), files[nopened].name);
|
||||
sort_die (_("open failed"), files[nopened].name);
|
||||
mergefps (files, ntemps, nopened, ofp, output_file, fps);
|
||||
return nopened;
|
||||
}
|
||||
@@ -3755,7 +3755,7 @@ check_inputs (char *const *files, size_t nfiles)
|
||||
continue;
|
||||
|
||||
if (euidaccess (files[i], R_OK) != 0)
|
||||
die (_("cannot read"), files[i]);
|
||||
sort_die (_("cannot read"), files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3770,7 +3770,7 @@ check_output (char const *outfile)
|
||||
{
|
||||
int outfd = open (outfile, O_WRONLY | O_CREAT | O_BINARY, MODE_RW_UGO);
|
||||
if (outfd < 0)
|
||||
die (_("open failed"), outfile);
|
||||
sort_die (_("open failed"), outfile);
|
||||
move_fd_or_die (outfd, STDOUT_FILENO);
|
||||
}
|
||||
}
|
||||
@@ -3861,10 +3861,10 @@ merge (struct sortfile *files, size_t ntemps, size_t nfiles,
|
||||
break;
|
||||
}
|
||||
if (errno != EMFILE || nopened <= 2)
|
||||
die (_("open failed"), output_file);
|
||||
sort_die (_("open failed"), output_file);
|
||||
}
|
||||
else if (nopened <= 2)
|
||||
die (_("open failed"), files[nopened].name);
|
||||
sort_die (_("open failed"), files[nopened].name);
|
||||
|
||||
/* We ran out of file descriptors. Close one of the input
|
||||
files, to gain a file descriptor. Then create a temporary
|
||||
@@ -4034,8 +4034,8 @@ static void badfieldspec (char const *, char const *)
|
||||
static void
|
||||
badfieldspec (char const *spec, char const *msgid)
|
||||
{
|
||||
error (SORT_FAILURE, 0, _("%s: invalid field specification %s"),
|
||||
_(msgid), quote (spec));
|
||||
die (SORT_FAILURE, 0, _("%s: invalid field specification %s"),
|
||||
_(msgid), quote (spec));
|
||||
abort ();
|
||||
}
|
||||
|
||||
@@ -4045,7 +4045,7 @@ static void incompatible_options (char const *) ATTRIBUTE_NORETURN;
|
||||
static void
|
||||
incompatible_options (char const *opts)
|
||||
{
|
||||
error (SORT_FAILURE, 0, _("options '-%s' are incompatible"), (opts));
|
||||
die (SORT_FAILURE, 0, _("options '-%s' are incompatible"), (opts));
|
||||
abort ();
|
||||
}
|
||||
|
||||
@@ -4096,8 +4096,8 @@ parse_field_count (char const *string, size_t *val, char const *msgid)
|
||||
|
||||
case LONGINT_INVALID:
|
||||
if (msgid)
|
||||
error (SORT_FAILURE, 0, _("%s: invalid count at start of %s"),
|
||||
_(msgid), quote (string));
|
||||
die (SORT_FAILURE, 0, _("%s: invalid count at start of %s"),
|
||||
_(msgid), quote (string));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -4422,7 +4422,7 @@ main (int argc, char **argv)
|
||||
|
||||
case COMPRESS_PROGRAM_OPTION:
|
||||
if (compress_program && !STREQ (compress_program, optarg))
|
||||
error (SORT_FAILURE, 0, _("multiple compress programs specified"));
|
||||
die (SORT_FAILURE, 0, _("multiple compress programs specified"));
|
||||
compress_program = optarg;
|
||||
break;
|
||||
|
||||
@@ -4495,13 +4495,13 @@ main (int argc, char **argv)
|
||||
|
||||
case 'o':
|
||||
if (outfile && !STREQ (outfile, optarg))
|
||||
error (SORT_FAILURE, 0, _("multiple output files specified"));
|
||||
die (SORT_FAILURE, 0, _("multiple output files specified"));
|
||||
outfile = optarg;
|
||||
break;
|
||||
|
||||
case RANDOM_SOURCE_OPTION:
|
||||
if (random_source && !STREQ (random_source, optarg))
|
||||
error (SORT_FAILURE, 0, _("multiple random sources specified"));
|
||||
die (SORT_FAILURE, 0, _("multiple random sources specified"));
|
||||
random_source = optarg;
|
||||
break;
|
||||
|
||||
@@ -4517,7 +4517,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
char newtab = optarg[0];
|
||||
if (! newtab)
|
||||
error (SORT_FAILURE, 0, _("empty tab"));
|
||||
die (SORT_FAILURE, 0, _("empty tab"));
|
||||
if (optarg[1])
|
||||
{
|
||||
if (STREQ (optarg, "\\0"))
|
||||
@@ -4528,12 +4528,12 @@ main (int argc, char **argv)
|
||||
"multi-character tab" instead of "multibyte tab", so
|
||||
that the diagnostic's wording does not need to be
|
||||
changed once multibyte characters are supported. */
|
||||
error (SORT_FAILURE, 0, _("multi-character tab %s"),
|
||||
quote (optarg));
|
||||
die (SORT_FAILURE, 0, _("multi-character tab %s"),
|
||||
quote (optarg));
|
||||
}
|
||||
}
|
||||
if (tab != TAB_DEFAULT && tab != newtab)
|
||||
error (SORT_FAILURE, 0, _("incompatible tabs"));
|
||||
die (SORT_FAILURE, 0, _("incompatible tabs"));
|
||||
tab = newtab;
|
||||
}
|
||||
break;
|
||||
@@ -4603,15 +4603,15 @@ main (int argc, char **argv)
|
||||
{
|
||||
stream = fopen (files_from, "r");
|
||||
if (stream == NULL)
|
||||
error (SORT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quoteaf (files_from));
|
||||
die (SORT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quoteaf (files_from));
|
||||
}
|
||||
|
||||
readtokens0_init (&tok);
|
||||
|
||||
if (! readtokens0 (stream, &tok) || fclose (stream) != 0)
|
||||
error (SORT_FAILURE, 0, _("cannot read file names from %s"),
|
||||
quoteaf (files_from));
|
||||
die (SORT_FAILURE, 0, _("cannot read file names from %s"),
|
||||
quoteaf (files_from));
|
||||
|
||||
if (tok.n_tok)
|
||||
{
|
||||
@@ -4622,24 +4622,24 @@ main (int argc, char **argv)
|
||||
for (i = 0; i < nfiles; i++)
|
||||
{
|
||||
if (STREQ (files[i], "-"))
|
||||
error (SORT_FAILURE, 0, _("when reading file names from stdin, "
|
||||
"no file name of %s allowed"),
|
||||
quoteaf (files[i]));
|
||||
die (SORT_FAILURE, 0, _("when reading file names from stdin, "
|
||||
"no file name of %s allowed"),
|
||||
quoteaf (files[i]));
|
||||
else if (files[i][0] == '\0')
|
||||
{
|
||||
/* Using the standard 'filename:line-number:' prefix here is
|
||||
not totally appropriate, since NUL is the separator,
|
||||
not NL, but it might be better than nothing. */
|
||||
unsigned long int file_number = i + 1;
|
||||
error (SORT_FAILURE, 0,
|
||||
_("%s:%lu: invalid zero-length file name"),
|
||||
quotef (files_from), file_number);
|
||||
die (SORT_FAILURE, 0,
|
||||
_("%s:%lu: invalid zero-length file name"),
|
||||
quotef (files_from), file_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
error (SORT_FAILURE, 0, _("no input from %s"),
|
||||
quoteaf (files_from));
|
||||
die (SORT_FAILURE, 0, _("no input from %s"),
|
||||
quoteaf (files_from));
|
||||
}
|
||||
|
||||
/* Inheritance of global options to individual keys. */
|
||||
@@ -4725,8 +4725,8 @@ main (int argc, char **argv)
|
||||
if (checkonly)
|
||||
{
|
||||
if (nfiles > 1)
|
||||
error (SORT_FAILURE, 0, _("extra operand %s not allowed with -%c"),
|
||||
quoteaf (files[1]), checkonly);
|
||||
die (SORT_FAILURE, 0, _("extra operand %s not allowed with -%c"),
|
||||
quoteaf (files[1]), checkonly);
|
||||
|
||||
if (outfile)
|
||||
{
|
||||
@@ -4780,7 +4780,7 @@ main (int argc, char **argv)
|
||||
#endif
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
die (_("close failed"), "-");
|
||||
sort_die (_("close failed"), "-");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+68
-67
@@ -29,6 +29,7 @@
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fd-reopen.h"
|
||||
#include "fcntl--.h"
|
||||
@@ -203,9 +204,9 @@ set_suffix_length (uintmax_t n_units, enum Split_type split_type)
|
||||
{
|
||||
if (suffix_length < suffix_needed)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("the suffix length needs to be at least %"PRIuMAX),
|
||||
suffix_needed);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("the suffix length needs to be at least %"PRIuMAX),
|
||||
suffix_needed);
|
||||
}
|
||||
suffix_auto = false;
|
||||
return;
|
||||
@@ -422,7 +423,7 @@ new_name:
|
||||
char *dir = dir_name (outfile);
|
||||
long name_max = pathconf (dir, _PC_NAME_MAX);
|
||||
if (0 <= name_max && name_max < base_len (last_component (outfile)))
|
||||
error (EXIT_FAILURE, ENAMETOOLONG, "%s", quotef (outfile));
|
||||
die (EXIT_FAILURE, ENAMETOOLONG, "%s", quotef (outfile));
|
||||
free (dir);
|
||||
}
|
||||
#endif
|
||||
@@ -443,7 +444,7 @@ new_name:
|
||||
sufindex[i] = 0;
|
||||
outfile_mid[i] = suffix_alphabet[sufindex[i]];
|
||||
}
|
||||
error (EXIT_FAILURE, 0, _("output file suffixes exhausted"));
|
||||
die (EXIT_FAILURE, 0, _("output file suffixes exhausted"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,12 +463,12 @@ create (const char *name)
|
||||
return fd;
|
||||
struct stat out_stat_buf;
|
||||
if (fstat (fd, &out_stat_buf) != 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to stat %s"), quoteaf (name));
|
||||
die (EXIT_FAILURE, errno, _("failed to stat %s"), quoteaf (name));
|
||||
if (SAME_INODE (in_stat_buf, out_stat_buf))
|
||||
error (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"),
|
||||
quoteaf (name));
|
||||
die (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"),
|
||||
quoteaf (name));
|
||||
if (ftruncate (fd, 0) != 0)
|
||||
error (EXIT_FAILURE, errno, _("%s: error truncating"), quotef (name));
|
||||
die (EXIT_FAILURE, errno, _("%s: error truncating"), quotef (name));
|
||||
|
||||
return fd;
|
||||
}
|
||||
@@ -479,12 +480,12 @@ create (const char *name)
|
||||
if (shell_prog == NULL)
|
||||
shell_prog = "/bin/sh";
|
||||
if (setenv ("FILE", name, 1) != 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("failed to set FILE environment variable"));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("failed to set FILE environment variable"));
|
||||
if (verbose)
|
||||
fprintf (stdout, _("executing with FILE=%s\n"), quotef (name));
|
||||
if (pipe (fd_pair) != 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to create pipe"));
|
||||
die (EXIT_FAILURE, errno, _("failed to create pipe"));
|
||||
child_pid = fork ();
|
||||
if (child_pid == 0)
|
||||
{
|
||||
@@ -498,26 +499,26 @@ create (const char *name)
|
||||
reading an EOF on the corresponding read-pipe. */
|
||||
for (j = 0; j < n_open_pipes; ++j)
|
||||
if (close (open_pipes[j]) != 0)
|
||||
error (EXIT_FAILURE, errno, _("closing prior pipe"));
|
||||
die (EXIT_FAILURE, errno, _("closing prior pipe"));
|
||||
if (close (fd_pair[1]))
|
||||
error (EXIT_FAILURE, errno, _("closing output pipe"));
|
||||
die (EXIT_FAILURE, errno, _("closing output pipe"));
|
||||
if (fd_pair[0] != STDIN_FILENO)
|
||||
{
|
||||
if (dup2 (fd_pair[0], STDIN_FILENO) != STDIN_FILENO)
|
||||
error (EXIT_FAILURE, errno, _("moving input pipe"));
|
||||
die (EXIT_FAILURE, errno, _("moving input pipe"));
|
||||
if (close (fd_pair[0]) != 0)
|
||||
error (EXIT_FAILURE, errno, _("closing input pipe"));
|
||||
die (EXIT_FAILURE, errno, _("closing input pipe"));
|
||||
}
|
||||
sigprocmask (SIG_SETMASK, &oldblocked, NULL);
|
||||
execl (shell_prog, last_component (shell_prog), "-c",
|
||||
filter_command, (char *) NULL);
|
||||
error (EXIT_FAILURE, errno, _("failed to run command: \"%s -c %s\""),
|
||||
shell_prog, filter_command);
|
||||
die (EXIT_FAILURE, errno, _("failed to run command: \"%s -c %s\""),
|
||||
shell_prog, filter_command);
|
||||
}
|
||||
if (child_pid == -1)
|
||||
error (EXIT_FAILURE, errno, _("fork system call failed"));
|
||||
die (EXIT_FAILURE, errno, _("fork system call failed"));
|
||||
if (close (fd_pair[0]) != 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to close input pipe"));
|
||||
die (EXIT_FAILURE, errno, _("failed to close input pipe"));
|
||||
filter_pid = child_pid;
|
||||
if (n_open_pipes == open_pipes_alloc)
|
||||
open_pipes = x2nrealloc (open_pipes, &open_pipes_alloc,
|
||||
@@ -534,11 +535,11 @@ static void
|
||||
closeout (FILE *fp, int fd, pid_t pid, char const *name)
|
||||
{
|
||||
if (fp != NULL && fclose (fp) != 0 && ! ignorable (errno))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (name));
|
||||
if (fd >= 0)
|
||||
{
|
||||
if (fp == NULL && close (fd) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (name));
|
||||
int j;
|
||||
for (j = 0; j < n_open_pipes; ++j)
|
||||
{
|
||||
@@ -553,7 +554,7 @@ closeout (FILE *fp, int fd, pid_t pid, char const *name)
|
||||
{
|
||||
int wstatus = 0;
|
||||
if (waitpid (pid, &wstatus, 0) == -1 && errno != ECHILD)
|
||||
error (EXIT_FAILURE, errno, _("waiting for child process"));
|
||||
die (EXIT_FAILURE, errno, _("waiting for child process"));
|
||||
if (WIFSIGNALED (wstatus))
|
||||
{
|
||||
int sig = WTERMSIG (wstatus);
|
||||
@@ -577,8 +578,8 @@ closeout (FILE *fp, int fd, pid_t pid, char const *name)
|
||||
else
|
||||
{
|
||||
/* shouldn't happen. */
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("unknown status from command (0x%X)"), wstatus + 0u);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("unknown status from command (0x%X)"), wstatus + 0u);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -599,7 +600,7 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
|
||||
next_file_name ();
|
||||
output_desc = create (outfile);
|
||||
if (output_desc < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (outfile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (outfile));
|
||||
}
|
||||
|
||||
if (full_write (output_desc, bp, bytes) == bytes)
|
||||
@@ -607,7 +608,7 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
|
||||
else
|
||||
{
|
||||
if (! ignorable (errno))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (outfile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (outfile));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -638,7 +639,7 @@ bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize, size_t initial_read,
|
||||
{
|
||||
n_read = safe_read (STDIN_FILENO, buf, bufsize);
|
||||
if (n_read == SAFE_READ_ERROR)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
eof = n_read == 0;
|
||||
}
|
||||
char *bp_out = buf;
|
||||
@@ -697,7 +698,7 @@ lines_split (uintmax_t n_lines, char *buf, size_t bufsize)
|
||||
{
|
||||
n_read = safe_read (STDIN_FILENO, buf, bufsize);
|
||||
if (n_read == SAFE_READ_ERROR)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
bp = bp_out = buf;
|
||||
eob = bp + n_read;
|
||||
*eob = eolchar;
|
||||
@@ -746,7 +747,7 @@ line_bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize)
|
||||
{
|
||||
n_read = safe_read (STDIN_FILENO, buf, bufsize);
|
||||
if (n_read == SAFE_READ_ERROR)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
size_t n_left = n_read;
|
||||
char *sob = buf;
|
||||
while (n_left)
|
||||
@@ -871,7 +872,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
else
|
||||
{
|
||||
if (lseek (STDIN_FILENO, start - initial_read, SEEK_CUR) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
initial_read = SIZE_MAX;
|
||||
}
|
||||
n_written = start;
|
||||
@@ -892,7 +893,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
{
|
||||
n_read = safe_read (STDIN_FILENO, buf, bufsize);
|
||||
if (n_read == SAFE_READ_ERROR)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
}
|
||||
if (n_read == 0)
|
||||
break; /* eof. */
|
||||
@@ -920,7 +921,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
large chunks from an existing file, so it's more efficient
|
||||
to write out directly. */
|
||||
if (full_write (STDOUT_FILENO, bp, to_write) != to_write)
|
||||
error (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
die (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
}
|
||||
else if (! k)
|
||||
cwrite (new_file_flag, bp, to_write);
|
||||
@@ -989,7 +990,7 @@ bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
else
|
||||
{
|
||||
if (lseek (STDIN_FILENO, start, SEEK_CUR) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
initial_read = SIZE_MAX;
|
||||
}
|
||||
|
||||
@@ -1005,14 +1006,14 @@ bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
{
|
||||
n_read = safe_read (STDIN_FILENO, buf, bufsize);
|
||||
if (n_read == SAFE_READ_ERROR)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
}
|
||||
if (n_read == 0)
|
||||
break; /* eof. */
|
||||
n_read = MIN (n_read, end - start);
|
||||
if (full_write (STDOUT_FILENO, buf, n_read) != n_read
|
||||
&& ! ignorable (errno))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef ("-"));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef ("-"));
|
||||
start += n_read;
|
||||
}
|
||||
}
|
||||
@@ -1077,7 +1078,7 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
|
||||
break;
|
||||
|
||||
if (!(errno == EMFILE || errno == ENFILE))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (files[i_check].of_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (files[i_check].of_name));
|
||||
|
||||
file_limit = true;
|
||||
|
||||
@@ -1087,19 +1088,19 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
|
||||
i_reopen = i_reopen ? i_reopen - 1 : nfiles - 1;
|
||||
/* No more open files to close, exit with E[NM]FILE. */
|
||||
if (i_reopen == i_check)
|
||||
error (EXIT_FAILURE, errno, "%s",
|
||||
quotef (files[i_check].of_name));
|
||||
die (EXIT_FAILURE, errno, "%s",
|
||||
quotef (files[i_check].of_name));
|
||||
}
|
||||
|
||||
if (fclose (files[i_reopen].ofile) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (files[i_reopen].of_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (files[i_reopen].of_name));
|
||||
files[i_reopen].ofile = NULL;
|
||||
files[i_reopen].ofd = OFD_APPEND;
|
||||
}
|
||||
|
||||
files[i_check].ofd = fd;
|
||||
if (!(files[i_check].ofile = fdopen (fd, "a")))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (files[i_check].of_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (files[i_check].of_name));
|
||||
files[i_check].opid = filter_pid;
|
||||
filter_pid = 0;
|
||||
}
|
||||
@@ -1148,7 +1149,7 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
|
||||
char *bp = buf, *eob;
|
||||
size_t n_read = safe_read (STDIN_FILENO, buf, bufsize);
|
||||
if (n_read == SAFE_READ_ERROR)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
else if (n_read == 0)
|
||||
break; /* eof. */
|
||||
eob = buf + n_read;
|
||||
@@ -1174,12 +1175,12 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
|
||||
if (line_no == k && unbuffered)
|
||||
{
|
||||
if (full_write (STDOUT_FILENO, bp, to_write) != to_write)
|
||||
error (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
die (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
}
|
||||
else if (line_no == k && fwrite (bp, to_write, 1, stdout) != 1)
|
||||
{
|
||||
clearerr (stdout); /* To silence close_stdout(). */
|
||||
error (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
die (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
}
|
||||
if (next)
|
||||
line_no = (line_no == n) ? 1 : line_no + 1;
|
||||
@@ -1195,15 +1196,15 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
|
||||
if (full_write (files[i_file].ofd, bp, to_write) != to_write
|
||||
&& ! ignorable (errno))
|
||||
{
|
||||
error (EXIT_FAILURE, errno, "%s",
|
||||
quotef (files[i_file].of_name));
|
||||
die (EXIT_FAILURE, errno, "%s",
|
||||
quotef (files[i_file].of_name));
|
||||
}
|
||||
}
|
||||
else if (fwrite (bp, to_write, 1, files[i_file].ofile) != 1
|
||||
&& ! ignorable (errno))
|
||||
{
|
||||
error (EXIT_FAILURE, errno, "%s",
|
||||
quotef (files[i_file].of_name));
|
||||
die (EXIT_FAILURE, errno, "%s",
|
||||
quotef (files[i_file].of_name));
|
||||
}
|
||||
|
||||
if (! ignorable (errno))
|
||||
@@ -1213,8 +1214,8 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
|
||||
{
|
||||
if (fclose (files[i_file].ofile) != 0)
|
||||
{
|
||||
error (EXIT_FAILURE, errno, "%s",
|
||||
quotef (files[i_file].of_name));
|
||||
die (EXIT_FAILURE, errno, "%s",
|
||||
quotef (files[i_file].of_name));
|
||||
}
|
||||
files[i_file].ofile = NULL;
|
||||
files[i_file].ofd = OFD_APPEND;
|
||||
@@ -1396,7 +1397,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
char neweol = optarg[0];
|
||||
if (! neweol)
|
||||
error (EXIT_FAILURE, 0, _("empty record separator"));
|
||||
die (EXIT_FAILURE, 0, _("empty record separator"));
|
||||
if (optarg[1])
|
||||
{
|
||||
if (STREQ (optarg, "\\0"))
|
||||
@@ -1407,15 +1408,15 @@ main (int argc, char **argv)
|
||||
"multi-character tab" instead of "multibyte tab", so
|
||||
that the diagnostic's wording does not need to be
|
||||
changed once multibyte characters are supported. */
|
||||
error (EXIT_FAILURE, 0, _("multi-character separator %s"),
|
||||
quote (optarg));
|
||||
die (EXIT_FAILURE, 0, _("multi-character separator %s"),
|
||||
quote (optarg));
|
||||
}
|
||||
}
|
||||
/* Make it explicit we don't support multiple separators. */
|
||||
if (0 <= eolchar && neweol != eolchar)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("multiple separator characters specified"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("multiple separator characters specified"));
|
||||
}
|
||||
|
||||
eolchar = neweol;
|
||||
@@ -1445,9 +1446,9 @@ main (int argc, char **argv)
|
||||
if (!DECIMAL_DIGIT_ACCUMULATE (n_units, c - '0', uintmax_t))
|
||||
{
|
||||
char buffer[INT_BUFSIZE_BOUND (uintmax_t)];
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("line count option -%s%c... is too large"),
|
||||
umaxtostr (n_units, buffer), c);
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("line count option -%s%c... is too large"),
|
||||
umaxtostr (n_units, buffer), c);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1548,8 +1549,8 @@ main (int argc, char **argv)
|
||||
/* Open the input file. */
|
||||
if (! STREQ (infile, "-")
|
||||
&& fd_reopen (STDIN_FILENO, infile, O_RDONLY, 0) < 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quoteaf (infile));
|
||||
die (EXIT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quoteaf (infile));
|
||||
|
||||
/* Binary I/O is safer when byte counts are used. */
|
||||
if (O_BINARY && ! isatty (STDIN_FILENO))
|
||||
@@ -1558,7 +1559,7 @@ main (int argc, char **argv)
|
||||
/* Get the optimal block size of input device and make a buffer. */
|
||||
|
||||
if (fstat (STDIN_FILENO, &in_stat_buf) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
|
||||
bool specified_buf_size = !! in_blk_size;
|
||||
if (! specified_buf_size)
|
||||
@@ -1573,16 +1574,16 @@ main (int argc, char **argv)
|
||||
file_size = input_file_size (STDIN_FILENO, &in_stat_buf,
|
||||
buf, in_blk_size);
|
||||
if (file_size < 0)
|
||||
error (EXIT_FAILURE, errno, _("%s: cannot determine file size"),
|
||||
quotef (infile));
|
||||
die (EXIT_FAILURE, errno, _("%s: cannot determine file size"),
|
||||
quotef (infile));
|
||||
initial_read = MIN (file_size, in_blk_size);
|
||||
/* Overflow, and sanity checking. */
|
||||
if (OFF_T_MAX < n_units)
|
||||
{
|
||||
char buffer[INT_BUFSIZE_BOUND (uintmax_t)];
|
||||
error (EXIT_FAILURE, EOVERFLOW, "%s: %s",
|
||||
_("invalid number of chunks"),
|
||||
quote (umaxtostr (n_units, buffer)));
|
||||
die (EXIT_FAILURE, EOVERFLOW, "%s: %s",
|
||||
_("invalid number of chunks"),
|
||||
quote (umaxtostr (n_units, buffer)));
|
||||
}
|
||||
/* increase file_size to n_units here, so that we still process
|
||||
any input data, and create empty files for the rest. */
|
||||
@@ -1643,7 +1644,7 @@ main (int argc, char **argv)
|
||||
IF_LINT (free (b));
|
||||
|
||||
if (close (STDIN_FILENO) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
closeout (NULL, output_desc, filter_pid, outfile);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
+3
-2
@@ -59,6 +59,7 @@
|
||||
#include "system.h"
|
||||
|
||||
#include "areadlink.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "file-type.h"
|
||||
#include "filemode.h"
|
||||
@@ -1219,8 +1220,8 @@ print_it (char const *format, int fd, char const *filename,
|
||||
{
|
||||
dest[len + 1] = *fmt_char;
|
||||
dest[len + 2] = '\0';
|
||||
error (EXIT_FAILURE, 0, _("%s: invalid directive"),
|
||||
quote (dest));
|
||||
die (EXIT_FAILURE, 0, _("%s: invalid directive"),
|
||||
quote (dest));
|
||||
}
|
||||
putchar ('%');
|
||||
break;
|
||||
|
||||
+9
-8
@@ -23,6 +23,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "filenamecat.h"
|
||||
#include "quote.h"
|
||||
@@ -238,7 +239,7 @@ set_LD_PRELOAD (void)
|
||||
|
||||
++path;
|
||||
if ( ! *path)
|
||||
error (EXIT_CANCELED, 0, _("failed to find %s"), quote (LIB_NAME));
|
||||
die (EXIT_CANCELED, 0, _("failed to find %s"), quote (LIB_NAME));
|
||||
}
|
||||
|
||||
/* FIXME: Do we need to support libstdbuf.dll, c:, '\' separators etc? */
|
||||
@@ -261,9 +262,9 @@ set_LD_PRELOAD (void)
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
error (EXIT_CANCELED, errno,
|
||||
_("failed to update the environment with %s"),
|
||||
quote (LD_PRELOAD));
|
||||
die (EXIT_CANCELED, errno,
|
||||
_("failed to update the environment with %s"),
|
||||
quote (LD_PRELOAD));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,9 +296,9 @@ set_libstdbuf_options (void)
|
||||
|
||||
if (putenv (var) != 0)
|
||||
{
|
||||
error (EXIT_CANCELED, errno,
|
||||
_("failed to update the environment with %s"),
|
||||
quote (var));
|
||||
die (EXIT_CANCELED, errno,
|
||||
_("failed to update the environment with %s"),
|
||||
quote (var));
|
||||
}
|
||||
|
||||
env_set = true;
|
||||
@@ -348,7 +349,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (!STREQ (optarg, "L")
|
||||
&& parse_size (optarg, &stdbuf[opt_fileno].size) == -1)
|
||||
error (EXIT_CANCELED, errno, _("invalid mode %s"), quote (optarg));
|
||||
die (EXIT_CANCELED, errno, _("invalid mode %s"), quote (optarg));
|
||||
|
||||
break;
|
||||
|
||||
|
||||
+26
-25
@@ -55,6 +55,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fd-reopen.h"
|
||||
#include "quote.h"
|
||||
@@ -1136,7 +1137,7 @@ main (int argc, char **argv)
|
||||
|
||||
case 'F':
|
||||
if (file_name)
|
||||
error (EXIT_FAILURE, 0, _("only one device may be specified"));
|
||||
die (EXIT_FAILURE, 0, _("only one device may be specified"));
|
||||
file_name = optarg;
|
||||
break;
|
||||
|
||||
@@ -1169,14 +1170,14 @@ main (int argc, char **argv)
|
||||
|
||||
/* Specifying both -a and -g gets an error. */
|
||||
if (verbose_output && recoverable_output)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("the options for verbose and stty-readable output styles are\n"
|
||||
"mutually exclusive"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("the options for verbose and stty-readable output styles are\n"
|
||||
"mutually exclusive"));
|
||||
|
||||
/* Specifying any other arguments with -a or -g gets an error. */
|
||||
if (!noargs && (verbose_output || recoverable_output))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("when specifying an output style, modes may not be set"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("when specifying an output style, modes may not be set"));
|
||||
|
||||
/* FIXME: it'd be better not to open the file until we've verified
|
||||
that all arguments are valid. Otherwise, we could end up doing
|
||||
@@ -1188,17 +1189,17 @@ main (int argc, char **argv)
|
||||
int fdflags;
|
||||
device_name = file_name;
|
||||
if (fd_reopen (STDIN_FILENO, device_name, O_RDONLY | O_NONBLOCK, 0) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
if ((fdflags = fcntl (STDIN_FILENO, F_GETFL)) == -1
|
||||
|| fcntl (STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
|
||||
error (EXIT_FAILURE, errno, _("%s: couldn't reset non-blocking mode"),
|
||||
quotef (device_name));
|
||||
die (EXIT_FAILURE, errno, _("%s: couldn't reset non-blocking mode"),
|
||||
quotef (device_name));
|
||||
}
|
||||
else
|
||||
device_name = _("standard input");
|
||||
|
||||
if (tcgetattr (STDIN_FILENO, &mode))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
|
||||
if (verbose_output || recoverable_output || noargs)
|
||||
{
|
||||
@@ -1304,8 +1305,8 @@ main (int argc, char **argv)
|
||||
|
||||
if (ioctl (STDIN_FILENO, TIOCEXT, &val) != 0)
|
||||
{
|
||||
error (EXIT_FAILURE, errno, _("%s: error setting %s"),
|
||||
quotef_n (0, device_name), quote_n (1, arg));
|
||||
die (EXIT_FAILURE, errno, _("%s: error setting %s"),
|
||||
quotef_n (0, device_name), quote_n (1, arg));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1386,7 +1387,7 @@ main (int argc, char **argv)
|
||||
static struct termios new_mode;
|
||||
|
||||
if (tcsetattr (STDIN_FILENO, tcsetattr_options, &mode))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
|
||||
/* POSIX (according to Zlotnick's book) tcsetattr returns zero if
|
||||
it performs *any* of the requested operations. This means it
|
||||
@@ -1396,7 +1397,7 @@ main (int argc, char **argv)
|
||||
compare them to the requested ones. */
|
||||
|
||||
if (tcgetattr (STDIN_FILENO, &new_mode))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
|
||||
/* Normally, one shouldn't use memcmp to compare structures that
|
||||
may have 'holes' containing uninitialized data, but we have been
|
||||
@@ -1421,9 +1422,9 @@ main (int argc, char **argv)
|
||||
if (speed_was_set || memcmp (&mode, &new_mode, sizeof (mode)) != 0)
|
||||
#endif
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s: unable to perform all requested operations"),
|
||||
quotef (device_name));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("%s: unable to perform all requested operations"),
|
||||
quotef (device_name));
|
||||
#ifdef TESTING
|
||||
{
|
||||
size_t i;
|
||||
@@ -1703,7 +1704,7 @@ set_window_size (int rows, int cols, char const *device_name)
|
||||
if (get_win_size (STDIN_FILENO, &win))
|
||||
{
|
||||
if (errno != EINVAL)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
memset (&win, 0, sizeof (win));
|
||||
}
|
||||
|
||||
@@ -1745,16 +1746,16 @@ set_window_size (int rows, int cols, char const *device_name)
|
||||
win.ws_col = 1;
|
||||
|
||||
if (ioctl (STDIN_FILENO, TIOCSWINSZ, (char *) &win))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
|
||||
if (ioctl (STDIN_FILENO, TIOCSSIZE, (char *) &ttysz))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
||||
if (ioctl (STDIN_FILENO, TIOCSWINSZ, (char *) &win))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1765,11 +1766,11 @@ display_window_size (bool fancy, char const *device_name)
|
||||
if (get_win_size (STDIN_FILENO, &win))
|
||||
{
|
||||
if (errno != EINVAL)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (device_name));
|
||||
if (!fancy)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s: no size information for this device"),
|
||||
quotef (device_name));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("%s: no size information for this device"),
|
||||
quotef (device_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "human.h"
|
||||
@@ -270,6 +271,6 @@ main (int argc, char **argv)
|
||||
ok &= sum_func (argv[optind], files_given);
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef ("-"));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef ("-"));
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
+4
-3
@@ -23,6 +23,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no 'g' prefix). */
|
||||
@@ -208,12 +209,12 @@ main (int argc, char **argv)
|
||||
|
||||
if (arg_data && arg_file_system)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot specify both --data and --file-system"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("cannot specify both --data and --file-system"));
|
||||
}
|
||||
|
||||
if (!args_specified && arg_data)
|
||||
error (EXIT_FAILURE, 0, _("--data needs at least one argument"));
|
||||
die (EXIT_FAILURE, 0, _("--data needs at least one argument"));
|
||||
|
||||
if (! args_specified || (arg_file_system && ! HAVE_SYNCFS))
|
||||
mode = MODE_SYNC;
|
||||
|
||||
+3
-1
@@ -18,6 +18,8 @@
|
||||
/* FIXME */
|
||||
#include <assert.h>
|
||||
|
||||
#include "die.h"
|
||||
|
||||
/* FIXME: this is small for testing */
|
||||
#define BUFFER_SIZE (8)
|
||||
|
||||
@@ -71,7 +73,7 @@ buf_init_from_stdin (Buf *x, char eol_byte)
|
||||
}
|
||||
bytes_read = full_read (STDIN_FILENO, buf, BUFFER_SIZE);
|
||||
if (bytes_read != buffer_size && errno != 0)
|
||||
error (EXIT_FAILURE, errno, _("read error"));
|
||||
die (EXIT_FAILURE, errno, _("read error"));
|
||||
|
||||
{
|
||||
struct B_pair bp;
|
||||
|
||||
@@ -43,6 +43,7 @@ tac -r -s '.\|
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "filenamecat.h"
|
||||
#include "safe-read.h"
|
||||
@@ -272,7 +273,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos)
|
||||
regoff_t ret;
|
||||
|
||||
if (1 < range)
|
||||
error (EXIT_FAILURE, 0, _("record too large"));
|
||||
die (EXIT_FAILURE, 0, _("record too large"));
|
||||
|
||||
if (range == 1
|
||||
|| ((ret = re_search (&compiled_separator, G_buffer,
|
||||
@@ -281,8 +282,8 @@ tac_seekable (int input_fd, const char *file, off_t file_pos)
|
||||
match_start = G_buffer - 1;
|
||||
else if (ret == -2)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("error in regular expression search"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("error in regular expression search"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -650,7 +651,7 @@ main (int argc, char **argv)
|
||||
if (sentinel_length == 0)
|
||||
{
|
||||
if (*separator == 0)
|
||||
error (EXIT_FAILURE, 0, _("separator cannot be empty"));
|
||||
die (EXIT_FAILURE, 0, _("separator cannot be empty"));
|
||||
|
||||
compiled_separator.buffer = NULL;
|
||||
compiled_separator.allocated = 0;
|
||||
@@ -659,7 +660,7 @@ main (int argc, char **argv)
|
||||
error_message = re_compile_pattern (separator, strlen (separator),
|
||||
&compiled_separator);
|
||||
if (error_message)
|
||||
error (EXIT_FAILURE, 0, "%s", (error_message));
|
||||
die (EXIT_FAILURE, 0, "%s", (error_message));
|
||||
}
|
||||
else
|
||||
match_length = sentinel_length = *separator ? strlen (separator) : 1;
|
||||
|
||||
+19
-19
@@ -388,8 +388,8 @@ xwrite_stdout (char const *buffer, size_t n_bytes)
|
||||
if (n_bytes > 0 && fwrite (buffer, 1, n_bytes, stdout) < n_bytes)
|
||||
{
|
||||
clearerr (stdout); /* To avoid redundant close_stdout diagnostic. */
|
||||
error (EXIT_FAILURE, errno, _("error writing %s"),
|
||||
quoteaf ("standard output"));
|
||||
die (EXIT_FAILURE, errno, _("error writing %s"),
|
||||
quoteaf ("standard output"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,8 +413,8 @@ dump_remainder (const char *pretty_filename, int fd, uintmax_t n_bytes)
|
||||
if (bytes_read == SAFE_READ_ERROR)
|
||||
{
|
||||
if (errno != EAGAIN)
|
||||
error (EXIT_FAILURE, errno, _("error reading %s"),
|
||||
quoteaf (pretty_filename));
|
||||
die (EXIT_FAILURE, errno, _("error reading %s"),
|
||||
quoteaf (pretty_filename));
|
||||
break;
|
||||
}
|
||||
if (bytes_read == 0)
|
||||
@@ -1158,9 +1158,9 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval)
|
||||
the append-only attribute. */
|
||||
}
|
||||
else
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("%s: cannot change nonblocking mode"),
|
||||
quotef (name));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("%s: cannot change nonblocking mode"),
|
||||
quotef (name));
|
||||
}
|
||||
else
|
||||
f[i].blocking = blocking;
|
||||
@@ -1234,7 +1234,7 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval)
|
||||
}
|
||||
|
||||
if ((!any_input || blocking) && fflush (stdout) != 0)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
/* If nothing was read, sleep and/or check for dead writers. */
|
||||
if (!any_input)
|
||||
@@ -1252,7 +1252,7 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval)
|
||||
&& errno != EPERM);
|
||||
|
||||
if (!writer_is_dead && xnanosleep (sleep_interval))
|
||||
error (EXIT_FAILURE, errno, _("cannot read realtime clock"));
|
||||
die (EXIT_FAILURE, errno, _("cannot read realtime clock"));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1380,7 +1380,7 @@ check_fspec (struct File_spec *fspec, struct File_spec **prev_fspec)
|
||||
fspec->size += bytes_read;
|
||||
|
||||
if (fflush (stdout) != 0)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
|
||||
/* Attempt to tail N_FILES files forever, or until killed.
|
||||
@@ -1592,7 +1592,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
|
||||
if (file_change == 0)
|
||||
continue;
|
||||
else if (file_change == -1)
|
||||
error (EXIT_FAILURE, errno, _("error monitoring inotify event"));
|
||||
die (EXIT_FAILURE, errno, _("error monitoring inotify event"));
|
||||
}
|
||||
|
||||
if (len <= evbuf_off)
|
||||
@@ -1612,7 +1612,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
|
||||
}
|
||||
|
||||
if (len == 0 || len == SAFE_READ_ERROR)
|
||||
error (EXIT_FAILURE, errno, _("error reading inotify event"));
|
||||
die (EXIT_FAILURE, errno, _("error reading inotify event"));
|
||||
}
|
||||
|
||||
void_ev = evbuf + evbuf_off;
|
||||
@@ -2056,8 +2056,8 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units)
|
||||
& ~LONGINT_INVALID_SUFFIX_CHAR)
|
||||
!= LONGINT_OK)
|
||||
{
|
||||
error (EXIT_FAILURE, errno, "%s: %s", _("invalid number"),
|
||||
quote (argv[1]));
|
||||
die (EXIT_FAILURE, errno, "%s: %s", _("invalid number"),
|
||||
quote (argv[1]));
|
||||
}
|
||||
|
||||
/* Set globals. */
|
||||
@@ -2142,8 +2142,8 @@ parse_options (int argc, char **argv,
|
||||
{
|
||||
double s;
|
||||
if (! (xstrtod (optarg, NULL, &s, c_strtod) && 0 <= s))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid number of seconds: %s"), quote (optarg));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid number of seconds: %s"), quote (optarg));
|
||||
*sleep_interval = s;
|
||||
}
|
||||
break;
|
||||
@@ -2290,7 +2290,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* When following by name, there must be a name. */
|
||||
if (found_hyphen && follow_mode == Follow_name)
|
||||
error (EXIT_FAILURE, 0, _("cannot follow %s by name"), quoteaf ("-"));
|
||||
die (EXIT_FAILURE, 0, _("cannot follow %s by name"), quoteaf ("-"));
|
||||
|
||||
/* When following forever, warn if any file is '-'.
|
||||
This is only a warning, since tail's output (before a failing seek,
|
||||
@@ -2378,7 +2378,7 @@ main (int argc, char **argv)
|
||||
tail_forever_inotify flushes only after writing,
|
||||
not before reading. */
|
||||
if (fflush (stdout) != 0)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
if (! tail_forever_inotify (wd, F, n_files, sleep_interval))
|
||||
return EXIT_FAILURE;
|
||||
@@ -2406,6 +2406,6 @@ main (int argc, char **argv)
|
||||
IF_LINT (free (F));
|
||||
|
||||
if (have_read_stdin && close (STDIN_FILENO) < 0)
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
die (EXIT_FAILURE, errno, "-");
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "argmatch.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "stdio--.h"
|
||||
@@ -170,7 +171,7 @@ main (int argc, char **argv)
|
||||
|
||||
ok = tee_files (argc - optind, &argv[optind]);
|
||||
if (close (STDIN_FILENO) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", _("standard input"));
|
||||
die (EXIT_FAILURE, errno, "%s", _("standard input"));
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
+6
-5
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "argmatch.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fd-reopen.h"
|
||||
#include "parse-datetime.h"
|
||||
@@ -112,7 +113,7 @@ get_reldate (struct timespec *result,
|
||||
char const *flex_date, struct timespec const *now)
|
||||
{
|
||||
if (! parse_datetime (result, flex_date, now))
|
||||
error (EXIT_FAILURE, 0, _("invalid date format %s"), quote (flex_date));
|
||||
die (EXIT_FAILURE, 0, _("invalid date format %s"), quote (flex_date));
|
||||
}
|
||||
|
||||
/* Update the time of file FILE according to the options given.
|
||||
@@ -306,8 +307,8 @@ main (int argc, char **argv)
|
||||
case 't':
|
||||
if (! posixtime (&newtime[0].tv_sec, optarg,
|
||||
PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS))
|
||||
error (EXIT_FAILURE, 0, _("invalid date format %s"),
|
||||
quote (optarg));
|
||||
die (EXIT_FAILURE, 0, _("invalid date format %s"),
|
||||
quote (optarg));
|
||||
newtime[0].tv_nsec = 0;
|
||||
newtime[1] = newtime[0];
|
||||
date_set = true;
|
||||
@@ -343,8 +344,8 @@ main (int argc, char **argv)
|
||||
might be an object-like macro. */
|
||||
if (no_dereference ? lstat (ref_file, &ref_stats)
|
||||
: stat (ref_file, &ref_stats))
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("failed to get attributes of %s"), quoteaf (ref_file));
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("failed to get attributes of %s"), quoteaf (ref_file));
|
||||
newtime[0] = get_stat_atime (&ref_stats);
|
||||
newtime[1] = get_stat_mtime (&ref_stats);
|
||||
date_set = true;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "quote.h"
|
||||
@@ -1203,8 +1204,8 @@ validate_case_classes (struct Spec_list *s1, struct Spec_list *s2)
|
||||
c1 must also transition at the same time. */
|
||||
if (s2_new_element && class_s2 != UL_NONE
|
||||
&& !(s1_new_element && class_s1 != UL_NONE))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("misaligned [:upper:] and/or [:lower:] construct"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("misaligned [:upper:] and/or [:lower:] construct"));
|
||||
|
||||
/* If case converting, quickly skip over the elements. */
|
||||
if (class_s2 != UL_NONE)
|
||||
@@ -1309,7 +1310,7 @@ get_spec_stats (struct Spec_list *s)
|
||||
indefinite element. */
|
||||
new_length = length + len;
|
||||
if (! (length <= new_length && new_length <= REPEAT_COUNT_MAXIMUM))
|
||||
error (EXIT_FAILURE, 0, _("too many characters in set"));
|
||||
die (EXIT_FAILURE, 0, _("too many characters in set"));
|
||||
length = new_length;
|
||||
}
|
||||
|
||||
@@ -1392,8 +1393,8 @@ string2_extend (const struct Spec_list *s1, struct Spec_list *s2)
|
||||
tr '[:upper:]0-9' '[:lower:]'
|
||||
That's not portable however, contradicts POSIX and is dependent
|
||||
on your collating sequence. */
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("when translating with string1 longer than string2,\nthe\
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("when translating with string1 longer than string2,\nthe\
|
||||
latter string must not end with a character class"));
|
||||
abort (); /* inform gcc that the above use of error never returns. */
|
||||
break;
|
||||
@@ -1452,8 +1453,8 @@ validate (struct Spec_list *s1, struct Spec_list *s2)
|
||||
get_s1_spec_stats (s1);
|
||||
if (s1->n_indefinite_repeats > 0)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("the [c*] repeat construct may not appear in string1"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("the [c*] repeat construct may not appear in string1"));
|
||||
}
|
||||
|
||||
if (s2)
|
||||
@@ -1462,23 +1463,23 @@ validate (struct Spec_list *s1, struct Spec_list *s2)
|
||||
|
||||
if (s2->n_indefinite_repeats > 1)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("only one [c*] repeat construct may appear in string2"));
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("only one [c*] repeat construct may appear in string2"));
|
||||
}
|
||||
|
||||
if (translating)
|
||||
{
|
||||
if (s2->has_equiv_class)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("[=c=] expressions may not appear in string2\
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("[=c=] expressions may not appear in string2\
|
||||
when translating"));
|
||||
}
|
||||
|
||||
if (s2->has_restricted_char_class)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("when translating, the only character classes that may\
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("when translating, the only character classes that may\
|
||||
appear in\nstring2 are 'upper' and 'lower'"));
|
||||
}
|
||||
|
||||
@@ -1492,7 +1493,7 @@ validate (struct Spec_list *s1, struct Spec_list *s2)
|
||||
given or string1 is empty. */
|
||||
|
||||
if (s2->length == 0)
|
||||
error (EXIT_FAILURE, 0,
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("when not truncating set1, string2 must be non-empty"));
|
||||
string2_extend (s1, s2);
|
||||
}
|
||||
@@ -1501,8 +1502,8 @@ validate (struct Spec_list *s1, struct Spec_list *s2)
|
||||
if (complement && s1->has_char_class
|
||||
&& ! (s2->length == s1->length && homogeneous_spec_list (s2)))
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("when translating with complemented character classes,\
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("when translating with complemented character classes,\
|
||||
\nstring2 must map all characters in the domain to one"));
|
||||
}
|
||||
}
|
||||
@@ -1510,8 +1511,8 @@ validate (struct Spec_list *s1, struct Spec_list *s2)
|
||||
/* Not translating. */
|
||||
{
|
||||
if (s2->n_indefinite_repeats > 0)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("the [c*] construct may appear in string2 only\
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("the [c*] construct may appear in string2 only\
|
||||
when translating"));
|
||||
}
|
||||
}
|
||||
@@ -1591,7 +1592,7 @@ squeeze_filter (char *buf, size_t size, size_t (*reader) (char *, size_t))
|
||||
}
|
||||
if (out_len > 0
|
||||
&& fwrite (&buf[begin], 1, out_len, stdout) != out_len)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
|
||||
if (char_to_squeeze != NOT_A_CHAR)
|
||||
@@ -1615,7 +1616,7 @@ plain_read (char *buf, size_t size)
|
||||
{
|
||||
size_t nr = safe_read (STDIN_FILENO, buf, size);
|
||||
if (nr == SAFE_READ_ERROR)
|
||||
error (EXIT_FAILURE, errno, _("read error"));
|
||||
die (EXIT_FAILURE, errno, _("read error"));
|
||||
return nr;
|
||||
}
|
||||
|
||||
@@ -1814,7 +1815,7 @@ main (int argc, char **argv)
|
||||
if (nr == 0)
|
||||
break;
|
||||
if (fwrite (io_buf, 1, nr, stdout) != nr)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
}
|
||||
else if (squeeze_repeats && delete && non_option_args == 2)
|
||||
@@ -1906,13 +1907,13 @@ main (int argc, char **argv)
|
||||
if (bytes_read == 0)
|
||||
break;
|
||||
if (fwrite (io_buf, 1, bytes_read, stdout) != bytes_read)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (close (STDIN_FILENO) != 0)
|
||||
error (EXIT_FAILURE, errno, _("standard input"));
|
||||
die (EXIT_FAILURE, errno, _("standard input"));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+5
-4
@@ -26,6 +26,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "stat-size.h"
|
||||
@@ -285,7 +286,7 @@ main (int argc, char **argv)
|
||||
_("Invalid number"), 0);
|
||||
/* Rounding to multiple of 0 is nonsensical */
|
||||
if ((rel_mode == rm_rup || rel_mode == rm_rdn) && size == 0)
|
||||
error (EXIT_FAILURE, 0, _("division by zero"));
|
||||
die (EXIT_FAILURE, 0, _("division by zero"));
|
||||
got_size = true;
|
||||
break;
|
||||
|
||||
@@ -334,7 +335,7 @@ main (int argc, char **argv)
|
||||
struct stat sb;
|
||||
off_t file_size = -1;
|
||||
if (stat (ref_file, &sb) != 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot stat %s"), quoteaf (ref_file));
|
||||
die (EXIT_FAILURE, errno, _("cannot stat %s"), quoteaf (ref_file));
|
||||
if (usable_st_size (&sb))
|
||||
file_size = sb.st_size;
|
||||
else
|
||||
@@ -355,8 +356,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
if (file_size < 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot get the size of %s"),
|
||||
quoteaf (ref_file));
|
||||
die (EXIT_FAILURE, errno, _("cannot get the size of %s"),
|
||||
quoteaf (ref_file));
|
||||
if (!got_size)
|
||||
size = file_size;
|
||||
else
|
||||
|
||||
+6
-5
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "readtokens.h"
|
||||
@@ -445,7 +446,7 @@ tsort (const char *file)
|
||||
root = new_item (NULL);
|
||||
|
||||
if (!is_stdin && ! freopen (file, "r", stdin))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (file));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (file));
|
||||
|
||||
fadvise (stdin, FADVISE_SEQUENTIAL);
|
||||
|
||||
@@ -472,8 +473,8 @@ tsort (const char *file)
|
||||
}
|
||||
|
||||
if (k != NULL)
|
||||
error (EXIT_FAILURE, 0, _("%s: input contains an odd number of tokens"),
|
||||
quotef (file));
|
||||
die (EXIT_FAILURE, 0, _("%s: input contains an odd number of tokens"),
|
||||
quotef (file));
|
||||
|
||||
/* T1. Initialize (N <- n). */
|
||||
walk_tree (root, count_items);
|
||||
@@ -531,8 +532,8 @@ tsort (const char *file)
|
||||
IF_LINT (free (root));
|
||||
|
||||
if (fclose (stdin) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s",
|
||||
is_stdin ? _("standard input") : quotef (file));
|
||||
die (EXIT_FAILURE, errno, "%s",
|
||||
is_stdin ? _("standard input") : quotef (file));
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
+2
-1
@@ -50,6 +50,7 @@
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "uname.h"
|
||||
@@ -283,7 +284,7 @@ main (int argc, char **argv)
|
||||
struct utsname name;
|
||||
|
||||
if (uname (&name) == -1)
|
||||
error (EXIT_FAILURE, errno, _("cannot get system name"));
|
||||
die (EXIT_FAILURE, errno, _("cannot get system name"));
|
||||
|
||||
if (toprint & PRINT_KERNEL_NAME)
|
||||
print_element (name.sysname);
|
||||
|
||||
+6
-6
@@ -39,7 +39,7 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "die.h"
|
||||
#include "xstrndup.h"
|
||||
|
||||
#include "expand-common.h"
|
||||
@@ -178,7 +178,7 @@ unexpand (void)
|
||||
if (convert)
|
||||
{
|
||||
if (next_tab_column < column)
|
||||
error (EXIT_FAILURE, 0, _("input line is too long"));
|
||||
die (EXIT_FAILURE, 0, _("input line is too long"));
|
||||
|
||||
if (c == '\t')
|
||||
{
|
||||
@@ -223,7 +223,7 @@ unexpand (void)
|
||||
{
|
||||
column++;
|
||||
if (!column)
|
||||
error (EXIT_FAILURE, 0, _("input line is too long"));
|
||||
die (EXIT_FAILURE, 0, _("input line is too long"));
|
||||
}
|
||||
|
||||
if (pending)
|
||||
@@ -231,7 +231,7 @@ unexpand (void)
|
||||
if (pending > 1 && one_blank_before_tab_stop)
|
||||
pending_blank[0] = '\t';
|
||||
if (fwrite (pending_blank, 1, pending, stdout) != pending)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
pending = 0;
|
||||
one_blank_before_tab_stop = false;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ unexpand (void)
|
||||
}
|
||||
|
||||
if (putchar (c) < 0)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
while (c != '\n');
|
||||
}
|
||||
@@ -303,7 +303,7 @@ main (int argc, char **argv)
|
||||
have_tabval = true;
|
||||
}
|
||||
if (!DECIMAL_DIGIT_ACCUMULATE (tabval, c - '0', uintmax_t))
|
||||
error (EXIT_FAILURE, 0, _("tab stop value is too large"));
|
||||
die (EXIT_FAILURE, 0, _("tab stop value is too large"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-5
@@ -24,6 +24,7 @@
|
||||
#include "system.h"
|
||||
#include "argmatch.h"
|
||||
#include "linebuffer.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "hard-locale.h"
|
||||
@@ -249,7 +250,7 @@ size_opt (char const *opt, char const *msgid)
|
||||
break;
|
||||
|
||||
default:
|
||||
error (EXIT_FAILURE, 0, "%s: %s", opt, _(msgid));
|
||||
die (EXIT_FAILURE, 0, "%s: %s", opt, _(msgid));
|
||||
}
|
||||
|
||||
return MIN (size, SIZE_MAX);
|
||||
@@ -334,9 +335,9 @@ check_file (const char *infile, const char *outfile, char delimiter)
|
||||
struct linebuffer *thisline, *prevline;
|
||||
|
||||
if (! (STREQ (infile, "-") || freopen (infile, "r", stdin)))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
if (! (STREQ (outfile, "-") || freopen (outfile, "w", stdout)))
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (outfile));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (outfile));
|
||||
|
||||
fadvise (stdin, FADVISE_SEQUENTIAL);
|
||||
|
||||
@@ -433,7 +434,7 @@ check_file (const char *infile, const char *outfile, char delimiter)
|
||||
if (match_count == UINTMAX_MAX)
|
||||
{
|
||||
if (count_occurrences)
|
||||
error (EXIT_FAILURE, 0, _("too many repeated lines"));
|
||||
die (EXIT_FAILURE, 0, _("too many repeated lines"));
|
||||
match_count--;
|
||||
}
|
||||
|
||||
@@ -469,7 +470,7 @@ check_file (const char *infile, const char *outfile, char delimiter)
|
||||
|
||||
closefiles:
|
||||
if (ferror (stdin) || fclose (stdin) != 0)
|
||||
error (EXIT_FAILURE, 0, _("error reading %s"), quoteaf (infile));
|
||||
die (EXIT_FAILURE, 0, _("error reading %s"), quoteaf (infile));
|
||||
|
||||
/* stdout is handled via the atexit-invoked close_stdout function. */
|
||||
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
@@ -83,7 +84,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (unlink (argv[optind]) != 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot unlink %s"), quoteaf (argv[optind]));
|
||||
die (EXIT_FAILURE, errno, _("cannot unlink %s"), quoteaf (argv[optind]));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+3
-2
@@ -32,6 +32,7 @@
|
||||
#endif
|
||||
|
||||
#include "c-strtod.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
@@ -122,7 +123,7 @@ print_uptime (size_t n, const STRUCT_UTMP *this)
|
||||
#endif
|
||||
{
|
||||
if (boot_time == 0)
|
||||
error (EXIT_FAILURE, errno, _("couldn't get boot time"));
|
||||
die (EXIT_FAILURE, errno, _("couldn't get boot time"));
|
||||
uptime = time_now - boot_time;
|
||||
}
|
||||
updays = uptime / 86400;
|
||||
@@ -180,7 +181,7 @@ uptime (const char *filename, int options)
|
||||
|
||||
#if HAVE_UTMPX_H || HAVE_UTMP_H
|
||||
if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
#endif
|
||||
|
||||
print_uptime (n_users, utmp_buf);
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
@@ -88,7 +89,7 @@ users (const char *filename, int options)
|
||||
STRUCT_UTMP *utmp_buf;
|
||||
|
||||
if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
|
||||
list_entries_users (n_users, utmp_buf);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "argv-iter.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "mbchar.h"
|
||||
@@ -707,8 +708,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
stream = fopen (files_from, "r");
|
||||
if (stream == NULL)
|
||||
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quoteaf (files_from));
|
||||
die (EXIT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quoteaf (files_from));
|
||||
}
|
||||
|
||||
/* Read the file list into RAM if we can detect its size and that
|
||||
@@ -721,8 +722,8 @@ main (int argc, char **argv)
|
||||
read_tokens = true;
|
||||
readtokens0_init (&tok);
|
||||
if (! readtokens0 (stream, &tok) || fclose (stream) != 0)
|
||||
error (EXIT_FAILURE, 0, _("cannot read file names from %s"),
|
||||
quoteaf (files_from));
|
||||
die (EXIT_FAILURE, 0, _("cannot read file names from %s"),
|
||||
quoteaf (files_from));
|
||||
files = tok.tok;
|
||||
nfiles = tok.n_tok;
|
||||
ai = argv_iter_init_argv (files);
|
||||
@@ -827,7 +828,7 @@ main (int argc, char **argv)
|
||||
free (fstatus);
|
||||
|
||||
if (have_read_stdin && close (STDIN_FILENO) != 0)
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
die (EXIT_FAILURE, errno, "-");
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "c-ctype.h"
|
||||
#include "canon-host.h"
|
||||
#include "readutmp.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "hard-locale.h"
|
||||
#include "quote.h"
|
||||
@@ -622,7 +623,7 @@ who (const char *filename, int options)
|
||||
STRUCT_UTMP *utmp_buf;
|
||||
|
||||
if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
|
||||
if (short_list)
|
||||
list_entries_who (n_users, utmp_buf);
|
||||
|
||||
+3
-5
@@ -25,6 +25,7 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
@@ -84,11 +85,8 @@ main (int argc, char **argv)
|
||||
uid = geteuid ();
|
||||
pw = (uid == NO_UID && errno ? NULL : getpwuid (uid));
|
||||
if (!pw)
|
||||
{
|
||||
error (0, errno, _("cannot find name for user ID %lu"),
|
||||
(unsigned long int) uid);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
die (EXIT_FAILURE, errno, _("cannot find name for user ID %lu"),
|
||||
(unsigned long int) uid);
|
||||
puts (pw->pw_name);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in new issue
Block a user