exit 1; } \
|| :
-error_fns = (error|die|diagnose)
+error_fns = (error|diagnose)
# Files in src/ should quote all strings in error() output, so that
# unexpected input chars like \r etc. don't corrupt the error.
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 \([^?]*EXIT_' \
- && { 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.
exclude_file_name_regexp--sc_trailing_blank = \
^(tests/pr/|gl/.*\.diff$$|man/help2man)
exclude_file_name_regexp--sc_system_h_headers = \
- ^src/((die|system|copy|chown-core|find-mount-point)\.h|make-prime-list\.c)$$
+ ^src/((system|copy|chown-core|find-mount-point)\.h|make-prime-list\.c)$$
_src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
_gl_src = (xdecto.max|cl-strtold)
#include <sys/types.h>
#include "system.h"
-#include "error.h"
#include "quote.h"
/* The official name of this program (e.g., no 'g' prefix). */
#include "system.h"
#include "c-ctype.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "idx.h"
#include "quote.h"
return;
/* currently, there's no way to return an error in encoding. */
- die (EXIT_FAILURE, 0,
- _("invalid input (length must be multiple of 4 characters)"));
+ error (EXIT_FAILURE, 0,
+ _("invalid input (length must be multiple of 4 characters)"));
}
else
{
{
/* Simple write. */
if (fwrite (buffer, 1, len, stdout) < len)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
else
for (idx_t written = 0; written < len; )
if (to_write == 0)
{
if (fputc ('\n', out) == EOF)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
*current_column = 0;
}
else
{
if (fwrite (buffer + written, 1, to_write, stdout) < to_write)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
*current_column += to_write;
written += to_write;
}
if (fclose (in) != 0)
{
if (STREQ (infile, "-"))
- die (EXIT_FAILURE, errno, _("closing standard input"));
+ error (EXIT_FAILURE, errno, _("closing standard input"));
else
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
}
exit (EXIT_SUCCESS);
/* When wrapping, terminate last line. */
if (wrap_column && current_column > 0 && fputc ('\n', out) == EOF)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
if (ferror (in))
- die (EXIT_FAILURE, errno, _("read error"));
+ error (EXIT_FAILURE, errno, _("read error"));
finish_and_exit (in, infile);
}
sum += n;
if (ferror (in))
- die (EXIT_FAILURE, errno, _("read error"));
+ error (EXIT_FAILURE, errno, _("read error"));
}
while (sum < BASE_LENGTH (DEC_BLOCKSIZE) && !feof (in));
ok = base_decode_ctx (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n);
if (fwrite (outbuf, 1, n, out) < n)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
if (!ok)
- die (EXIT_FAILURE, 0, _("invalid input"));
+ error (EXIT_FAILURE, 0, _("invalid input"));
}
}
while (!feof (in));
intmax_t w;
strtol_error s_err = xstrtoimax (optarg, nullptr, 10, &w, "");
if (LONGINT_OVERFLOW < s_err || w < 0)
- die (EXIT_FAILURE, 0, "%s: %s",
- _("invalid wrap size"), quote (optarg));
+ error (EXIT_FAILURE, 0, "%s: %s",
+ _("invalid wrap size"), quote (optarg));
wrap_column = s_err == LONGINT_OVERFLOW || IDX_MAX < w ? 0 : w;
}
break;
{
input_fh = fopen (infile, "rb");
if (input_fh == nullptr)
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
}
fadvise (input_fh, FADVISE_SEQUENTIAL);
#include "alignalloc.h"
#include "idx.h"
#include "ioblksize.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "full-write.h"
#include "safe-read.h"
/* Write this block out. */
if (full_write (STDOUT_FILENO, buf, n_read) != n_read)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
}
if (0 < n_write)
{
if (full_write (STDOUT_FILENO, outbuf, n_write) != n_write)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
*bpout = outbuf;
}
}
do
{
if (full_write (STDOUT_FILENO, wp, outsize) != outsize)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
wp += outsize;
remaining_bytes = bpout - wp;
}
/* Get device, i-node number, and optimal blocksize of output. */
if (fstat (STDOUT_FILENO, &stat_buf) < 0)
- die (EXIT_FAILURE, errno, _("standard output"));
+ error (EXIT_FAILURE, errno, _("standard output"));
/* Optimal size of i/o operations of output. */
idx_t outsize = io_blksize (stat_buf);
if (pending_cr)
{
if (full_write (STDOUT_FILENO, "\r", 1) != 1)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
if (have_read_stdin && close (STDIN_FILENO) < 0)
- die (EXIT_FAILURE, errno, _("closing standard input"));
+ error (EXIT_FAILURE, errno, _("closing standard input"));
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
#include "system.h"
#include "dev-ino.h"
-#include "die.h"
-#include "error.h"
#include "ignore-value.h"
#include "quote.h"
#include "root-dev-ino.h"
if (bit_flags == FTS_PHYSICAL)
{
if (dereference == 1)
- die (EXIT_FAILURE, 0,
- _("-R --dereference requires either -H or -L"));
+ error (EXIT_FAILURE, 0,
+ _("-R --dereference requires either -H or -L"));
affect_symlink_referent = false;
}
else
{
if (dereference == 0)
- die (EXIT_FAILURE, 0, _("-R -h requires -P"));
+ error (EXIT_FAILURE, 0, _("-R -h requires -P"));
affect_symlink_referent = true;
}
}
char *ref_context = nullptr;
if (getfilecon (reference_file, &ref_context) < 0)
- die (EXIT_FAILURE, errno, _("failed to get security context of %s"),
- quoteaf (reference_file));
+ error (EXIT_FAILURE, errno, _("failed to get security context of %s"),
+ quoteaf (reference_file));
specified_context = ref_context;
}
specified_context = argv[optind++];
if (0 < is_selinux_enabled ()
&& security_check_context (specified_context) < 0)
- die (EXIT_FAILURE, errno, _("invalid context: %s"),
- quote (specified_context));
+ error (EXIT_FAILURE, errno, _("invalid context: %s"),
+ quote (specified_context));
}
if (reference_file && component_specified)
static struct dev_ino dev_ino_buf;
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
if (root_dev_ino == nullptr)
- die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
- quoteaf ("/"));
+ error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
+ quoteaf ("/"));
}
else
{
#include "system.h"
#include "chown-core.h"
-#include "die.h"
-#include "error.h"
#include "fts_.h"
#include "quote.h"
#include "root-dev-ino.h"
uintmax_t tmp;
if (! (xstrtoumax (name, nullptr, 10, &tmp, "") == LONGINT_OK
&& tmp <= GID_T_MAX))
- die (EXIT_FAILURE, 0, _("invalid group: %s"),
- quote (name));
+ error (EXIT_FAILURE, 0, _("invalid group: %s"),
+ quote (name));
gid = tmp;
}
endgrent (); /* Save a file descriptor. */
if (bit_flags == FTS_PHYSICAL)
{
if (dereference == 1)
- die (EXIT_FAILURE, 0,
- _("-R --dereference requires either -H or -L"));
+ error (EXIT_FAILURE, 0,
+ _("-R --dereference requires either -H or -L"));
dereference = 0;
}
}
{
struct stat ref_stats;
if (stat (reference_file, &ref_stats))
- die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
- quoteaf (reference_file));
+ error (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);
static struct dev_ino dev_ino_buf;
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
if (chopt.root_dev_ino == nullptr)
- die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
- quoteaf ("/"));
+ error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
+ quoteaf ("/"));
}
bit_flags |= FTS_DEFER_STAT;
#include "system.h"
#include "assure.h"
#include "dev-ino.h"
-#include "die.h"
-#include "error.h"
#include "filemode.h"
#include "ignore-value.h"
#include "modechange.h"
{
change = mode_create_from_ref (reference_file);
if (!change)
- die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
- quoteaf (reference_file));
+ error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
+ quoteaf (reference_file));
}
else
{
static struct dev_ino dev_ino_buf;
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
if (root_dev_ino == nullptr)
- die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
- quoteaf ("/"));
+ error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
+ quoteaf ("/"));
}
else
{
#include "system.h"
#include "assure.h"
#include "chown-core.h"
-#include "error.h"
#include "ignore-value.h"
#include "root-dev-ino.h"
#include "xfts.h"
#include "system.h"
#include "chown-core.h"
-#include "die.h"
-#include "error.h"
#include "fts_.h"
#include "quote.h"
#include "root-dev-ino.h"
if (bit_flags == FTS_PHYSICAL)
{
if (dereference == 1)
- die (EXIT_FAILURE, 0,
- _("-R --dereference requires either -H or -L"));
+ error (EXIT_FAILURE, 0,
+ _("-R --dereference requires either -H or -L"));
dereference = 0;
}
}
{
struct stat ref_stats;
if (stat (reference_file, &ref_stats))
- die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
- quoteaf (reference_file));
+ error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
+ quoteaf (reference_file));
uid = ref_stats.st_uid;
gid = ref_stats.st_gid;
static struct dev_ino dev_ino_buf;
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
if (chopt.root_dev_ino == nullptr)
- die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
- quoteaf ("/"));
+ error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
+ quoteaf ("/"));
}
bit_flags |= FTS_DEFER_STAT;
#include <grp.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "ignore-value.h"
#include "mgetgroups.h"
#include "quote.h"
}
if (chroot (newroot) != 0)
- die (EXIT_CANCELED, errno, _("cannot change root directory to %s"),
- quoteaf (newroot));
+ error (EXIT_CANCELED, errno, _("cannot change root directory to %s"),
+ quoteaf (newroot));
if (! skip_chdir && chdir ("/"))
- die (EXIT_CANCELED, errno, _("cannot chdir to root directory"));
+ error (EXIT_CANCELED, errno, _("cannot chdir to root directory"));
if (argc == optind + 1)
{
}
else if (gid_unset (gid))
{
- die (EXIT_CANCELED, errno,
- _("no group specified for unknown uid: %d"), (int) uid);
+ error (EXIT_CANCELED, errno,
+ _("no group specified for unknown uid: %d"), (int) uid);
}
}
if (ngroups <= 0)
{
if (! n_gids)
- die (EXIT_CANCELED, errno,
- _("failed to get supplemental groups"));
+ error (EXIT_CANCELED, errno,
+ _("failed to get supplemental groups"));
/* else look-up outside the chroot worked, then go with those. */
}
else
#endif
if ((uid_set (uid) || groups) && setgroups (n_gids, gids) != 0)
- die (EXIT_CANCELED, errno, _("failed to set supplemental groups"));
+ error (EXIT_CANCELED, errno, _("failed to set supplemental groups"));
free (in_gids);
free (out_gids);
if (gid_set (gid) && setgid (gid))
- die (EXIT_CANCELED, errno, _("failed to set group-ID"));
+ error (EXIT_CANCELED, errno, _("failed to set group-ID"));
if (uid_set (uid) && setuid (uid))
- die (EXIT_CANCELED, errno, _("failed to set user-ID"));
+ error (EXIT_CANCELED, errno, _("failed to set user-ID"));
/* Execute the given command. */
execvp (argv[0], argv);
#else /* !CRCTAB */
-# include "die.h"
-# include "error.h"
-
# include "cksum.h"
/* Number of bytes to read at once. */
#include <sys/types.h>
#include "system.h"
#include "linebuffer.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "hard-locale.h"
#include "quote.h"
alt[i][2] = 0;
streams[i] = (STREQ (infiles[i], "-") ? stdin : fopen (infiles[i], "r"));
if (!streams[i])
- die (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
+ error (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]))
- die (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
+ error (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
}
while (thisline[0] || thisline[1])
all_line[i][alt[i][1]], i + 1);
if (ferror (streams[i]))
- die (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
+ error (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
fill_up[i] = false;
}
for (i = 0; i < 2; i++)
if (fclose (streams[i]) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
+ error (EXIT_FAILURE, errno, "%s", quotef (infiles[i]));
if (total_option)
{
}
if (issued_disorder_warning[0] || issued_disorder_warning[1])
- die (EXIT_FAILURE, 0, _("input is not in sorted order"));
+ error (EXIT_FAILURE, 0, _("input is not in sorted order"));
/* Exit here to pacify gcc -fsanitizer=leak. */
exit (EXIT_SUCCESS);
case OUTPUT_DELIMITER_OPTION:
if (col_sep_len && !STREQ (col_sep, optarg))
- die (EXIT_FAILURE, 0, _("multiple output delimiters specified"));
+ error (EXIT_FAILURE, 0, _("multiple output delimiters specified"));
col_sep = optarg;
col_sep_len = *optarg ? strlen (optarg) : 1;
break;
#include "canonicalize.h"
#include "copy.h"
#include "cp-hash.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "fcntl--.h"
#include "file-set.h"
restore_default_fscreatecon_or_die (void)
{
if (setfscreatecon (nullptr) != 0)
- die (EXIT_FAILURE, errno,
- _("failed to restore the default file creation context"));
+ error (EXIT_FAILURE, errno,
+ _("failed to restore the default file creation context"));
}
/* Return a newly-allocated string that is like STR
#endif
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "quote.h"
#ifdef SINGLE_BINARY
{
argv[nskip] = arg_name; /* XXX: Discards any specified path. */
launch_program (prog_name, argc - nskip, argv + nskip);
- die (EXIT_FAILURE, 0, _("unknown program %s"),
- quote (prog_name));
+ error (EXIT_FAILURE, 0, _("unknown program %s"),
+ quote (prog_name));
}
}
#include "backupfile.h"
#include "copy.h"
#include "cp-hash.h"
-#include "die.h"
-#include "error.h"
#include "filenamecat.h"
#include "ignore-value.h"
#include "quote.h"
if (no_target_directory)
{
if (target_directory)
- die (EXIT_FAILURE, 0,
- _("cannot combine --target-directory (-t) "
- "and --no-target-directory (-T)"));
+ error (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]));
{
target_dirfd = target_directory_operand (target_directory, &sb);
if (! target_dirfd_valid (target_dirfd))
- die (EXIT_FAILURE, errno, _("target directory %s"),
- quoteaf (target_directory));
+ error (EXIT_FAILURE, errno, _("target directory %s"),
+ quoteaf (target_directory));
}
else
{
|| (O_PATHSEARCH == O_SEARCH && err == EACCES
&& (sb.st_mode || stat (lastfile, &sb) == 0)
&& S_ISDIR (sb.st_mode)))
- die (EXIT_FAILURE, err, _("target %s"), quoteaf (lastfile));
+ error (EXIT_FAILURE, err, _("target %s"), quoteaf (lastfile));
}
}
case 't':
if (target_directory)
- die (EXIT_FAILURE, 0,
- _("multiple target directories specified"));
+ error (EXIT_FAILURE, 0,
+ _("multiple target directories specified"));
target_directory = optarg;
break;
x.preserve_security_context = false;
if (x.preserve_security_context && (x.set_security_context || scontext))
- die (EXIT_FAILURE, 0,
- _("cannot set target context and preserve it"));
+ error (EXIT_FAILURE, 0,
+ _("cannot set target context and preserve it"));
if (x.require_preserve_context && ! selinux_enabled)
- die (EXIT_FAILURE, 0,
- _("cannot preserve security context "
- "without an SELinux-enabled kernel"));
+ error (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,
error (...);
*/
if (scontext && setfscreatecon (scontext) < 0)
- die (EXIT_FAILURE, errno,
- _("failed to set default file creation context to %s"),
- quote (scontext));
+ error (EXIT_FAILURE, errno,
+ _("failed to set default file creation context to %s"),
+ quote (scontext));
#if !USE_XATTR
if (x.require_preserve_xattr)
- die (EXIT_FAILURE, 0, _("cannot preserve extended attributes, cp is "
- "built without xattr support"));
+ error (EXIT_FAILURE, 0, _("cannot preserve extended attributes, cp is "
+ "built without xattr support"));
#endif
/* Allocate space for remembering copied and created files. */
#include <regex.h>
-#include "die.h"
-#include "error.h"
#include "fd-reopen.h"
#include "idx.h"
#include "quote.h"
get_first_line_in_buffer (void)
{
if (head == nullptr && !load_buffer ())
- die (EXIT_FAILURE, errno, _("input disappeared"));
+ error (EXIT_FAILURE, errno, _("input disappeared"));
return head->first_available;
}
set_input_file (char const *name)
{
if (! STREQ (name, "-") && fd_reopen (STDIN_FILENO, name, O_RDONLY, 0) < 0)
- die (EXIT_FAILURE, errno, _("cannot open %s for reading"),
- quoteaf (name));
+ error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
+ quoteaf (name));
}
/* Write all lines from the beginning of the buffer up to, but
check_for_offset (struct control *p, char const *str, char const *num)
{
if (xstrtoimax (num, nullptr, 10, &p->offset, "") != LONGINT_OK)
- die (EXIT_FAILURE, 0, _("%s: integer expected after delimiter"),
- quote (str));
+ error (EXIT_FAILURE, 0, _("%s: integer expected after delimiter"),
+ quote (str));
}
/* Given that the first character of command line arg STR is '{',
end = str + strlen (str) - 1;
if (*end != '}')
- die (EXIT_FAILURE, 0, _("%s: '}' is required in repeat count"),
- quote (str));
+ error (EXIT_FAILURE, 0, _("%s: '}' is required in repeat count"),
+ quote (str));
*end = '\0';
if (str + 1 == end - 1 && *(str + 1) == '*')
if (xstrtoumax (str + 1, nullptr, 10, &val, "") != LONGINT_OK
|| INTMAX_MAX < val)
{
- die (EXIT_FAILURE, 0,
- _("%s}: integer required between '{' and '}'"),
- quote (global_argv[argnum]));
+ error (EXIT_FAILURE, 0,
+ _("%s}: integer required between '{' and '}'"),
+ quote (global_argv[argnum]));
}
p->repeat = val;
}
closing_delim = strrchr (str + 1, delim);
if (closing_delim == nullptr)
- die (EXIT_FAILURE, 0,
- _("%s: closing delimiter '%c' missing"), str, delim);
+ error (EXIT_FAILURE, 0,
+ _("%s: closing delimiter '%c' missing"), str, delim);
len = closing_delim - str - 1;
p = new_control_record ();
uintmax_t val;
if (xstrtoumax (argv[i], nullptr, 10, &val, "") != LONGINT_OK
|| INTMAX_MAX < val)
- die (EXIT_FAILURE, 0, _("%s: invalid pattern"), quote (argv[i]));
+ error (EXIT_FAILURE, 0, _("%s: invalid pattern"), quote (argv[i]));
if (val == 0)
- die (EXIT_FAILURE, 0,
- _("%s: line number must be greater than zero"), argv[i]);
+ error (EXIT_FAILURE, 0,
+ _("%s: line number must be greater than zero"), argv[i]);
if (val < last_val)
{
char buf[INT_BUFSIZE_BOUND (intmax_t)];
- die (EXIT_FAILURE, 0,
- _("line number %s is smaller than preceding line number, %s"),
- quote (argv[i]), imaxtostr (last_val, buf));
+ error (EXIT_FAILURE, 0,
+ _("line number %s is smaller than preceding line number,"
+ " %s"),
+ quote (argv[i]), imaxtostr (last_val, buf));
}
if (val == last_val)
break;
case 0:
- die (EXIT_FAILURE, 0, _("missing conversion specifier in suffix"));
+ error (EXIT_FAILURE, 0, _("missing conversion specifier in suffix"));
default:
if (isprint (ch))
- die (EXIT_FAILURE, 0,
- _("invalid conversion specifier in suffix: %c"), ch);
+ error (EXIT_FAILURE, 0,
+ _("invalid conversion specifier in suffix: %c"), ch);
else
- die (EXIT_FAILURE, 0,
- _("invalid conversion specifier in suffix: \\%.3o"), ch);
+ error (EXIT_FAILURE, 0,
+ _("invalid conversion specifier in suffix: \\%.3o"), ch);
}
if (flags & ~ compatible_flags)
- die (EXIT_FAILURE, 0,
- _("invalid flags in conversion specification: %%%c%c"),
- (flags & ~ compatible_flags & FLAG_ALTERNATIVE ? '#' : '\''), ch);
+ error (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
if (*f == '%' && *++f != '%')
{
if (percent)
- die (EXIT_FAILURE, 0,
- _("too many %% conversion specifications in suffix"));
+ error (EXIT_FAILURE, 0,
+ _("too many %% conversion specifications in suffix"));
percent = true;
int flags;
f += get_format_flags (f, &flags);
}
if (! percent)
- die (EXIT_FAILURE, 0,
- _("missing %% conversion specification in suffix"));
+ error (EXIT_FAILURE, 0,
+ _("missing %% conversion specification in suffix"));
int maxlen = snprintf (nullptr, 0, format, INT_MAX);
if (maxlen < 0)
#include "system.h"
#include "assure.h"
-#include "error.h"
#include "fadvise.h"
#include "getndelim2.h"
#include "system.h"
#include "argmatch.h"
-#include "die.h"
-#include "error.h"
#include "parse-datetime.h"
#include "posixtm.h"
#include "quote.h"
{
in_stream = fopen (input_filename, "r");
if (in_stream == nullptr)
- {
- die (EXIT_FAILURE, errno, "%s", quotef (input_filename));
- }
+ error (EXIT_FAILURE, errno, "%s", quotef (input_filename));
}
line = nullptr;
if (line_length < 0)
{
if (ferror (in_stream))
- die (EXIT_FAILURE, errno, _("%s: read error"),
- quotef (input_filename));
+ error (EXIT_FAILURE, errno, _("%s: read error"),
+ quotef (input_filename));
break;
}
}
if (fclose (in_stream) == EOF)
- die (EXIT_FAILURE, errno, "%s", quotef (input_filename));
+ error (EXIT_FAILURE, errno, "%s", quotef (input_filename));
free (line);
if (new_format)
{
if (format)
- die (EXIT_FAILURE, 0, _("multiple output formats specified"));
+ error (EXIT_FAILURE, 0, _("multiple output formats specified"));
format = new_format;
}
}
if (argv[optind][0] == '+')
{
if (format)
- die (EXIT_FAILURE, 0, _("multiple output formats specified"));
+ error (EXIT_FAILURE, 0, _("multiple output formats specified"));
format = argv[optind++] + 1;
}
else if (set_date || option_specified_date)
if (reference != nullptr)
{
if (stat (reference, &refstats) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (reference));
+ error (EXIT_FAILURE, errno, "%s", quotef (reference));
when = get_stat_mtime (&refstats);
}
else if (get_resolution)
}
if (! valid_date)
- die (EXIT_FAILURE, 0, _("invalid date %s"), quote (datestr));
+ error (EXIT_FAILURE, 0, _("invalid date %s"), quote (datestr));
if (set_date)
{
#include "system.h"
#include "alignalloc.h"
#include "close-stream.h"
-#include "die.h"
#include "fd-reopen.h"
#include "gethrxtime.h"
#include "human.h"
if (!ibuf)
{
char hbuf[LONGEST_HUMAN_READABLE + 1];
- die (EXIT_FAILURE, 0,
- _("memory exhausted by input buffer of size %td bytes (%s)"),
- input_blocksize,
- human_readable (input_blocksize, hbuf,
- human_opts | human_base_1024, 1, 1));
+ error (EXIT_FAILURE, 0,
+ _("memory exhausted by input buffer of size %td bytes (%s)"),
+ input_blocksize,
+ human_readable (input_blocksize, hbuf,
+ human_opts | human_base_1024, 1, 1));
}
}
if (!obuf)
{
char hbuf[LONGEST_HUMAN_READABLE + 1];
- die (EXIT_FAILURE, 0,
- _("memory exhausted by output buffer of size %td"
- " bytes (%s)"),
- output_blocksize,
- human_readable (output_blocksize, hbuf,
- human_opts | human_base_1024, 1, 1));
+ error (EXIT_FAILURE, 0,
+ _("memory exhausted by output buffer of size %td"
+ " bytes (%s)"),
+ output_blocksize,
+ human_readable (output_blocksize, hbuf,
+ human_opts | human_base_1024, 1, 1));
}
}
else
}
if (iclose (STDIN_FILENO) != 0)
- die (EXIT_FAILURE, errno, _("closing input file %s"), quoteaf (input_file));
+ error (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 a consequence of signal handling. */
if (iclose (STDOUT_FILENO) != 0)
- die (EXIT_FAILURE, errno,
- _("closing output file %s"), quoteaf (output_file));
+ error (EXIT_FAILURE, errno,
+ _("closing output file %s"), quoteaf (output_file));
}
/* Process any pending signals. If signals are caught, this function
invalid = LONGINT_OVERFLOW;
if (invalid != LONGINT_OK)
- die (EXIT_FAILURE, invalid == LONGINT_OVERFLOW ? EOVERFLOW : 0,
- "%s: %s", _("invalid number"), quoteaf (val));
+ error (EXIT_FAILURE, invalid == LONGINT_OVERFLOW ? EOVERFLOW : 0,
+ "%s: %s", _("invalid number"), quoteaf (val));
else if (converted_idx)
*converted_idx = n;
}
input_flags &= ~O_FULLBLOCK;
if (multiple_bits_set (conversions_mask & (C_ASCII | C_EBCDIC | C_IBM)))
- die (EXIT_FAILURE, 0, _("cannot combine any two of {ascii,ebcdic,ibm}"));
+ error (EXIT_FAILURE, 0, _("cannot combine any two of {ascii,ebcdic,ibm}"));
if (multiple_bits_set (conversions_mask & (C_BLOCK | C_UNBLOCK)))
- die (EXIT_FAILURE, 0, _("cannot combine block and unblock"));
+ error (EXIT_FAILURE, 0, _("cannot combine block and unblock"));
if (multiple_bits_set (conversions_mask & (C_LCASE | C_UCASE)))
- die (EXIT_FAILURE, 0, _("cannot combine lcase and ucase"));
+ error (EXIT_FAILURE, 0, _("cannot combine lcase and ucase"));
if (multiple_bits_set (conversions_mask & (C_EXCL | C_NOCREAT)))
- die (EXIT_FAILURE, 0, _("cannot combine excl and nocreat"));
+ error (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)))
- die (EXIT_FAILURE, 0, _("cannot combine direct and nocache"));
+ error (EXIT_FAILURE, 0, _("cannot combine direct and nocache"));
if (input_flags & O_NOCACHE)
{
{
struct stat st;
if (ifstat (STDIN_FILENO, &st) != 0)
- die (EXIT_FAILURE, errno, _("cannot fstat %s"), quoteaf (file));
+ error (EXIT_FAILURE, errno, _("cannot fstat %s"), quoteaf (file));
if (usable_st_size (&st) && 0 <= input_offset
&& st.st_size - input_offset < offset)
{
}
if (!ok)
- die (EXIT_FAILURE, errno, _("setting flags for %s"), quoteaf (name));
+ error (EXIT_FAILURE, errno, _("setting flags for %s"), quoteaf (name));
}
}
else
{
if (ifd_reopen (STDIN_FILENO, input_file, O_RDONLY | input_flags, 0) < 0)
- die (EXIT_FAILURE, errno, _("failed to open %s"),
- quoteaf (input_file));
+ error (EXIT_FAILURE, errno, _("failed to open %s"),
+ quoteaf (input_file));
}
offset = lseek (STDIN_FILENO, 0, SEEK_CUR);
if ((INT_MULTIPLY_WRAPV (seek_records, output_blocksize, &size)
|| INT_ADD_WRAPV (seek_bytes, size, &size))
&& !(conversions_mask & C_NOTRUNC))
- die (EXIT_FAILURE, 0,
- _("offset too large: "
- "cannot truncate to a length of seek=%"PRIdMAX""
- " (%td-byte) blocks"),
- seek_records, output_blocksize);
+ error (EXIT_FAILURE, 0,
+ _("offset too large: "
+ "cannot truncate to a length of seek=%"PRIdMAX""
+ " (%td-byte) blocks"),
+ seek_records, output_blocksize);
/* Open the output file with *read* access only if we might
need to read to satisfy a 'seek=' request. If we can't read
|| ifd_reopen (STDOUT_FILENO, output_file, O_RDWR | opts, perms) < 0)
&& (ifd_reopen (STDOUT_FILENO, output_file, O_WRONLY | opts, perms)
< 0))
- die (EXIT_FAILURE, errno, _("failed to open %s"),
- quoteaf (output_file));
+ error (EXIT_FAILURE, errno, _("failed to open %s"),
+ quoteaf (output_file));
if (seek_records != 0 && !(conversions_mask & C_NOTRUNC))
{
#include "system.h"
#include "assure.h"
#include "canonicalize.h"
-#include "die.h"
-#include "error.h"
#include "fsusage.h"
#include "human.h"
#include "mbsalign.h"
/* 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)
- die (EXIT_FAILURE, 0, _("no file systems processed"));
+ error (EXIT_FAILURE, 0, _("no file systems processed"));
}
main_exit (exit_status);
+++ /dev/null
-/* Report an error and exit.
- Copyright 2016-2023 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
- 02110-1301, USA. */
-
-#ifndef DIE_H
-# define DIE_H
-
-# include <error.h>
-# include <stddef.h>
-
-/* Like 'error (STATUS, ...)', except STATUS must be a nonzero constant.
- This may pacify the compiler or help it generate better code. */
-# define die(status, ...) \
- verify_expr (status, (error (status, __VA_ARGS__), unreachable ()))
-
-#endif /* DIE_H */
#if HASH_ALGO_CKSUM
# include "sm3.h"
#endif
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "stdio--.h"
#include "xbinary-io.h"
++line_number;
if (line_number == 0)
- die (EXIT_FAILURE, 0, _("%s: too many checksum lines"),
- quotef (checkfile_name));
+ error (EXIT_FAILURE, 0, _("%s: too many checksum lines"),
+ quotef (checkfile_name));
line_length = getline (&line, &line_chars_allocated, checkfile_stream);
if (line_length <= 0)
if (digest_length % 8 != 0)
{
error (0, 0, _("invalid length: %s"), quote (digest_length_str));
- die (EXIT_FAILURE, 0, _("length is not a multiple of 8"));
+ error (EXIT_FAILURE, 0, _("length is not a multiple of 8"));
}
break;
#endif
#if HASH_ALGO_BLAKE2 || HASH_ALGO_CKSUM
# if HASH_ALGO_CKSUM
if (digest_length && cksum_algorithm != blake2b)
- die (EXIT_FAILURE, 0,
- _("--length is only supported with --algorithm=blake2b"));
+ error (EXIT_FAILURE, 0,
+ _("--length is only supported with --algorithm=blake2b"));
# endif
if (digest_length > BLAKE2B_MAX_LEN * 8)
{
error (0, 0, _("invalid length: %s"), quote (digest_length_str));
- die (EXIT_FAILURE, 0,
- _("maximum digest length for %s is %d bits"),
- quote (DIGEST_TYPE_STRING),
- BLAKE2B_MAX_LEN * 8);
+ error (EXIT_FAILURE, 0,
+ _("maximum digest length for %s is %d bits"),
+ quote (DIGEST_TYPE_STRING),
+ BLAKE2B_MAX_LEN * 8);
}
if (digest_length == 0)
{
case sysv:
case crc:
if (do_check && algorithm_specified)
- die (EXIT_FAILURE, 0,
- _("--check is not supported with --algorithm={bsd,sysv,crc}"));
+ error (EXIT_FAILURE, 0,
+ _("--check is not supported with --algorithm={bsd,sysv,crc}"));
break;
default:
break;
if (optind == argc)
*operand_lim++ = bad_cast ("-");
else if (1 < argc - optind && raw_digest)
- {
- die (EXIT_FAILURE, 0,
- _("the --raw option is not supported with multiple files"));
- }
+ error (EXIT_FAILURE, 0,
+ _("the --raw option is not supported with multiple files"));
for (char **operandp = argv + optind; operandp < operand_lim; operandp++)
{
}
if (have_read_stdin && fclose (stdin) == EOF)
- die (EXIT_FAILURE, errno, _("standard input"));
+ error (EXIT_FAILURE, errno, _("standard input"));
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
#include "system.h"
#include "dircolors.h"
#include "c-strcase.h"
-#include "die.h"
-#include "error.h"
#include "obstack.h"
#include "quote.h"
#include "stdio--.h"
{
syntax = guess_shell_syntax ();
if (syntax == SHELL_SYNTAX_UNKNOWN)
- {
- die (EXIT_FAILURE, 0,
- _("no SHELL environment variable, and no shell type option given"));
- }
+ error (EXIT_FAILURE, 0,
+ _("no SHELL environment variable,"
+ " and no shell type option given"));
}
obstack_init (&lsc_obstack);
#include <sys/types.h>
#include "system.h"
-#include "error.h"
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "dirname"
#include "argv-iter.h"
#include "assure.h"
#include "di-set.h"
-#include "die.h"
-#include "error.h"
#include "exclude.h"
#include "fprintftime.h"
#include "human.h"
if (opt_threshold == 0 && *optarg == '-')
{
/* Do not allow -0, as this wouldn't make sense anyway. */
- die (EXIT_FAILURE, 0, _("invalid --threshold argument '-0'"));
+ error (EXIT_FAILURE, 0, _("invalid --threshold argument '-0'"));
}
}
break;
}
if (! (STREQ (files_from, "-") || freopen (files_from, "r", stdin)))
- die (EXIT_FAILURE, errno, _("cannot open %s for reading"),
- quoteaf (files_from));
+ error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
+ quoteaf (files_from));
ai = argv_iter_init_stream (stdin);
di_set_free (di_mnt);
if (files_from && (ferror (stdin) || fclose (stdin) != 0) && ok)
- die (EXIT_FAILURE, 0, _("error reading %s"), quoteaf (files_from));
+ error (EXIT_FAILURE, 0, _("error reading %s"), quoteaf (files_from));
if (print_grand_total)
print_size (&tot_dui, _("total"));
#include <signal.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "idx.h"
#include "operand2sig.h"
#include "quote.h"
devmsg ("unset: %s\n", usvars[i]);
if (unsetenv (usvars[i]))
- die (EXIT_CANCELED, errno, _("cannot unset %s"),
- quote (usvars[i]));
+ error (EXIT_CANCELED, errno, _("cannot unset %s"),
+ quote (usvars[i]));
}
}
case 'c':
if (dq)
- die (EXIT_CANCELED, 0,
- _("'\\c' must not appear in double-quoted -S string"));
+ error (EXIT_CANCELED, 0,
+ _("'\\c' must not appear in double-quoted -S string"));
goto eos; /* '\c' terminates the string. */
case 'f': newc = '\f'; break;
case 'v': newc = '\v'; break;
case '\0':
- die (EXIT_CANCELED, 0,
- _("invalid backslash at end of string in -S"));
+ error (EXIT_CANCELED, 0,
+ _("invalid backslash at end of string in -S"));
default:
- die (EXIT_CANCELED, 0, _("invalid sequence '\\%c' in -S"), newc);
+ error (EXIT_CANCELED, 0,
+ _("invalid sequence '\\%c' in -S"), newc);
}
break;
{
char *n = extract_varname (str);
if (!n)
- die (EXIT_CANCELED, 0,
- _("only ${VARNAME} expansion is supported, error at: %s"),
- str);
+ error (EXIT_CANCELED, 0,
+ _("only ${VARNAME} expansion is supported, error at: %s"),
+ str);
char *v = getenv (n);
if (v)
}
if (dq || sq)
- die (EXIT_CANCELED, 0, _("no terminating quote in -S string"));
+ error (EXIT_CANCELED, 0, _("no terminating quote in -S string"));
eos:
splitbuf_append_byte (&ss, '\0');
int sig_err = sigaction (i, nullptr, &act);
if (sig_err && !ignore_errors)
- die (EXIT_CANCELED, errno,
- _("failed to get signal action for signal %d"), i);
+ error (EXIT_CANCELED, errno,
+ _("failed to get signal action for signal %d"), i);
if (! sig_err)
{
act.sa_handler = set_to_default ? SIG_DFL : SIG_IGN;
sig_err = sigaction (i, &act, nullptr);
if (sig_err && !ignore_errors)
- die (EXIT_CANCELED, errno,
- _("failed to set signal action for signal %d"), i);
+ error (EXIT_CANCELED, errno,
+ _("failed to set signal action for signal %d"), i);
}
if (dev_debug)
sigemptyset (&set);
if (sigprocmask (0, nullptr, &set))
- die (EXIT_CANCELED, errno, _("failed to get signal process mask"));
+ error (EXIT_CANCELED, errno, _("failed to get signal process mask"));
for (int i = 1; i <= SIGNUM_BOUND; i++)
{
}
if (sigprocmask (SIG_SETMASK, &set, nullptr))
- die (EXIT_CANCELED, errno, _("failed to set signal process mask"));
+ error (EXIT_CANCELED, errno, _("failed to set signal process mask"));
}
static void
sigemptyset (&set);
if (sigprocmask (0, nullptr, &set))
- die (EXIT_CANCELED, errno, _("failed to get signal process mask"));
+ error (EXIT_CANCELED, errno, _("failed to get signal process mask"));
for (int i = 1; i <= SIGNUM_BOUND; i++)
{
if (putenv (argv[optind]))
{
*eq = '\0';
- die (EXIT_CANCELED, errno, _("cannot set %s"),
- quote (argv[optind]));
+ error (EXIT_CANCELED, errno, _("cannot set %s"),
+ quote (argv[optind]));
}
optind++;
}
devmsg ("chdir: %s\n", quoteaf (newdir));
if (chdir (newdir) != 0)
- die (EXIT_CANCELED, errno, _("cannot change directory to %s"),
- quoteaf (newdir));
+ error (EXIT_CANCELED, errno, _("cannot change directory to %s"),
+ quoteaf (newdir));
}
if (dev_debug)
#include <stdio.h>
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "quote.h"
if (max_column_width < column_width)
{
if (SIZE_MAX < column_width)
- die (EXIT_FAILURE, 0, _("tabs are too far apart"));
+ error (EXIT_FAILURE, 0, _("tabs are too far apart"));
max_column_width = column_width;
}
}
for (size_t i = 0; i < entries; i++)
{
if (tabs[i] == 0)
- die (EXIT_FAILURE, 0, _("tab size cannot be 0"));
+ error (EXIT_FAILURE, 0, _("tab size cannot be 0"));
if (tabs[i] <= prev_tab)
- die (EXIT_FAILURE, 0, _("tab sizes must be ascending"));
+ error (EXIT_FAILURE, 0, _("tab sizes must be ascending"));
prev_tab = tabs[i];
}
if (increment_size && extend_size)
- die (EXIT_FAILURE, 0, _("'/' specifier is mutually exclusive with '+'"));
+ error (EXIT_FAILURE, 0, _("'/' specifier is mutually exclusive with '+'"));
}
/* Called after all command-line options have been parsed,
cleanup_file_list_stdin (void)
{
if (have_read_stdin && fclose (stdin) != 0)
- die (EXIT_FAILURE, errno, "-");
+ error (EXIT_FAILURE, errno, "-");
}
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-
#include "expand-common.h"
/* The official name of this program (e.g., no 'g' prefix). */
next_tab_column = column + 1;
if (next_tab_column < column)
- die (EXIT_FAILURE, 0, _("input line is too long"));
+ error (EXIT_FAILURE, 0, _("input line is too long"));
while (++column < next_tab_column)
if (putchar (' ') < 0)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
c = ' ';
}
{
column++;
if (!column)
- die (EXIT_FAILURE, 0, _("input line is too long"));
+ error (EXIT_FAILURE, 0, _("input line is too long"));
}
convert &= convert_entire_line || !! isblank (c);
return;
if (putchar (c) < 0)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
while (c != '\n');
}
#include <gmp.h>
#include <regex.h>
-#include "die.h"
-#include "error.h"
#include "long-options.h"
#include "mbuiter.h"
#include "strnumcmp.h"
v = eval (true);
if (!nomoreargs ())
- die (EXPR_INVALID, 0, _("syntax error: unexpected argument %s"),
- quotearg_n_style (0, locale_quoting_style, *args));
+ error (EXPR_INVALID, 0, _("syntax error: unexpected argument %s"),
+ quotearg_n_style (0, locale_quoting_style, *args));
printv (v);
if (! looks_like_integer (s))
return false;
if (mpz_init_set_str (v->u.i, s, 10) != 0)
- die (EXPR_FAILURE, ERANGE, "%s", (s));
+ error (EXPR_FAILURE, ERANGE, "%s", (s));
free (s);
v->type = integer;
return true;
require_more_args (void)
{
if (nomoreargs ())
- die (EXPR_INVALID, 0, _("syntax error: missing argument after %s"),
- quotearg_n_style (0, locale_quoting_style, *(args - 1)));
+ error (EXPR_INVALID, 0, _("syntax error: missing argument after %s"),
+ quotearg_n_style (0, locale_quoting_style, *(args - 1)));
}
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)
- die (EXPR_INVALID, 0, "%s", (errmsg));
+ error (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);
v = int_value (0);
}
else
- die (EXPR_FAILURE,
- (matchlen == -2 ? errno : EOVERFLOW),
- _("error in regular expression matcher"));
+ error (EXPR_FAILURE,
+ matchlen == -2 ? errno : EOVERFLOW,
+ _("error in regular expression matcher"));
if (0 < re_regs.num_regs)
{
{
v = eval (evaluate);
if (nomoreargs ())
- die (EXPR_INVALID, 0, _("syntax error: expecting ')' after %s"),
- quotearg_n_style (0, locale_quoting_style, *(args - 1)));
+ error (EXPR_INVALID, 0, _("syntax error: expecting ')' after %s"),
+ quotearg_n_style (0, locale_quoting_style, *(args - 1)));
if (!nextarg (")"))
- die (EXPR_INVALID, 0, _("syntax error: expecting ')' instead of %s"),
- quotearg_n_style (0, locale_quoting_style, *args));
+ error (EXPR_INVALID, 0, _("syntax error: expecting ')' instead of %s"),
+ quotearg_n_style (0, locale_quoting_style, *args));
return v;
}
if (nextarg (")"))
- die (EXPR_INVALID, 0, _("syntax error: unexpected ')'"));
+ error (EXPR_INVALID, 0, _("syntax error: unexpected ')'"));
return str_value (*args++);
}
if (evaluate)
{
if (!toarith (l) || !toarith (r))
- die (EXPR_INVALID, 0, _("non-integer argument"));
+ error (EXPR_INVALID, 0, _("non-integer argument"));
if (fxn != multiply && mpz_sgn (r->u.i) == 0)
- die (EXPR_INVALID, 0, _("division by zero"));
+ error (EXPR_INVALID, 0, _("division by zero"));
((fxn == multiply ? mpz_mul
: fxn == divide ? mpz_tdiv_q
: mpz_tdiv_r)
if (evaluate)
{
if (!toarith (l) || !toarith (r))
- die (EXPR_INVALID, 0, _("non-integer argument"));
+ error (EXPR_INVALID, 0, _("non-integer argument"));
(fxn == plus ? mpz_add : mpz_sub) (l->u.i, l->u.i, r->u.i);
}
freev (r);
{
error (0, errno, _("string comparison failed"));
error (0, 0, _("set LC_ALL='C' to work around the problem"));
- 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));
+ 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));
}
}
#include "system.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "full-write.h"
#include "quote.h"
#include "readtokens.h"
if (g <= L)
{
if (qpos >= QUEUE_SIZE)
- die (EXIT_FAILURE, 0, _("squfof queue overflow"));
+ error (EXIT_FAILURE, 0, _("squfof queue overflow"));
queue[qpos].Q = g;
queue[qpos].P = P % g;
qpos++;
{
size_t size = lbuf.end - lbuf.buf;
if (full_write (STDOUT_FILENO, lbuf.buf, size) != size)
- die (EXIT_FAILURE, errno, "%s", _("write error"));
+ error (EXIT_FAILURE, errno, "%s", _("write error"));
lbuf.end = lbuf.buf;
}
if (token_length == (size_t) -1)
{
if (ferror (stdin))
- die (EXIT_FAILURE, errno, _("error reading input"));
+ error (EXIT_FAILURE, errno, _("error reading input"));
break;
}
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "save-cwd.h"
#include "xgetcwd.h"
#include "find-mount-point.h"
{
int save_errno = errno;
if (restore_cwd (&cwd) != 0)
- die (EXIT_FAILURE, errno,
- _("failed to return to initial working directory"));
+ error (EXIT_FAILURE, errno,
+ _("failed to return to initial working directory"));
free_cwd (&cwd);
errno = save_errno;
}
#include "c-ctype.h"
#include "system.h"
-#include "error.h"
-#include "die.h"
#include "fadvise.h"
#include "xdectoint.h"
}
if (have_read_stdin && fclose (stdin) != 0)
- die (EXIT_FAILURE, errno, "%s", _("closing standard input"));
+ error (EXIT_FAILURE, errno, "%s", _("closing standard input"));
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "xdectoint.h"
}
if (have_read_stdin && fclose (stdin) == EOF)
- die (EXIT_FAILURE, errno, "-");
+ error (EXIT_FAILURE, errno, "-");
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
#include <grp.h>
#include "system.h"
-#include "error.h"
#include "mgetgroups.h"
#include "quote.h"
#include "group-list.h"
#include <getopt.h>
#include "system.h"
-#include "die.h"
#include "group-list.h"
#include "quote.h"
errno = 0;
ruid = getuid ();
if (ruid == NO_UID && errno)
- die (EXIT_FAILURE, errno, _("cannot get real UID"));
+ error (EXIT_FAILURE, errno, _("cannot get real UID"));
errno = 0;
egid = getegid ();
if (egid == NO_GID && errno)
- die (EXIT_FAILURE, errno, _("cannot get effective GID"));
+ error (EXIT_FAILURE, errno, _("cannot get effective GID"));
errno = 0;
rgid = getgid ();
if (rgid == NO_GID && errno)
- die (EXIT_FAILURE, errno, _("cannot get real GID"));
+ error (EXIT_FAILURE, errno, _("cannot get real GID"));
if (!print_group_list (nullptr, ruid, rgid, egid, true, ' '))
ok = false;
#include "system.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "full-read.h"
#include "quote.h"
#include "safe-read.h"
if (n_bytes > 0 && fwrite (buffer, 1, n_bytes, stdout) < n_bytes)
{
clearerr (stdout); /* To avoid redundant close_stdout diagnostic. */
- die (EXIT_FAILURE, errno, _("error writing %s"),
- quoteaf ("standard output"));
+ error (EXIT_FAILURE, errno, _("error writing %s"),
+ quoteaf ("standard output"));
}
}
if (SIZE_MAX < n_elide_0 + READ_BUFSIZE)
{
char umax_buf[INT_BUFSIZE_BOUND (n_elide_0)];
- die (EXIT_FAILURE, 0, _("%s: number of bytes is too large"),
- umaxtostr (n_elide_0, umax_buf));
+ error (EXIT_FAILURE, 0, _("%s: number of bytes is too large"),
+ umaxtostr (n_elide_0, umax_buf));
}
/* Two cases to consider...
if ( ! count_lines && elide_from_end && OFF_T_MAX < n_units)
{
char umax_buf[INT_BUFSIZE_BOUND (n_units)];
- die (EXIT_FAILURE, EOVERFLOW, "%s: %s", _("invalid number of bytes"),
- quote (umaxtostr (n_units, umax_buf)));
+ error (EXIT_FAILURE, EOVERFLOW, "%s: %s", _("invalid number of bytes"),
+ quote (umaxtostr (n_units, umax_buf)));
}
file_list = (optind < argc
ok &= head_file (file_list[i], n_units, count_lines, elide_from_end);
if (have_read_stdin && close (STDIN_FILENO) < 0)
- die (EXIT_FAILURE, errno, "-");
+ error (EXIT_FAILURE, errno, "-");
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
#include "system.h"
#include "long-options.h"
-#include "error.h"
#include "quote.h"
/* The official name of this program (e.g., no 'g' prefix). */
#include "system.h"
#include "long-options.h"
-#include "die.h"
-#include "error.h"
#include "quote.h"
#include "xgethostname.h"
/* Set hostname to operand. */
char const *name = argv[optind];
if (sethostname (name, strlen (name)) != 0)
- die (EXIT_FAILURE, errno, _("cannot set name to %s"),
- quote (name));
+ error (EXIT_FAILURE, errno, _("cannot set name to %s"),
+ quote (name));
}
else
{
hostname = xgethostname ();
if (hostname == nullptr)
- die (EXIT_FAILURE, errno, _("cannot determine hostname"));
+ error (EXIT_FAILURE, errno, _("cannot determine hostname"));
puts (hostname);
}
#include <selinux/selinux.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "mgetgroups.h"
#include "quote.h"
#include "group-list.h"
/* politely decline if we're not on a SELinux/SMACK-enabled kernel. */
#ifdef HAVE_SMACK
if (!selinux_enabled && !smack_enabled)
- die (EXIT_FAILURE, 0,
- _("--context (-Z) works only on "
- "an SELinux/SMACK-enabled kernel"));
+ error (EXIT_FAILURE, 0,
+ _("--context (-Z) works only on "
+ "an SELinux/SMACK-enabled kernel"));
#else
if (!selinux_enabled)
- die (EXIT_FAILURE, 0,
- _("--context (-Z) works only on an SELinux-enabled kernel"));
+ error (EXIT_FAILURE, 0,
+ _("--context (-Z) works only on an SELinux-enabled kernel"));
#endif
just_context = true;
break;
size_t n_ids = argc - optind;
if (n_ids && just_context)
- die (EXIT_FAILURE, 0,
- _("cannot print security context when user specified"));
+ error (EXIT_FAILURE, 0,
+ _("cannot print security context when user specified"));
if (just_user + just_group + just_group_list + just_context > 1)
- die (EXIT_FAILURE, 0, _("cannot print \"only\" of more than one choice"));
+ error (EXIT_FAILURE, 0, _("cannot print \"only\" of more than one choice"));
bool default_format = ! (just_user
|| just_group
|| just_context);
if (default_format && (use_real || use_name))
- die (EXIT_FAILURE, 0,
- _("cannot print only names or real IDs in default format"));
+ error (EXIT_FAILURE, 0,
+ _("cannot print only names or real IDs in default format"));
if (default_format && opt_zero)
- die (EXIT_FAILURE, 0,
- _("option --zero not permitted in default format"));
+ error (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,
|| (smack_enabled
&& smack_new_label_from_self (&context) < 0
&& just_context))
- die (EXIT_FAILURE, 0, _("can't get process context"));
+ error (EXIT_FAILURE, 0, _("can't get process context"));
}
if (n_ids >= 1)
errno = 0;
euid = geteuid ();
if (euid == NO_UID && errno)
- die (EXIT_FAILURE, errno, _("cannot get effective UID"));
+ error (EXIT_FAILURE, errno, _("cannot get effective UID"));
}
if (just_user ? use_real
errno = 0;
ruid = getuid ();
if (ruid == NO_UID && errno)
- die (EXIT_FAILURE, errno, _("cannot get real UID"));
+ error (EXIT_FAILURE, errno, _("cannot get real UID"));
}
if (!just_user && (just_group || just_group_list || !just_context))
errno = 0;
egid = getegid ();
if (egid == NO_GID && errno)
- die (EXIT_FAILURE, errno, _("cannot get effective GID"));
+ error (EXIT_FAILURE, errno, _("cannot get effective GID"));
errno = 0;
rgid = getgid ();
if (rgid == NO_GID && errno)
- die (EXIT_FAILURE, errno, _("cannot get real GID"));
+ error (EXIT_FAILURE, errno, _("cannot get real GID"));
}
print_stuff (nullptr);
}
#include "system.h"
#include "backupfile.h"
-#include "error.h"
#include "cp-hash.h"
#include "copy.h"
-#include "die.h"
#include "filenamecat.h"
#include "full-read.h"
#include "mkancesdirs.h"
if (name && *name == '-')
safe_name = file_name_concat (".", name, nullptr);
execlp (strip_program, strip_program, safe_name, nullptr);
- die (EXIT_FAILURE, errno, _("cannot run %s"), quoteaf (strip_program));
+ error (EXIT_FAILURE, errno, _("cannot run %s"),
+ quoteaf (strip_program));
}
default: /* Parent. */
if (waitpid (pid, &status, 0) < 0)
uintmax_t tmp;
if (xstrtoumax (owner_name, nullptr, 0, &tmp, "") != LONGINT_OK
|| UID_T_MAX < tmp)
- die (EXIT_FAILURE, 0, _("invalid user %s"),
- quote (owner_name));
+ error (EXIT_FAILURE, 0, _("invalid user %s"),
+ quoteaf (owner_name));
owner_id = tmp;
}
else
uintmax_t tmp;
if (xstrtoumax (group_name, nullptr, 0, &tmp, "") != LONGINT_OK
|| GID_T_MAX < tmp)
- die (EXIT_FAILURE, 0, _("invalid group %s"),
- quote (group_name));
+ error (EXIT_FAILURE, 0, _("invalid group %s"),
+ quoteaf (group_name));
group_id = tmp;
}
else
if (! strip (to))
{
if (unlinkat (to_dirfd, to_relname, 0) != 0) /* Cleanup. */
- die (EXIT_FAILURE, errno, _("cannot unlink %s"), quoteaf (to));
+ error (EXIT_FAILURE, errno, _("cannot unlink %s"), quoteaf (to));
return false;
}
if (x->preserve_timestamps && (strip_files || ! S_ISREG (from_sb.st_mode))
break;
case 't':
if (target_directory)
- die (EXIT_FAILURE, 0,
- _("multiple target directories specified"));
+ error (EXIT_FAILURE, 0,
+ _("multiple target directories specified"));
target_directory = optarg;
break;
case 'T':
/* Check for invalid combinations of arguments. */
if (dir_arg && strip_files)
- die (EXIT_FAILURE, 0,
- _("the strip option may not be used when installing a directory"));
+ error (EXIT_FAILURE, 0,
+ _("the strip option may not be used when installing a directory"));
if (dir_arg && target_directory)
- die (EXIT_FAILURE, 0,
- _("target directory not allowed when installing a directory"));
+ error (EXIT_FAILURE, 0,
+ _("target directory not allowed when installing a directory"));
x.backup_type = (make_backups
? xget_version (_("backup type"),
set_simple_backup_suffix (backup_suffix);
if (x.preserve_security_context && (x.set_security_context || scontext))
- die (EXIT_FAILURE, 0,
- _("cannot set target context and preserve it"));
+ error (EXIT_FAILURE, 0,
+ _("cannot set target context and preserve it"));
if (scontext && setfscreatecon (scontext) < 0)
- die (EXIT_FAILURE, errno,
- _("failed to set default file creation context to %s"),
+ error (EXIT_FAILURE, errno,
+ _("failed to set default file creation context to %s"),
quote (scontext));
n_files = argc - optind;
if (no_target_directory)
{
if (target_directory)
- die (EXIT_FAILURE, 0,
- _("cannot combine --target-directory (-t) "
- "and --no-target-directory (-T)"));
+ error (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]));
target_dirfd = target_directory_operand (target_directory, &sb);
if (! (target_dirfd_valid (target_dirfd)
|| (mkdir_and_install && errno == ENOENT)))
- die (EXIT_FAILURE, errno, _("failed to access %s"),
- quoteaf (target_directory));
+ error (EXIT_FAILURE, errno, _("failed to access %s"),
+ quoteaf (target_directory));
}
else if (!dir_arg)
{
n_files--;
}
else if (2 < n_files)
- die (EXIT_FAILURE, errno, _("target %s"), quoteaf (lastfile));
+ error (EXIT_FAILURE, errno, _("target %s"), quoteaf (lastfile));
}
if (specified_mode)
{
struct mode_change *change = mode_compile (specified_mode);
if (!change)
- die (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode));
+ error (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode));
mode = mode_adjust (0, false, 0, change, nullptr);
dir_mode = mode_adjust (0, true, 0, change, &dir_mode_bits);
free (change);
#include "system.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "hard-locale.h"
#include "linebuffer.h"
if (! readlinebuffer_delim (&line->buf, fp, eolchar))
{
if (ferror (fp))
- die (EXIT_FAILURE, errno, _("read error"));
+ error (EXIT_FAILURE, errno, _("read error"));
freeline (line);
return false;
}
if (s_err == LONGINT_OVERFLOW || (s_err == LONGINT_OK && SIZE_MAX < val))
val = SIZE_MAX;
else if (s_err != LONGINT_OK || val == 0)
- die (EXIT_FAILURE, 0, _("invalid field number: %s"), quote (str));
+ error (EXIT_FAILURE, 0, _("invalid field number: %s"), quote (str));
result = val - 1;
if (s[1])
{
/* '0' must be all alone -- no '.FIELD'. */
- die (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s));
+ error (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s));
}
*file_index = 0;
*field_index = 0;
case '1':
case '2':
if (s[1] != '.')
- die (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s));
+ error (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s));
*file_index = s[0] - '0';
*field_index = string_to_join_field (s + 2);
break;
default:
- die (EXIT_FAILURE, 0,
- _("invalid file number in field spec: %s"), quote (s));
+ error (EXIT_FAILURE, 0,
+ _("invalid file number in field spec: %s"), quote (s));
}
}
{
unsigned long int var1 = *var + 1;
unsigned long int val1 = val + 1;
- die (EXIT_FAILURE, 0,
- _("incompatible join fields %lu, %lu"), var1, val1);
+ error (EXIT_FAILURE, 0,
+ _("incompatible join fields %lu, %lu"), var1, val1);
}
*var = val;
}
unsigned long int val;
if (xstrtoul (optarg, nullptr, 10, &val, "") != LONGINT_OK
|| (val != 1 && val != 2))
- die (EXIT_FAILURE, 0,
- _("invalid field number: %s"), quote (optarg));
+ error (EXIT_FAILURE, 0,
+ _("invalid field number: %s"), quote (optarg));
if (val == 1)
print_unpairables_1 = true;
else
case 'e':
if (empty_filler && ! STREQ (empty_filler, optarg))
- die (EXIT_FAILURE, 0,
- _("conflicting empty-field replacement strings"));
+ error (EXIT_FAILURE, 0,
+ _("conflicting empty-field replacement strings"));
empty_filler = optarg;
break;
if (STREQ (optarg, "\\0"))
newtab = '\0';
else
- die (EXIT_FAILURE, 0, _("multi-character tab %s"),
- quote (optarg));
+ error (EXIT_FAILURE, 0, _("multi-character tab %s"),
+ quote (optarg));
}
if (0 <= tab && tab != newtab)
- die (EXIT_FAILURE, 0, _("incompatible tabs"));
+ error (EXIT_FAILURE, 0, _("incompatible tabs"));
tab = newtab;
}
break;
fp1 = STREQ (g_names[0], "-") ? stdin : fopen (g_names[0], "r");
if (!fp1)
- die (EXIT_FAILURE, errno, "%s", quotef (g_names[0]));
+ error (EXIT_FAILURE, errno, "%s", quotef (g_names[0]));
fp2 = STREQ (g_names[1], "-") ? stdin : fopen (g_names[1], "r");
if (!fp2)
- die (EXIT_FAILURE, errno, "%s", quotef (g_names[1]));
+ error (EXIT_FAILURE, errno, "%s", quotef (g_names[1]));
if (fp1 == fp2)
- die (EXIT_FAILURE, errno, _("both files cannot be standard input"));
+ error (EXIT_FAILURE, errno, _("both files cannot be standard input"));
join (fp1, fp2);
if (fclose (fp1) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (g_names[0]));
+ error (EXIT_FAILURE, errno, "%s", quotef (g_names[0]));
if (fclose (fp2) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (g_names[1]));
+ error (EXIT_FAILURE, errno, "%s", quotef (g_names[1]));
if (issued_disorder_warning[0] || issued_disorder_warning[1])
- die (EXIT_FAILURE, 0, _("input is not in sorted order"));
+ error (EXIT_FAILURE, 0, _("input is not in sorted order"));
else
return EXIT_SUCCESS;
}
#include <signal.h>
#include "system.h"
-#include "error.h"
#include "sig2str.h"
#include "operand2sig.h"
#include "quote.h"
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "long-options.h"
#include "quote.h"
}
if (link (argv[optind], argv[optind + 1]) != 0)
- die (EXIT_FAILURE, errno, _("cannot create link %s to %s"),
- quoteaf_n (0, argv[optind + 1]), quoteaf_n (1, argv[optind]));
+ error (EXIT_FAILURE, errno, _("cannot create link %s to %s"),
+ quoteaf_n (0, argv[optind + 1]), quoteaf_n (1, argv[optind]));
return EXIT_SUCCESS;
}
#include "system.h"
#include "backupfile.h"
-#include "die.h"
-#include "error.h"
#include "fcntl-safer.h"
#include "filenamecat.h"
#include "file-set.h"
break;
case 't':
if (target_directory)
- die (EXIT_FAILURE, 0, _("multiple target directories specified"));
+ error (EXIT_FAILURE, 0, _("multiple target directories specified"));
else
{
struct stat st;
if (stat (optarg, &st) != 0)
- die (EXIT_FAILURE, errno, _("failed to access %s"),
- quoteaf (optarg));
+ error (EXIT_FAILURE, errno, _("failed to access %s"),
+ quoteaf (optarg));
if (! S_ISDIR (st.st_mode))
- die (EXIT_FAILURE, 0, _("target %s is not a directory"),
- quoteaf (optarg));
+ error (EXIT_FAILURE, 0, _("target %s is not a directory"),
+ quoteaf (optarg));
}
target_directory = optarg;
break;
}
if (relative && !symbolic_link)
- die (EXIT_FAILURE, 0, _("cannot do --relative without --symbolic"));
+ error (EXIT_FAILURE, 0, _("cannot do --relative without --symbolic"));
if (!hard_dir_link)
{
if (no_target_directory)
{
if (target_directory)
- die (EXIT_FAILURE, 0,
- _("cannot combine --target-directory "
- "and --no-target-directory"));
+ error (EXIT_FAILURE, 0,
+ _("cannot combine --target-directory "
+ "and --no-target-directory"));
if (n_files != 2)
{
if (n_files < 2)
target_directory = d;
}
else if (! (n_files == 2 && !target_directory))
- die (EXIT_FAILURE, err, _("target %s"), quoteaf (d));
+ error (EXIT_FAILURE, err, _("target %s"), quoteaf (d));
}
}
src/chown-core.h \
src/copy.h \
src/cp-hash.h \
- src/die.h \
src/dircolors.h \
src/expand-common.h \
src/find-mount-point.h \
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "long-options.h"
#include "quote.h"
using a fallback technique. */
cp = getlogin ();
if (! cp)
- die (EXIT_FAILURE, 0, _("no login name"));
+ error (EXIT_FAILURE, 0, _("no login name"));
puts (cp);
return EXIT_SUCCESS;
#include "assure.h"
#include "c-strcase.h"
#include "dev-ino.h"
-#include "die.h"
-#include "error.h"
#include "filenamecat.h"
#include "hard-locale.h"
#include "hash.h"
case 'w':
width_opt = decode_line_length (optarg);
if (width_opt < 0)
- die (LS_FAILURE, 0, "%s: %s", _("invalid line width"),
- quote (optarg));
+ error (LS_FAILURE, 0, "%s: %s", _("invalid line width"),
+ quote (optarg));
break;
case 'x':
dired &= (format == long_format) & !print_hyperlink;
if (eolbyte < dired)
- die (LS_FAILURE, 0, _("--dired and --zero are incompatible"));
+ error (LS_FAILURE, 0, _("--dired and --zero are incompatible"));
/* If -c or -u is specified and not -l (or any other option that implies -l),
and no sort-type was specified, then sort by the ctime (-c) or atime (-u).
else
{
if (strchr (p1 + 1, '\n'))
- die (LS_FAILURE, 0, _("invalid time style format %s"),
- quote (p0));
+ error (LS_FAILURE, 0, _("invalid time style format %s"),
+ quote (p0));
*p1++ = '\0';
}
long_time_format[0] = p0;
#include <selinux/label.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "mkdir-p.h"
#include "modechange.h"
#include "prog-fprintf.h"
ret = setfscreatecon (scontext);
if (ret < 0)
- die (EXIT_FAILURE, errno,
- _("failed to set default file creation context to %s"),
- quote (scontext));
+ error (EXIT_FAILURE, errno,
+ _("failed to set default file creation context to %s"),
+ quote (scontext));
}
{
struct mode_change *change = mode_compile (specified_mode);
if (!change)
- die (EXIT_FAILURE, 0, _("invalid mode %s"),
- quote (specified_mode));
+ error (EXIT_FAILURE, 0, _("invalid mode %s"),
+ quote (specified_mode));
options.mode = mode_adjust (S_IRWXUGO, true, umask_value, change,
&options.mode_bits);
options.umask_self = umask_value & ~options.mode;
#include <selinux/label.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "modechange.h"
#include "quote.h"
#include "selinux.h"
ret = setfscreatecon (scontext);
if (ret < 0)
- die (EXIT_FAILURE, errno,
- _("failed to set default file creation context to %s"),
- quote (scontext));
+ error (EXIT_FAILURE, errno,
+ _("failed to set default file creation context to %s"),
+ quote (scontext));
}
newmode = MODE_RW_UGO;
mode_t umask_value;
struct mode_change *change = mode_compile (specified_mode);
if (!change)
- die (EXIT_FAILURE, 0, _("invalid mode"));
+ error (EXIT_FAILURE, 0, _("invalid mode"));
umask_value = umask (0);
umask (umask_value);
newmode = mode_adjust (newmode, false, umask_value, change, nullptr);
free (change);
if (newmode & ~S_IRWXUGO)
- die (EXIT_FAILURE, 0,
- _("mode must specify only file permission bits"));
+ error (EXIT_FAILURE, 0,
+ _("mode must specify only file permission bits"));
}
for (; optind < argc; ++optind)
#include <selinux/label.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "modechange.h"
#include "quote.h"
#include "selinux.h"
mode_t umask_value;
struct mode_change *change = mode_compile (specified_mode);
if (!change)
- die (EXIT_FAILURE, 0, _("invalid mode"));
+ error (EXIT_FAILURE, 0, _("invalid mode"));
umask_value = umask (0);
umask (umask_value);
newmode = mode_adjust (newmode, false, umask_value, change, nullptr);
free (change);
if (newmode & ~S_IRWXUGO)
- die (EXIT_FAILURE, 0,
- _("mode must specify only file permission bits"));
+ error (EXIT_FAILURE, 0,
+ _("mode must specify only file permission bits"));
}
/* If the number of arguments is 0 or 1,
ret = setfscreatecon (scontext);
if (ret < 0)
- die (EXIT_FAILURE, errno,
- _("failed to set default file creation context to %s"),
- quote (scontext));
+ error (EXIT_FAILURE, errno,
+ _("failed to set default file creation context to %s"),
+ quote (scontext));
}
/* Only check the first character, to allow mnemonic usage like
{
case 'b': /* 'block' or 'buffered' */
#ifndef S_IFBLK
- die (EXIT_FAILURE, 0, _("block special files not supported"));
+ error (EXIT_FAILURE, 0, _("block special files not supported"));
#else
node_type = S_IFBLK;
#endif
case 'c': /* 'character' */
case 'u': /* 'unbuffered' */
#ifndef S_IFCHR
- die (EXIT_FAILURE, 0, _("character special files not supported"));
+ error (EXIT_FAILURE, 0, _("character special files not supported"));
#else
node_type = S_IFCHR;
#endif
if (xstrtoumax (s_major, nullptr, 0, &i_major, "") != LONGINT_OK
|| i_major != (major_t) i_major)
- die (EXIT_FAILURE, 0,
- _("invalid major device number %s"), quote (s_major));
+ error (EXIT_FAILURE, 0,
+ _("invalid major device number %s"), quote (s_major));
if (xstrtoumax (s_minor, nullptr, 0, &i_minor, "") != LONGINT_OK
|| i_minor != (minor_t) i_minor)
- die (EXIT_FAILURE, 0,
- _("invalid minor device number %s"), quote (s_minor));
+ error (EXIT_FAILURE, 0,
+ _("invalid minor device number %s"), quote (s_minor));
device = makedev (i_major, i_minor);
#ifdef NODEV
if (device == NODEV)
- die (EXIT_FAILURE, 0, _("invalid device %s %s"),
- s_major, s_minor);
+ error (EXIT_FAILURE, 0, _("invalid device %s %s"),
+ s_major, s_minor);
#endif
if (set_security_context)
defaultcon (set_security_context, argv[optind], node_type);
if (mknod (argv[optind], newmode | node_type, device) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
+ error (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
}
break;
if (set_security_context)
defaultcon (set_security_context, argv[optind], S_IFIFO);
if (mkfifo (argv[optind], newmode) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
+ error (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
break;
default:
}
if (specified_mode && lchmod (argv[optind], newmode) != 0)
- die (EXIT_FAILURE, errno, _("cannot set permissions of %s"),
- quoteaf (argv[optind]));
+ error (EXIT_FAILURE, errno, _("cannot set permissions of %s"),
+ quoteaf (argv[optind]));
return EXIT_SUCCESS;
}
#include "system.h"
#include "close-stream.h"
-#include "die.h"
-#include "error.h"
#include "filenamecat.h"
#include "quote.h"
#include "tempname.h"
size_t len = strlen (template);
if (!len || template[len - 1] != 'X')
{
- die (EXIT_FAILURE, 0,
- _("with --suffix, template %s must end in X"),
- quote (template));
+ error (EXIT_FAILURE, 0,
+ _("with --suffix, template %s must end in X"),
+ quote (template));
}
suffix_len = strlen (suffix);
dest_name = xcharalloc (len + suffix_len + 1);
/* At this point, template is malloc'd, and suffix points into template. */
if (suffix_len && last_component (suffix) != suffix)
{
- die (EXIT_FAILURE, 0,
- _("invalid suffix %s, contains directory separator"),
- quote (suffix));
+ error (EXIT_FAILURE, 0,
+ _("invalid suffix %s, contains directory separator"),
+ quote (suffix));
}
x_count = count_consecutive_X_s (template, suffix - template);
if (x_count < 3)
- die (EXIT_FAILURE, 0, _("too few X's in template %s"), quote (template));
+ error (EXIT_FAILURE, 0, _("too few X's in template %s"), quote (template));
if (use_dest_dir)
{
dest_dir = "/tmp";
if (last_component (template) != template)
- die (EXIT_FAILURE, 0,
- _("invalid template, %s, contains directory separator"),
- quote (template));
+ error (EXIT_FAILURE, 0,
+ _("invalid template, %s, contains directory separator"),
+ quote (template));
}
else
{
dest_dir = (env && *env ? env : "/tmp");
}
if (IS_ABSOLUTE_FILE_NAME (template))
- die (EXIT_FAILURE, 0,
- _("invalid template, %s; with --tmpdir,"
- " it may not be absolute"),
- quote (template));
+ error (EXIT_FAILURE, 0,
+ _("invalid template, %s; with --tmpdir,"
+ " it may not be absolute"),
+ quote (template));
}
dest_name = file_name_concat (dest_dir, template, nullptr);
#include "backupfile.h"
#include "copy.h"
#include "cp-hash.h"
-#include "die.h"
-#include "error.h"
#include "filenamecat.h"
#include "remove.h"
#include "renameatu.h"
static struct dev_ino dev_ino_buf;
x->root_dev_ino = get_root_dev_ino (&dev_ino_buf);
if (x->root_dev_ino == nullptr)
- die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
- quoteaf ("/"));
+ error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
+ quoteaf ("/"));
}
x->preserve_all_root = false;
break;
case 't':
if (target_directory)
- die (EXIT_FAILURE, 0, _("multiple target directories specified"));
+ error (EXIT_FAILURE, 0, _("multiple target directories specified"));
target_directory = optarg;
break;
case 'T':
if (no_target_directory)
{
if (target_directory)
- die (EXIT_FAILURE, 0,
- _("cannot combine --target-directory (-t) "
- "and --no-target-directory (-T)"));
+ error (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]));
{
target_dirfd = target_directory_operand (target_directory, &sb);
if (! target_dirfd_valid (target_dirfd))
- die (EXIT_FAILURE, errno, _("target directory %s"),
- quoteaf (target_directory));
+ error (EXIT_FAILURE, errno, _("target directory %s"),
+ quoteaf (target_directory));
}
else
{
|| (O_PATHSEARCH == O_SEARCH && err == EACCES
&& (sb.st_mode != 0 || stat (lastfile, &sb) == 0)
&& S_ISDIR (sb.st_mode)))
- die (EXIT_FAILURE, err, _("target %s"), quoteaf (lastfile));
+ error (EXIT_FAILURE, err, _("target %s"), quoteaf (lastfile));
}
}
}
# include <sys/resource.h>
#endif
-#include "die.h"
-#include "error.h"
#include "quote.h"
#include "xstrtol.h"
enum { MIN_ADJUSTMENT = 1 - 2 * NZERO, MAX_ADJUSTMENT = 2 * NZERO - 1 };
long int tmp;
if (LONGINT_OVERFLOW < xstrtol (adjustment_given, nullptr, 10, &tmp, ""))
- die (EXIT_CANCELED, 0, _("invalid adjustment %s"),
- quote (adjustment_given));
+ error (EXIT_CANCELED, 0, _("invalid adjustment %s"),
+ quote (adjustment_given));
adjustment = MAX (MIN_ADJUSTMENT, MIN (tmp, MAX_ADJUSTMENT));
}
errno = 0;
current_niceness = GET_NICENESS ();
if (current_niceness == -1 && errno != 0)
- die (EXIT_CANCELED, errno, _("cannot get niceness"));
+ error (EXIT_CANCELED, errno, _("cannot get niceness"));
printf ("%d\n", current_niceness);
return EXIT_SUCCESS;
}
#else
current_niceness = GET_NICENESS ();
if (current_niceness == -1 && errno != 0)
- die (EXIT_CANCELED, errno, _("cannot get niceness"));
+ error (EXIT_CANCELED, errno, _("cannot get niceness"));
ok = (setpriority (PRIO_PROCESS, 0, current_niceness + adjustment) == 0);
#endif
if (!ok)
#include <regex.h>
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "linebuffer.h"
#include "quote.h"
RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES;
errmsg = re_compile_pattern (optarg, strlen (optarg), regexp);
if (errmsg)
- die (EXIT_FAILURE, 0, "%s", (errmsg));
+ error (EXIT_FAILURE, 0, "%s", (errmsg));
break;
default:
rval = false;
print_lineno (void)
{
if (line_no_overflow)
- die (EXIT_FAILURE, 0, _("line number overflow"));
+ error (EXIT_FAILURE, 0, _("line number overflow"));
printf (lineno_format, lineno_width, line_no, separator_str);
0, line_buf.length - 1, nullptr))
{
case -2:
- die (EXIT_FAILURE, errno, _("error in regular expression search"));
+ error (EXIT_FAILURE, errno, _("error in regular expression search"));
case -1:
fputs (print_no_line_fmt, stdout);
ok &= nl_file (argv[optind]);
if (have_read_stdin && fclose (stdin) == EOF)
- die (EXIT_FAILURE, errno, "-");
+ error (EXIT_FAILURE, errno, "-");
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
#include "system.h"
-#include "error.h"
#include "filenamecat.h"
#include "fd-reopen.h"
#include "long-options.h"
#include <sys/types.h>
#include "system.h"
-#include "error.h"
#include "nproc.h"
#include "quote.h"
#include "xdectoint.h"
#include "mbsalign.h"
#include "argmatch.h"
#include "c-ctype.h"
-#include "die.h"
-#include "error.h"
#include "quote.h"
#include "system.h"
#include "xstrtol.h"
num_size = snprintf (buf, buf_size, fmt, precision, val);
if (num_size < 0 || num_size >= (int) buf_size)
- die (EXIT_FAILURE, 0,
- _("failed to prepare value '%Lf' for printing"), val);
+ error (EXIT_FAILURE, 0,
+ _("failed to prepare value '%Lf' for printing"), val);
return;
}
num_size = snprintf (buf, buf_size - 1, fmt, prec, val,
suffix_power_char (power));
if (num_size < 0 || num_size >= (int) buf_size - 1)
- die (EXIT_FAILURE, 0,
- _("failed to prepare value '%Lf' for printing"), val);
+ error (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);
if (s_err != LONGINT_OK || *end || n == 0)
{
free (t_string);
- die (EXIT_FAILURE, 0, _("invalid unit size: %s"), quote (n_string));
+ error (EXIT_FAILURE, 0, _("invalid unit size: %s"), quote (n_string));
}
free (t_string);
for (i = 0; !(fmt[i] == '%' && fmt[i + 1] != '%'); i += (fmt[i] == '%') + 1)
{
if (!fmt[i])
- die (EXIT_FAILURE, 0,
- _("format %s has no %% directive"), quote (fmt));
+ error (EXIT_FAILURE, 0,
+ _("format %s has no %% directive"), quote (fmt));
prefix_len++;
}
errno = 0;
pad = strtol (fmt + i, &endptr, 10);
if (errno == ERANGE || pad < -LONG_MAX)
- die (EXIT_FAILURE, 0,
- _("invalid format %s (width overflow)"), quote (fmt));
+ error (EXIT_FAILURE, 0,
+ _("invalid format %s (width overflow)"), quote (fmt));
if (endptr != (fmt + i) && pad != 0)
{
i = endptr - fmt;
if (fmt[i] == '\0')
- die (EXIT_FAILURE, 0, _("format %s ends in %%"), quote (fmt));
+ error (EXIT_FAILURE, 0, _("format %s ends in %%"), quote (fmt));
if (fmt[i] == '.')
{
negative precision is only supported (and ignored)
when used with '.*f'. glibc at least will malform
output when passed a direct negative precision. */
- die (EXIT_FAILURE, 0,
- _("invalid precision in format %s"), quote (fmt));
+ error (EXIT_FAILURE, 0,
+ _("invalid precision in format %s"), quote (fmt));
}
i = endptr - fmt;
}
if (fmt[i] != 'f')
- die (EXIT_FAILURE, 0, _("invalid format %s,"
- " directive must be %%[0]['][-][N][.][N]f"),
+ error (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] != '%')
- die (EXIT_FAILURE, 0, _("format %s has too many %% directives"),
- quote (fmt));
+ error (EXIT_FAILURE, 0, _("format %s has too many %% directives"),
+ quote (fmt));
if (prefix_len)
format_str_prefix = ximemdup0 (fmt, prefix_len);
case PADDING_OPTION:
if (xstrtol (optarg, nullptr, 10, &padding_width, "") != LONGINT_OK
|| padding_width == 0 || padding_width < -LONG_MAX)
- die (EXIT_FAILURE, 0, _("invalid padding value %s"),
- quote (optarg));
+ error (EXIT_FAILURE, 0, _("invalid padding value %s"),
+ quote (optarg));
if (padding_width < 0)
{
padding_alignment = MBS_ALIGN_LEFT;
case FIELD_OPTION:
if (n_frp)
- die (EXIT_FAILURE, 0, _("multiple field specifications"));
+ error (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')
- die (EXIT_FAILURE, 0,
- _("the delimiter must be a single character"));
+ error (EXIT_FAILURE, 0,
+ _("the delimiter must be a single character"));
delimiter = optarg[0];
break;
{
if (xstrtoumax (optarg, nullptr, 10, &header, "") != LONGINT_OK
|| header == 0)
- die (EXIT_FAILURE, 0, _("invalid header value %s"),
- quote (optarg));
+ error (EXIT_FAILURE, 0, _("invalid header value %s"),
+ quote (optarg));
}
else
{
}
if (format_str != nullptr && grouping)
- die (EXIT_FAILURE, 0, _("--grouping cannot be combined with --format"));
+ error (EXIT_FAILURE, 0, _("--grouping cannot be combined with --format"));
if (debug && ! locale_ok)
error (0, 0, _("failed to set locale"));
if (grouping)
{
if (scale_to != scale_none)
- die (EXIT_FAILURE, 0, _("grouping cannot be combined with --to"));
+ error (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"));
}
}
if (ferror (stdin))
- die (EXIT_FAILURE, errno, _("error reading input"));
+ error (EXIT_FAILURE, errno, _("error reading input"));
}
if (debug && !valid_numbers)
#include "system.h"
#include "argmatch.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "ftoastr.h"
#include "quote.h"
#include "stat-size.h"
}
if (n_skip != 0)
- die (EXIT_FAILURE, 0, _("cannot skip past end of combined input"));
+ error (EXIT_FAILURE, 0, _("cannot skip past end of combined input"));
return ok;
}
address_pad_len = 0;
break;
default:
- die (EXIT_FAILURE, 0,
- _("invalid output address radix '%c';\
- it must be one character from [doxn]"),
- optarg[0]);
+ error (EXIT_FAILURE, 0,
+ _("invalid output address radix '%c';"
+ " it must be one character from [doxn]"),
+ optarg[0]);
break;
}
break;
/* The minimum string length may be no larger than SIZE_MAX,
since we may allocate a buffer of this size. */
if (SIZE_MAX < tmp)
- die (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
+ error (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
string_min = tmp;
}
if (s_err != LONGINT_OK)
xstrtol_fatal (s_err, oi, c, long_options, optarg);
if (SIZE_MAX < w_tmp)
- die (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
+ error (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
desired_width = w_tmp;
}
break;
return EXIT_FAILURE;
if (flag_dump_strings && n_specs > 0)
- die (EXIT_FAILURE, 0,
- _("no type may be specified when dumping strings"));
+ error (EXIT_FAILURE, 0,
+ _("no type may be specified when dumping strings"));
n_files = argc - optind;
{
end_offset = n_bytes_to_skip + max_bytes_to_format;
if (end_offset < n_bytes_to_skip)
- die (EXIT_FAILURE, 0, _("skip-bytes + read-bytes is too large"));
+ error (EXIT_FAILURE, 0, _("skip-bytes + read-bytes is too large"));
}
if (n_specs == 0)
cleanup:
if (have_read_stdin && fclose (stdin) == EOF)
- die (EXIT_FAILURE, errno, _("standard input"));
+ error (EXIT_FAILURE, errno, _("standard input"));
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
#include <sys/wait.h>
#include "system.h"
-#include "error.h"
#include "quote.h"
#include "sig2str.h"
#include "operand2sig.h"
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
/* The official name of this program (e.g., no 'g' prefix). */
static void
write_error (void)
{
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
/* Output a single byte, reporting any write errors. */
{
fileptr[files_open] = fopen (fnamptr[files_open], "r");
if (fileptr[files_open] == nullptr)
- die (EXIT_FAILURE, errno, "%s", quotef (fnamptr[files_open]));
+ error (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);
}
if (opened_stdin && have_read_stdin)
- die (EXIT_FAILURE, 0, _("standard input is closed"));
+ error (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
{
/* Don't use the quote() quoting style, because that would double the
number of displayed backslashes, making the diagnostic look bogus. */
- die (EXIT_FAILURE, 0,
- _("delimiter list ends with an unescaped backslash: %s"),
- quotearg_n_style_colon (0, c_maybe_quoting_style, delim_arg));
+ error (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)
free (delims);
if (have_read_stdin && fclose (stdin) == EOF)
- die (EXIT_FAILURE, errno, "-");
+ error (EXIT_FAILURE, errno, "-");
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
#include <wchar.h>
#include "system.h"
-#include "error.h"
#include "quote.h"
/* The official name of this program (e.g., no 'g' prefix). */
#include "system.h"
#include "canon-host.h"
-#include "die.h"
-#include "error.h"
#include "hard-locale.h"
#include "readutmp.h"
STRUCT_UTMP *utmp_buf = nullptr;
if (read_utmp (filename, &n_users, &utmp_buf, 0) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (filename));
+ error (EXIT_FAILURE, errno, "%s", quotef (filename));
scan_entries (n_users, utmp_buf, argc_names, argv_names);
exit (EXIT_SUCCESS);
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "hard-locale.h"
#include "mbswidth.h"
static _Noreturn void
integer_overflow (void)
{
- die (EXIT_FAILURE, 0, _("integer overflow"));
+ error (EXIT_FAILURE, 0, _("integer overflow"));
}
/* Return the number of columns that have either an open file or
case PAGES_OPTION: /* --pages=FIRST_PAGE[:LAST_PAGE] */
{ /* dominates old opt +... */
if (! optarg)
- die (EXIT_FAILURE, 0,
- _("'--pages=FIRST_PAGE[:LAST_PAGE]' missing argument"));
+ error (EXIT_FAILURE, 0,
+ _("'--pages=FIRST_PAGE[:LAST_PAGE]' missing argument"));
else if (! first_last_page (oi, 0, optarg))
- die (EXIT_FAILURE, 0, _("invalid page range %s"),
- quote (optarg));
+ error (EXIT_FAILURE, 0, _("invalid page range %s"),
+ quote (optarg));
break;
}
first_page_number = 1;
if (parallel_files && explicit_columns)
- die (EXIT_FAILURE, 0,
- _("cannot specify number of columns when printing in parallel"));
+ error (EXIT_FAILURE, 0,
+ _("cannot specify number of columns when printing in parallel"));
if (parallel_files && print_across_flag)
- die (EXIT_FAILURE, 0,
- _("cannot specify both printing across and printing in parallel"));
+ error (EXIT_FAILURE, 0,
+ _("cannot specify both printing across and printing in parallel"));
/* Translate some old short options to new/long options.
To meet downward compatibility with other UNIX pr utilities
cleanup ();
if (have_read_stdin && fclose (stdin) == EOF)
- die (EXIT_FAILURE, errno, _("standard input"));
+ error (EXIT_FAILURE, errno, _("standard input"));
main_exit (failed_opens ? EXIT_FAILURE : EXIT_SUCCESS);
}
chars_per_column = useful_chars / columns;
if (chars_per_column < 1)
- die (EXIT_FAILURE, 0, _("page width too narrow"));
+ error (EXIT_FAILURE, 0, _("page width too narrow"));
if (numbered_lines)
{
else if (fclose (p->fp) != 0 && !err)
err = errno;
if (err)
- die (EXIT_FAILURE, err, "%s", quotef (p->name));
+ error (EXIT_FAILURE, err, "%s", quotef (p->name));
if (!parallel_files)
{
print_white_space ();
if (page_number == 0)
- die (EXIT_FAILURE, 0, _("page number overflow"));
+ error (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)
#include "system.h"
#include "cl-strtod.h"
-#include "die.h"
-#include "error.h"
#include "quote.h"
#include "unicodeio.h"
#include "xprintf.h"
++esc_length, ++p)
esc_value = esc_value * 16 + hextobin (*p);
if (esc_length == 0)
- die (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
+ error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
putchar (esc_value);
}
else if (isodigit (*p))
--esc_length, ++p)
{
if (! isxdigit (to_uchar (*p)))
- die (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
+ error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
uni_value = uni_value * 16 + hextobin (*p);
}
/* Error for invalid code points 0000D800 through 0000DFFF inclusive.
Note print_unicode_char() would print the literal \u.. in this case. */
if (uni_value >= 0xd800 && uni_value <= 0xdfff)
- die (EXIT_FAILURE, 0, _("invalid universal character name \\%c%0*x"),
- esc_char, (esc_char == 'u' ? 4 : 8), uni_value);
+ error (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);
}
if (INT_MIN <= width && width <= INT_MAX)
field_width = width;
else
- die (EXIT_FAILURE, 0, _("invalid field width: %s"),
- quote (*argv));
+ error (EXIT_FAILURE, 0, _("invalid field width: %s"),
+ quote (*argv));
++argv;
--argc;
}
precision = -1;
}
else if (INT_MAX < prec)
- die (EXIT_FAILURE, 0, _("invalid precision: %s"),
- quote (*argv));
+ error (EXIT_FAILURE, 0, _("invalid precision: %s"),
+ quote (*argv));
else
precision = prec;
++argv;
{
unsigned char conversion = *f;
+ int speclen = MIN (f + 1 - direc_start, INT_MAX);
if (! ok[conversion])
- die (EXIT_FAILURE, 0,
- _("%.*s: invalid conversion specification"),
- (int) (f + 1 - direc_start), direc_start);
+ error (EXIT_FAILURE, 0,
+ _("%.*s: invalid conversion specification"),
+ speclen, direc_start);
}
print_direc (direc_start, direc_length, *f,
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
-#include "die.h"
#include <regex.h>
#include "argmatch.h"
-#include "error.h"
#include "fadvise.h"
#include "quote.h"
#include "read-file.h"
static void
matcher_error (void)
{
- die (EXIT_FAILURE, errno, _("error in regular expression matcher"));
+ error (EXIT_FAILURE, errno, _("error in regular expression matcher"));
}
/* Unescape STRING in-place. */
message = re_compile_pattern (string, strlen (string), pattern);
if (message)
- die (EXIT_FAILURE, 0, _("%s (for regexp %s)"), message, quote (string));
+ error (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,
block->start = read_file (file_name, 0, &used_length);
if (!block->start)
- die (EXIT_FAILURE, errno, "%s", quotef (using_stdin ? "-" : file_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (using_stdin ? "-" : file_name));
if (using_stdin)
clearerr (stdin);
break;
case 0:
- die (EXIT_FAILURE, 0,
- _("error: regular expression has a match of length zero: %s"),
- quote (context_regex.string));
+ error (EXIT_FAILURE, 0,
+ _("error: regular expression has a match of length zero:"
+ " %s"),
+ quote (context_regex.string));
default:
next_context_start = cursor + context_regs.end[0];
intmax_t tmp;
if (! (xstrtoimax (optarg, nullptr, 0, &tmp, "") == LONGINT_OK
&& 0 < tmp && tmp <= PTRDIFF_MAX))
- die (EXIT_FAILURE, 0, _("invalid gap width: %s"),
- quote (optarg));
+ error (EXIT_FAILURE, 0, _("invalid gap width: %s"),
+ quote (optarg));
gap_size = tmp;
break;
}
intmax_t tmp;
if (! (xstrtoimax (optarg, nullptr, 0, &tmp, "") == LONGINT_OK
&& 0 < tmp && tmp <= PTRDIFF_MAX))
- die (EXIT_FAILURE, 0, _("invalid line width: %s"),
- quote (optarg));
+ error (EXIT_FAILURE, 0, _("invalid line width: %s"),
+ quote (optarg));
line_width = tmp;
break;
}
if (optind < argc)
{
if (! freopen (argv[optind], "w", stdout))
- die (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
+ error (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
optind++;
}
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "quote.h"
#include "root-dev-ino.h"
#include "xgetcwd.h"
dirp = opendir ("..");
if (dirp == nullptr)
- die (EXIT_FAILURE, errno, _("cannot open directory %s"),
- quote (nth_parent (parent_height)));
+ error (EXIT_FAILURE, errno, _("cannot open directory %s"),
+ quote (nth_parent (parent_height)));
fd = dirfd (dirp);
if ((0 <= fd ? fchdir (fd) : chdir ("..")) < 0)
- die (EXIT_FAILURE, errno, _("failed to chdir to %s"),
- quote (nth_parent (parent_height)));
+ error (EXIT_FAILURE, errno, _("failed to chdir to %s"),
+ quote (nth_parent (parent_height)));
if ((0 <= fd ? fstat (fd, &parent_sb) : stat (".", &parent_sb)) < 0)
- die (EXIT_FAILURE, errno, _("failed to stat %s"),
- quote (nth_parent (parent_height)));
+ error (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. */
{
/* Note that this diagnostic serves for both readdir
and closedir failures. */
- die (EXIT_FAILURE, errno, _("reading directory %s"),
- quote (nth_parent (parent_height)));
+ error (EXIT_FAILURE, errno, _("reading directory %s"),
+ quote (nth_parent (parent_height)));
}
if ( ! found)
- die (EXIT_FAILURE, 0,
- _("couldn't find directory entry in %s with matching i-node"),
- quote (nth_parent (parent_height)));
+ error (EXIT_FAILURE, 0,
+ _("couldn't find directory entry in %s with matching i-node"),
+ quote (nth_parent (parent_height)));
*dot_sb = parent_sb;
}
struct stat dot_sb;
if (root_dev_ino == nullptr)
- die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
- quoteaf ("/"));
+ error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
+ quoteaf ("/"));
if (stat (".", &dot_sb) < 0)
- die (EXIT_FAILURE, errno, _("failed to stat %s"), quoteaf ("."));
+ error (EXIT_FAILURE, errno, _("failed to stat %s"), quoteaf ("."));
while (true)
{
#include "system.h"
#include "canonicalize.h"
-#include "error.h"
#include "areadlink.h"
/* The official name of this program (e.g., no 'g' prefix). */
#include "system.h"
#include "canonicalize.h"
-#include "die.h"
-#include "error.h"
#include "relpath.h"
/* The official name of this program (e.g., no 'g' prefix). */
{
struct stat sb;
if (stat (path, &sb) != 0)
- die (EXIT_FAILURE, errno, _("cannot stat %s"), quoteaf (path));
+ error (EXIT_FAILURE, errno, _("cannot stat %s"), quoteaf (path));
return S_ISDIR (sb.st_mode);
}
{
can_relative_to = realpath_canon (relative_to, can_mode);
if (!can_relative_to)
- die (EXIT_FAILURE, errno, "%s", quotef (relative_to));
+ error (EXIT_FAILURE, errno, "%s", quotef (relative_to));
if (need_dir && !isdir (can_relative_to))
- die (EXIT_FAILURE, ENOTDIR, "%s", quotef (relative_to));
+ error (EXIT_FAILURE, ENOTDIR, "%s", quotef (relative_to));
}
if (relative_base == relative_to)
can_relative_base = can_relative_to;
{
char *base = realpath_canon (relative_base, can_mode);
if (!base)
- die (EXIT_FAILURE, errno, "%s", quotef (relative_base));
+ error (EXIT_FAILURE, errno, "%s", quotef (relative_base));
if (need_dir && !isdir (base))
- die (EXIT_FAILURE, ENOTDIR, "%s", quotef (relative_base));
+ error (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))
#include <config.h>
-#include "error.h"
#include "system.h"
#include "relpath.h"
#include "system.h"
#include "assure.h"
-#include "error.h"
#include "file-type.h"
#include "filenamecat.h"
#include "ignore-value.h"
#include "system.h"
#include "argmatch.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "remove.h"
#include "root-dev-ino.h"
#include "yesno.h"
case NO_PRESERVE_ROOT:
if (! STREQ (argv[optind - 1], "--no-preserve-root"))
- die (EXIT_FAILURE, 0,
- _("you may not abbreviate the --no-preserve-root option"));
+ error (EXIT_FAILURE, 0,
+ _("you may not abbreviate the --no-preserve-root option"));
preserve_root = false;
break;
if STREQ (optarg, "all")
x.preserve_all_root = true;
else
- {
- die (EXIT_FAILURE, 0,
+ error (EXIT_FAILURE, 0,
_("unrecognized --preserve-root argument: %s"),
quoteaf (optarg));
- }
}
preserve_root = true;
break;
static struct dev_ino dev_ino_buf;
x.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
if (x.root_dev_ino == nullptr)
- die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
- quoteaf ("/"));
+ error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
+ quoteaf ("/"));
}
uintmax_t n_files = argc - optind;
#include <sys/types.h>
#include "system.h"
-#include "error.h"
#include "prog-fprintf.h"
/* The official name of this program (e.g., no 'g' prefix). */
#include <selinux/context.h>
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "quote.h"
/* The official name of this program (e.g., no 'g' prefix). */
{
case 'r':
if (role)
- die (EXIT_CANCELED, 0, _("multiple roles"));
+ error (EXIT_CANCELED, 0, _("multiple roles"));
role = optarg;
break;
case 't':
if (type)
- die (EXIT_CANCELED, 0, _("multiple types"));
+ error (EXIT_CANCELED, 0, _("multiple types"));
type = optarg;
break;
case 'u':
if (user)
- die (EXIT_CANCELED, 0, _("multiple users"));
+ error (EXIT_CANCELED, 0, _("multiple users"));
user = optarg;
break;
case 'l':
if (range)
- die (EXIT_CANCELED, 0, _("multiple levelranges"));
+ error (EXIT_CANCELED, 0, _("multiple levelranges"));
range = optarg;
break;
case 'c':
if (argc - optind == 0)
{
if (getcon (&cur_context) < 0)
- die (EXIT_CANCELED, errno, _("failed to get current context"));
+ error (EXIT_CANCELED, errno, _("failed to get current context"));
fputs (cur_context, stdout);
fputc ('\n', stdout);
return EXIT_SUCCESS;
}
if (is_selinux_enabled () != 1)
- die (EXIT_CANCELED, 0, _("%s may be used only on a SELinux kernel"),
- program_name);
+ error (EXIT_CANCELED, 0, _("%s may be used only on a SELinux kernel"),
+ program_name);
if (context)
{
con = context_new (context);
if (!con)
- die (EXIT_CANCELED, errno, _("failed to create security context: %s"),
- quote (context));
+ error (EXIT_CANCELED, errno, _("failed to create security context: %s"),
+ quote (context));
}
else
{
if (getcon (&cur_context) < 0)
- die (EXIT_CANCELED, errno, _("failed to get current context"));
+ error (EXIT_CANCELED, 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)
- die (EXIT_CANCELED, errno,
- _("failed to get security context of %s"),
- quoteaf (argv[optind]));
+ error (EXIT_CANCELED, 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)
- die (EXIT_CANCELED, errno, _("failed to compute a new context"));
+ error (EXIT_CANCELED, errno, _("failed to compute a new context"));
/* free contexts */
freecon (file_context);
freecon (cur_context);
con = context_new (cur_context);
if (!con)
- die (EXIT_CANCELED, errno, _("failed to create security context: %s"),
- quote (cur_context));
+ error (EXIT_CANCELED, errno, _("failed to create security context: %s"),
+ quote (cur_context));
if (user && context_user_set (con, user))
- die (EXIT_CANCELED, errno, _("failed to set new user: %s"),
- quote (user));
+ error (EXIT_CANCELED, errno, _("failed to set new user: %s"),
+ quote (user));
if (type && context_type_set (con, type))
- die (EXIT_CANCELED, errno, _("failed to set new type: %s"),
- quote (type));
+ error (EXIT_CANCELED, errno, _("failed to set new type: %s"),
+ quote (type));
if (range && context_range_set (con, range))
- die (EXIT_CANCELED, errno, _("failed to set new range: %s"),
- quote (range));
+ error (EXIT_CANCELED, errno, _("failed to set new range: %s"),
+ quote (range));
if (role && context_role_set (con, role))
- die (EXIT_CANCELED, errno, _("failed to set new role: %s"),
- quote (role));
+ error (EXIT_CANCELED, errno, _("failed to set new role: %s"),
+ quote (role));
}
if (security_check_context (context_str (con)) < 0)
- die (EXIT_CANCELED, errno, _("invalid context: %s"),
- quote (context_str (con)));
+ error (EXIT_CANCELED, errno, _("invalid context: %s"),
+ quote (context_str (con)));
if (setexeccon (context_str (con)) != 0)
- die (EXIT_CANCELED, errno, _("unable to set security context %s"),
- quote (context_str (con)));
+ error (EXIT_CANCELED, errno, _("unable to set security context %s"),
+ quote (context_str (con)));
if (cur_context != nullptr)
freecon (cur_context);
#include <sys/types.h>
#include "system.h"
-#include "die.h"
#include "cl-strtod.h"
-#include "error.h"
#include "quote.h"
#include "xstrtod.h"
for (i = 0; ! (fmt[i] == '%' && fmt[i + 1] != '%'); i += (fmt[i] == '%') + 1)
{
if (!fmt[i])
- die (EXIT_FAILURE, 0,
- _("format %s has no %% directive"), quote (fmt));
+ error (EXIT_FAILURE, 0,
+ _("format %s has no %% directive"), quote (fmt));
prefix_len++;
}
has_L = (fmt[i] == 'L');
i += has_L;
if (fmt[i] == '\0')
- die (EXIT_FAILURE, 0, _("format %s ends in %%"), quote (fmt));
+ error (EXIT_FAILURE, 0, _("format %s ends in %%"), quote (fmt));
if (! strchr ("efgaEFGA", fmt[i]))
- die (EXIT_FAILURE, 0,
- _("format %s has unknown %%%c directive"), quote (fmt), fmt[i]);
+ error (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] != '%')
- die (EXIT_FAILURE, 0, _("format %s has too many %% directives"),
- quote (fmt));
+ error (EXIT_FAILURE, 0, _("format %s has too many %% directives"),
+ quote (fmt));
else if (fmt[i])
suffix_len++;
else
{
/* FIXME: consider option to silently ignore errno=EPIPE */
clearerr (stdout);
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
/* Actually print the sequence of numbers in the specified range, with the
#include <config.h>
#include "system.h"
-#include "error.h"
#include "quote.h"
#include "set-fields.h"
#include "argmatch.h"
#include "assure.h"
#include "xdectoint.h"
-#include "die.h"
-#include "error.h"
#include "fcntl--.h"
#include "human.h"
#include "randint.h"
case RANDOM_SOURCE_OPTION:
if (random_source && !STREQ (random_source, optarg))
- die (EXIT_FAILURE, 0, _("multiple random sources specified"));
+ error (EXIT_FAILURE, 0, _("multiple random sources specified"));
random_source = optarg;
break;
randint_source = randint_all_new (random_source, SIZE_MAX);
if (! randint_source)
- die (EXIT_FAILURE, errno, "%s",
- quotef (random_source ? random_source : "getrandom"));
+ error (EXIT_FAILURE, errno, "%s",
+ quotef (random_source ? random_source : "getrandom"));
atexit (clear_random_data);
for (i = 0; i < n_files; i++)
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "getopt.h"
#include "linebuffer.h"
while (readlinebuffer_delim (line, in, eolbyte) != nullptr && n_lines++);
if (! n_lines)
- die (EXIT_FAILURE, EOVERFLOW, _("too many input lines"));
+ error (EXIT_FAILURE, EOVERFLOW, _("too many input lines"));
freebuffer (&dummy);
}
/* no more input lines, or an input error. */
if (ferror (in))
- die (EXIT_FAILURE, errno, _("read error"));
+ error (EXIT_FAILURE, errno, _("read error"));
*out_rsrv = rsrv;
return MIN (k, n_lines);
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, 0, &used)))
- die (EXIT_FAILURE, errno, _("read error"));
+ error (EXIT_FAILURE, errno, _("read error"));
if (used && buf[used - 1] != eolbyte)
buf[used++] = eolbyte;
case 'i':
{
if (input_range)
- die (EXIT_FAILURE, 0, _("multiple -i options specified"));
+ error (EXIT_FAILURE, 0, _("multiple -i options specified"));
input_range = true;
uintmax_t u;
n_lines = hi_input - lo_input + 1;
if (err != LONGINT_OK || (lo_input <= hi_input) == (n_lines == 0))
- die (EXIT_FAILURE, err == LONGINT_OVERFLOW ? EOVERFLOW : 0,
- "%s: %s", _("invalid input range"), quote (optarg));
+ error (EXIT_FAILURE, err == LONGINT_OVERFLOW ? EOVERFLOW : 0,
+ "%s: %s", _("invalid input range"), quote (optarg));
}
break;
if (e == LONGINT_OK)
head_lines = MIN (head_lines, argval);
else if (e != LONGINT_OVERFLOW)
- die (EXIT_FAILURE, 0, _("invalid line count: %s"),
- quote (optarg));
+ error (EXIT_FAILURE, 0, _("invalid line count: %s"),
+ quote (optarg));
}
break;
case 'o':
if (outfile && !STREQ (outfile, optarg))
- die (EXIT_FAILURE, 0, _("multiple output files specified"));
+ error (EXIT_FAILURE, 0, _("multiple output files specified"));
outfile = optarg;
break;
case RANDOM_SOURCE_OPTION:
if (random_source && !STREQ (random_source, optarg))
- die (EXIT_FAILURE, 0, _("multiple random sources specified"));
+ error (EXIT_FAILURE, 0, _("multiple random sources specified"));
random_source = optarg;
break;
if (n_operands == 1
&& ! (STREQ (operand[0], "-")
|| freopen (operand[0], "r", stdin)))
- die (EXIT_FAILURE, errno, "%s", quotef (operand[0]));
+ error (EXIT_FAILURE, errno, "%s", quotef (operand[0]));
fadvise (stdin, FADVISE_SEQUENTIAL);
? SIZE_MAX
: randperm_bound (ahead_lines, n_lines)));
if (! randint_source)
- die (EXIT_FAILURE, errno, "%s",
- quotef (random_source ? random_source : "getrandom"));
+ error (EXIT_FAILURE, errno, "%s",
+ quotef (random_source ? random_source : "getrandom"));
if (use_reservoir_sampling)
{
doesn't have to worry about opening something other than
stdin. */
if (! (head_lines == 0 || echo || input_range || fclose (stdin) == 0))
- die (EXIT_FAILURE, errno, _("read error"));
+ error (EXIT_FAILURE, errno, _("read error"));
if (!repeat)
permutation = randperm_new (randint_source, ahead_lines, n_lines);
if (outfile && ! freopen (outfile, "w", stdout))
- die (EXIT_FAILURE, errno, "%s", quotef (outfile));
+ error (EXIT_FAILURE, errno, "%s", quotef (outfile));
/* Generate output according to requested method */
if (repeat)
else
{
if (n_lines == 0)
- die (EXIT_FAILURE, 0, _("no lines to repeat"));
+ error (EXIT_FAILURE, 0, _("no lines to repeat"));
if (input_range)
i = write_random_numbers (randint_source, ahead_lines,
lo_input, hi_input, eolbyte);
}
if (i != 0)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
main_exit (EXIT_SUCCESS);
}
#include "system.h"
#include "cl-strtod.h"
-#include "die.h"
-#include "error.h"
#include "long-options.h"
#include "quote.h"
#include "xnanosleep.h"
usage (EXIT_FAILURE);
if (xnanosleep (seconds))
- die (EXIT_FAILURE, errno, _("cannot read realtime clock"));
+ error (EXIT_FAILURE, errno, _("cannot read realtime clock"));
return EXIT_SUCCESS;
}
#include "system.h"
#include "argmatch.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "filevercmp.h"
#include "flexmember.h"
static void
sort_die (char const *message, char const *file)
{
- die (SORT_FAILURE, errno, "%s: %s", message,
- quotef (file ? file : _("standard output")));
+ error (SORT_FAILURE, errno, "%s: %s", message,
+ quotef (file ? file : _("standard output")));
}
void
pid_t cpid = waitpid ((pid ? pid : -1), &status, (pid ? 0 : WNOHANG));
if (cpid < 0)
- die (SORT_FAILURE, errno, _("waiting for %s [-d]"),
- quoteaf (compress_program));
+ error (SORT_FAILURE, errno, _("waiting for %s [-d]"),
+ quoteaf (compress_program));
else if (0 < cpid && (0 < pid || delete_proc (cpid)))
{
if (! WIFEXITED (status) || WEXITSTATUS (status))
- die (SORT_FAILURE, 0, _("%s [-d] terminated abnormally"),
- quoteaf (compress_program));
+ error (SORT_FAILURE, 0, _("%s [-d] terminated abnormally"),
+ quoteaf (compress_program));
--nprocs;
}
if (fd < 0)
{
if (! (survive_fd_exhaustion && errno == EMFILE))
- die (SORT_FAILURE, errno, _("cannot create temporary file in %s"),
- quoteaf (temp_dir));
+ error (SORT_FAILURE, errno, _("cannot create temporary file in %s"),
+ quoteaf (temp_dir));
free (node);
node = nullptr;
}
int ftruncate_errno = errno;
struct stat *outst = get_outstatus ();
if (!outst || S_ISREG (outst->st_mode) || S_TYPEISSHM (outst))
- die (SORT_FAILURE, ftruncate_errno, _("%s: error truncating"),
- quotef (file));
+ error (SORT_FAILURE, ftruncate_errno, _("%s: error truncating"),
+ quotef (file));
}
fp = stdout;
}
{
case -1:
if (errno != EMFILE)
- die (SORT_FAILURE, errno, _("couldn't create process for %s -d"),
- quoteaf (compress_program));
+ error (SORT_FAILURE, errno, _("couldn't create process for %s -d"),
+ quoteaf (compress_program));
close (tempfd);
errno = EMFILE;
break;
{
error (0, 0, _("invalid --%s argument %s"),
long_options[oi].name, quote (s));
- die (SORT_FAILURE, 0,
- _("minimum --%s argument is %s"),
- long_options[oi].name, quote ("2"));
+ error (SORT_FAILURE, 0,
+ _("minimum --%s argument is %s"),
+ long_options[oi].name, quote ("2"));
}
else if (max_nmerge < nmerge)
{
char max_nmerge_buf[INT_BUFSIZE_BOUND (max_nmerge)];
error (0, 0, _("--%s argument %s too large"),
long_options[oi].name, quote (s));
- die (SORT_FAILURE, 0,
- _("maximum --%s argument with current rlimit is %s"),
- long_options[oi].name,
- uinttostr (max_nmerge, max_nmerge_buf));
+ error (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);
if (SIZE_MAX < nthreads)
nthreads = SIZE_MAX;
if (nthreads == 0)
- die (SORT_FAILURE, 0, _("number in parallel must be nonzero"));
+ error (SORT_FAILURE, 0, _("number in parallel must be nonzero"));
return nthreads;
}
{
error (0, errno, _("string transformation failed"));
error (0, 0, _("set LC_ALL='C' to work around the problem"));
- die (SORT_FAILURE, 0,
- _("the untransformed string was %s"),
- quotearg_n_style (0, locale_quoting_style, src));
+ error (SORT_FAILURE, 0,
+ _("the untransformed string was %s"),
+ quotearg_n_style (0, locale_quoting_style, src));
}
return translated_size;
static void
badfieldspec (char const *spec, char const *msgid)
{
- die (SORT_FAILURE, 0, _("%s: invalid field specification %s"),
- _(msgid), quote (spec));
+ error (SORT_FAILURE, 0, _("%s: invalid field specification %s"),
+ _(msgid), quote (spec));
}
/* Report incompatible options. */
static void
incompatible_options (char const *opts)
{
- die (SORT_FAILURE, 0, _("options '-%s' are incompatible"), (opts));
+ error (SORT_FAILURE, 0, _("options '-%s' are incompatible"), (opts));
}
/* Check compatibility of ordering options. */
case LONGINT_INVALID:
if (msgid)
- die (SORT_FAILURE, 0, _("%s: invalid count at start of %s"),
- _(msgid), quote (string));
+ error (SORT_FAILURE, 0, _("%s: invalid count at start of %s"),
+ _(msgid), quote (string));
return nullptr;
}
case COMPRESS_PROGRAM_OPTION:
if (compress_program && !STREQ (compress_program, optarg))
- die (SORT_FAILURE, 0, _("multiple compress programs specified"));
+ error (SORT_FAILURE, 0, _("multiple compress programs specified"));
compress_program = optarg;
break;
case 'o':
if (outfile && !STREQ (outfile, optarg))
- die (SORT_FAILURE, 0, _("multiple output files specified"));
+ error (SORT_FAILURE, 0, _("multiple output files specified"));
outfile = optarg;
break;
case RANDOM_SOURCE_OPTION:
if (random_source && !STREQ (random_source, optarg))
- die (SORT_FAILURE, 0, _("multiple random sources specified"));
+ error (SORT_FAILURE, 0, _("multiple random sources specified"));
random_source = optarg;
break;
{
char newtab = optarg[0];
if (! newtab)
- die (SORT_FAILURE, 0, _("empty tab"));
+ error (SORT_FAILURE, 0, _("empty tab"));
if (optarg[1])
{
if (STREQ (optarg, "\\0"))
"multi-character tab" instead of "multibyte tab", so
that the diagnostic's wording does not need to be
changed once multibyte characters are supported. */
- die (SORT_FAILURE, 0, _("multi-character tab %s"),
- quote (optarg));
+ error (SORT_FAILURE, 0, _("multi-character tab %s"),
+ quote (optarg));
}
}
if (tab != TAB_DEFAULT && tab != newtab)
- die (SORT_FAILURE, 0, _("incompatible tabs"));
+ error (SORT_FAILURE, 0, _("incompatible tabs"));
tab = newtab;
}
break;
readtokens0_init (&tok);
if (! readtokens0 (stream, &tok))
- die (SORT_FAILURE, 0, _("cannot read file names from %s"),
- quoteaf (files_from));
+ error (SORT_FAILURE, 0, _("cannot read file names from %s"),
+ quoteaf (files_from));
xfclose (stream, files_from);
if (tok.n_tok)
for (size_t i = 0; i < nfiles; i++)
{
if (STREQ (files[i], "-"))
- die (SORT_FAILURE, 0, _("when reading file names from stdin, "
- "no file name of %s allowed"),
- quoteaf (files[i]));
+ error (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;
- die (SORT_FAILURE, 0,
- _("%s:%lu: invalid zero-length file name"),
- quotef (files_from), file_number);
+ error (SORT_FAILURE, 0,
+ _("%s:%lu: invalid zero-length file name"),
+ quotef (files_from), file_number);
}
}
}
else
- die (SORT_FAILURE, 0, _("no input from %s"),
- quoteaf (files_from));
+ error (SORT_FAILURE, 0, _("no input from %s"),
+ quoteaf (files_from));
}
/* Inheritance of global options to individual keys. */
if (checkonly)
{
if (nfiles > 1)
- die (SORT_FAILURE, 0, _("extra operand %s not allowed with -%c"),
- quoteaf (files[1]), checkonly);
+ error (SORT_FAILURE, 0, _("extra operand %s not allowed with -%c"),
+ quoteaf (files[1]), checkonly);
if (outfile)
{
#include "system.h"
#include "alignalloc.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "fd-reopen.h"
#include "fcntl--.h"
if (suffix_length) /* set by user */
{
if (suffix_length < suffix_length_needed)
- {
- die (EXIT_FAILURE, 0,
+ error (EXIT_FAILURE, 0,
_("the suffix length needs to be at least %d"),
suffix_length_needed);
- }
suffix_auto = false;
return;
}
char *dir = dir_name (outfile);
long name_max = pathconf (dir, _PC_NAME_MAX);
if (0 <= name_max && name_max < base_len (last_component (outfile)))
- die (EXIT_FAILURE, ENAMETOOLONG, "%s", quotef (outfile));
+ error (EXIT_FAILURE, ENAMETOOLONG, "%s", quotef (outfile));
free (dir);
}
#endif
sufindex[i] = 0;
outfile_mid[i] = suffix_alphabet[sufindex[i]];
}
- die (EXIT_FAILURE, 0, _("output file suffixes exhausted"));
+ error (EXIT_FAILURE, 0, _("output file suffixes exhausted"));
}
}
return fd;
struct stat out_stat_buf;
if (fstat (fd, &out_stat_buf) != 0)
- die (EXIT_FAILURE, errno, _("failed to stat %s"), quoteaf (name));
+ error (EXIT_FAILURE, errno, _("failed to stat %s"), quoteaf (name));
if (SAME_INODE (in_stat_buf, out_stat_buf))
- die (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"),
- quoteaf (name));
+ error (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"),
+ quoteaf (name));
bool regularish
= S_ISREG (out_stat_buf.st_mode) || S_TYPEISSHM (&out_stat_buf);
if (! (regularish && out_stat_buf.st_size == 0)
&& ftruncate (fd, 0) < 0 && regularish)
- die (EXIT_FAILURE, errno, _("%s: error truncating"), quotef (name));
+ error (EXIT_FAILURE, errno, _("%s: error truncating"), quotef (name));
return fd;
}
if (shell_prog == nullptr)
shell_prog = "/bin/sh";
if (setenv ("FILE", name, 1) != 0)
- die (EXIT_FAILURE, errno,
- _("failed to set FILE environment variable"));
+ error (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)
- die (EXIT_FAILURE, errno, _("failed to create pipe"));
+ error (EXIT_FAILURE, errno, _("failed to create pipe"));
child_pid = fork ();
if (child_pid == 0)
{
reading an EOF on the corresponding read-pipe. */
for (j = 0; j < n_open_pipes; ++j)
if (close (open_pipes[j]) != 0)
- die (EXIT_FAILURE, errno, _("closing prior pipe"));
+ error (EXIT_FAILURE, errno, _("closing prior pipe"));
if (close (fd_pair[1]))
- die (EXIT_FAILURE, errno, _("closing output pipe"));
+ error (EXIT_FAILURE, errno, _("closing output pipe"));
if (fd_pair[0] != STDIN_FILENO)
{
if (dup2 (fd_pair[0], STDIN_FILENO) != STDIN_FILENO)
- die (EXIT_FAILURE, errno, _("moving input pipe"));
+ error (EXIT_FAILURE, errno, _("moving input pipe"));
if (close (fd_pair[0]) != 0)
- die (EXIT_FAILURE, errno, _("closing input pipe"));
+ error (EXIT_FAILURE, errno, _("closing input pipe"));
}
if (default_SIGPIPE)
signal (SIGPIPE, SIG_DFL);
execl (shell_prog, last_component (shell_prog), "-c",
filter_command, (char *) nullptr);
- die (EXIT_FAILURE, errno, _("failed to run command: \"%s -c %s\""),
- shell_prog, filter_command);
+ error (EXIT_FAILURE, errno, _("failed to run command: \"%s -c %s\""),
+ shell_prog, filter_command);
}
if (child_pid < 0)
- die (EXIT_FAILURE, errno, _("fork system call failed"));
+ error (EXIT_FAILURE, errno, _("fork system call failed"));
if (close (fd_pair[0]) != 0)
- die (EXIT_FAILURE, errno, _("failed to close input pipe"));
+ error (EXIT_FAILURE, errno, _("failed to close input pipe"));
filter_pid = child_pid;
if (n_open_pipes == open_pipes_alloc)
open_pipes = xpalloc (open_pipes, &open_pipes_alloc, 1,
closeout (FILE *fp, int fd, pid_t pid, char const *name)
{
if (fp != nullptr && fclose (fp) != 0 && ! ignorable (errno))
- die (EXIT_FAILURE, errno, "%s", quotef (name));
+ error (EXIT_FAILURE, errno, "%s", quotef (name));
if (fd >= 0)
{
if (fp == nullptr && close (fd) < 0)
- die (EXIT_FAILURE, errno, "%s", quotef (name));
+ error (EXIT_FAILURE, errno, "%s", quotef (name));
int j;
for (j = 0; j < n_open_pipes; ++j)
{
{
int wstatus;
if (waitpid (pid, &wstatus, 0) < 0)
- die (EXIT_FAILURE, errno, _("waiting for child process"));
+ error (EXIT_FAILURE, errno, _("waiting for child process"));
else if (WIFSIGNALED (wstatus))
{
int sig = WTERMSIG (wstatus);
else
{
/* shouldn't happen. */
- die (EXIT_FAILURE, 0,
- _("unknown status from command (0x%X)"), wstatus + 0u);
+ error (EXIT_FAILURE, 0,
+ _("unknown status from command (0x%X)"), wstatus + 0u);
}
}
}
next_file_name ();
output_desc = create (outfile);
if (output_desc < 0)
- die (EXIT_FAILURE, errno, "%s", quotef (outfile));
+ error (EXIT_FAILURE, errno, "%s", quotef (outfile));
}
if (full_write (output_desc, bp, bytes) == bytes)
else
{
if (! ignorable (errno))
- die (EXIT_FAILURE, errno, "%s", quotef (outfile));
+ error (EXIT_FAILURE, errno, "%s", quotef (outfile));
return false;
}
}
n_read = read (STDIN_FILENO, buf, bufsize);
if (n_read < 0)
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
eof = n_read == 0;
}
char *bp_out = buf;
{
n_read = read (STDIN_FILENO, buf, bufsize);
if (n_read < 0)
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
bp = bp_out = buf;
eob = bp + n_read;
*eob = eolchar;
{
n_read = read (STDIN_FILENO, buf, bufsize);
if (n_read < 0)
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
idx_t n_left = n_read;
char *sob = buf;
while (n_left)
{
if (initial_read < start
&& lseek (STDIN_FILENO, start - initial_read, SEEK_CUR) < 0)
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
initial_read = -1;
}
n_written = start;
n_read = read (STDIN_FILENO, buf,
MIN (bufsize, file_size - n_written));
if (n_read < 0)
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
}
if (n_read == 0)
break; /* eof. */
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)
- die (EXIT_FAILURE, errno, "%s", _("write error"));
+ error (EXIT_FAILURE, errno, "%s", _("write error"));
}
else if (! k)
cwrite (new_file_flag, bp, to_write);
{
if (initial_read < start
&& lseek (STDIN_FILENO, start - initial_read, SEEK_CUR) < 0)
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
initial_read = -1;
}
{
n_read = read (STDIN_FILENO, buf, bufsize);
if (n_read < 0)
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (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))
- die (EXIT_FAILURE, errno, "%s", quotef ("-"));
+ error (EXIT_FAILURE, errno, "%s", quotef ("-"));
start += n_read;
}
}
break;
if (!(errno == EMFILE || errno == ENFILE))
- die (EXIT_FAILURE, errno, "%s", quotef (files[i_check].of_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (files[i_check].of_name));
file_limit = true;
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)
- die (EXIT_FAILURE, errno, "%s",
- quotef (files[i_check].of_name));
+ error (EXIT_FAILURE, errno, "%s",
+ quotef (files[i_check].of_name));
}
if (fclose (files[i_reopen].ofile) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (files[i_reopen].of_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (files[i_reopen].of_name));
files[i_reopen].ofile = nullptr;
files[i_reopen].ofd = OFD_APPEND;
}
files[i_check].ofd = fd;
FILE *ofile = fdopen (fd, "a");
if (!ofile)
- die (EXIT_FAILURE, errno, "%s", quotef (files[i_check].of_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (files[i_check].of_name));
files[i_check].ofile = ofile;
files[i_check].opid = filter_pid;
filter_pid = 0;
char *bp = buf, *eob;
ssize_t n_read = read (STDIN_FILENO, buf, bufsize);
if (n_read < 0)
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
else if (n_read == 0)
break; /* eof. */
eob = buf + n_read;
if (line_no == k && unbuffered)
{
if (full_write (STDOUT_FILENO, bp, to_write) != to_write)
- die (EXIT_FAILURE, errno, "%s", _("write error"));
+ error (EXIT_FAILURE, errno, "%s", _("write error"));
}
else if (line_no == k && fwrite (bp, to_write, 1, stdout) != 1)
{
clearerr (stdout); /* To silence close_stdout(). */
- die (EXIT_FAILURE, errno, "%s", _("write error"));
+ error (EXIT_FAILURE, errno, "%s", _("write error"));
}
if (next)
line_no = (line_no == n) ? 1 : line_no + 1;
an 8% performance benefit, due to reduced data copying. */
if (full_write (files[i_file].ofd, bp, to_write) != to_write
&& ! ignorable (errno))
- {
- die (EXIT_FAILURE, errno, "%s",
+ error (EXIT_FAILURE, errno, "%s",
quotef (files[i_file].of_name));
- }
}
else if (fwrite (bp, to_write, 1, files[i_file].ofile) != 1
&& ! ignorable (errno))
- {
- die (EXIT_FAILURE, errno, "%s",
+ error (EXIT_FAILURE, errno, "%s",
quotef (files[i_file].of_name));
- }
if (! ignorable (errno))
wrote = true;
if (file_limit)
{
if (fclose (files[i_file].ofile) != 0)
- {
- die (EXIT_FAILURE, errno, "%s",
+ error (EXIT_FAILURE, errno, "%s",
quotef (files[i_file].of_name));
- }
files[i_file].ofile = nullptr;
files[i_file].ofd = OFD_APPEND;
}
static _Noreturn void
strtoint_die (char const *msgid, char const *arg)
{
- die (EXIT_FAILURE, errno == EINVAL ? 0 : errno, "%s: %s",
- gettext (msgid), quote (arg));
+ error (EXIT_FAILURE, errno == EINVAL ? 0 : errno, "%s: %s",
+ gettext (msgid), quote (arg));
}
/* Use OVERFLOW_OK when it is OK to ignore LONGINT_OVERFLOW errors, since the
*n_units = parse_n_units (argend + 1, "",
N_("invalid number of chunks"));
if (! (0 < *k_units && *k_units <= *n_units))
- die (EXIT_FAILURE, 0, "%s: %s", _("invalid chunk number"),
- quote_mem (arg, argend - arg));
+ error (EXIT_FAILURE, 0, "%s: %s", _("invalid chunk number"),
+ quote_mem (arg, argend - arg));
}
else if (! (e <= OVERFLOW_OK && 0 < *n_units))
strtoint_die (N_("invalid number of chunks"), arg);
{
char neweol = optarg[0];
if (! neweol)
- die (EXIT_FAILURE, 0, _("empty record separator"));
+ error (EXIT_FAILURE, 0, _("empty record separator"));
if (optarg[1])
{
if (STREQ (optarg, "\\0"))
"multi-character tab" instead of "multibyte tab", so
that the diagnostic's wording does not need to be
changed once multibyte characters are supported. */
- die (EXIT_FAILURE, 0, _("multi-character separator %s"),
- quote (optarg));
+ error (EXIT_FAILURE, 0, _("multi-character separator %s"),
+ quote (optarg));
}
}
/* Make it explicit we don't support multiple separators. */
if (0 <= eolchar && neweol != eolchar)
{
- die (EXIT_FAILURE, 0,
- _("multiple separator characters specified"));
+ error (EXIT_FAILURE, 0,
+ _("multiple separator characters specified"));
}
eolchar = neweol;
/* Open the input file. */
if (! STREQ (infile, "-")
&& fd_reopen (STDIN_FILENO, infile, O_RDONLY, 0) < 0)
- die (EXIT_FAILURE, errno, _("cannot open %s for reading"),
- quoteaf (infile));
+ error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
+ quoteaf (infile));
/* Binary I/O is safer when byte counts are used. */
xset_binary_mode (STDIN_FILENO, O_BINARY);
/* Get the optimal block size of input device and make a buffer. */
if (fstat (STDIN_FILENO, &in_stat_buf) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
if (in_blk_size == 0)
{
file_size = input_file_size (STDIN_FILENO, &in_stat_buf,
buf, in_blk_size);
if (file_size < 0)
- die (EXIT_FAILURE, errno, _("%s: cannot determine file size"),
- quotef (infile));
+ error (EXIT_FAILURE, errno, _("%s: cannot determine file size"),
+ quotef (infile));
initial_read = MIN (file_size, in_blk_size);
}
}
if (close (STDIN_FILENO) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
closeout (nullptr, output_desc, filter_pid, outfile);
main_exit (EXIT_SUCCESS);
#include "areadlink.h"
#include "argmatch.h"
-#include "die.h"
-#include "error.h"
#include "file-type.h"
#include "filemode.h"
#include "fs.h"
{
dest[len] = fmt_char;
dest[len + 1] = '\0';
- die (EXIT_FAILURE, 0, _("%s: invalid directive"),
- quote (dest));
+ error (EXIT_FAILURE, 0, _("%s: invalid directive"),
+ quote (dest));
}
putchar ('%');
break;
#include "system.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "filenamecat.h"
#include "quote.h"
#include "xreadlink.h"
++path;
if ( ! *path)
- die (EXIT_CANCELED, 0, _("failed to find %s"), quote (LIB_NAME));
+ error (EXIT_CANCELED, 0, _("failed to find %s"), quote (LIB_NAME));
}
/* FIXME: Do we need to support libstdbuf.dll, c:, '\' separators etc? */
#endif
if (ret != 0)
- {
- die (EXIT_CANCELED, errno,
+ error (EXIT_CANCELED, errno,
_("failed to update the environment with %s"),
quote (LD_PRELOAD));
- }
}
/* Populate environ with _STDBUF_I=$MODE _STDBUF_O=$MODE _STDBUF_E=$MODE.
xalloc_die ();
if (putenv (var) != 0)
- {
- die (EXIT_CANCELED, errno,
+ error (EXIT_CANCELED, errno,
_("failed to update the environment with %s"),
quote (var));
- }
env_set = true;
}
if (!STREQ (optarg, "L")
&& parse_size (optarg, &stdbuf[opt_fileno].size) == -1)
- die (EXIT_CANCELED, errno, _("invalid mode %s"), quote (optarg));
+ error (EXIT_CANCELED, errno, _("invalid mode %s"), quote (optarg));
break;
#include "system.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "fd-reopen.h"
#include "quote.h"
#include "xdectoint.h"
continue;
if (ioctl (STDIN_FILENO, TIOCEXT, &val) != 0)
- {
- die (EXIT_FAILURE, errno, _("%s: error setting %s"),
+ error (EXIT_FAILURE, errno, _("%s: error setting %s"),
quotef_n (0, device_name), quote_n (1, arg));
- }
}
#endif
#ifdef TIOCGWINSZ
case 'F':
if (file_name)
- die (EXIT_FAILURE, 0, _("only one device may be specified"));
+ error (EXIT_FAILURE, 0, _("only one device may be specified"));
file_name = optarg;
break;
/* Specifying both -a and -g gets an error. */
if (verbose_output && recoverable_output)
- die (EXIT_FAILURE, 0,
- _("the options for verbose and stty-readable output styles are\n"
- "mutually exclusive"));
+ error (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))
- die (EXIT_FAILURE, 0,
- _("when specifying an output style, modes may not be set"));
+ error (EXIT_FAILURE, 0,
+ _("when specifying an output style, modes may not be set"));
device_name = file_name ? file_name : _("standard input");
{
int fdflags;
if (fd_reopen (STDIN_FILENO, device_name, O_RDONLY | O_NONBLOCK, 0) < 0)
- die (EXIT_FAILURE, errno, "%s", quotef (device_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (device_name));
if ((fdflags = fcntl (STDIN_FILENO, F_GETFL)) == -1
|| fcntl (STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
- die (EXIT_FAILURE, errno, _("%s: couldn't reset non-blocking mode"),
- quotef (device_name));
+ error (EXIT_FAILURE, errno, _("%s: couldn't reset non-blocking mode"),
+ quotef (device_name));
}
if (tcgetattr (STDIN_FILENO, &mode))
- die (EXIT_FAILURE, errno, "%s", quotef (device_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (device_name));
if (verbose_output || recoverable_output || noargs)
{
static struct termios new_mode;
if (tcsetattr (STDIN_FILENO, tcsetattr_options, &mode))
- die (EXIT_FAILURE, errno, "%s", quotef (device_name));
+ error (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
compare them to the requested ones. */
if (tcgetattr (STDIN_FILENO, &new_mode))
- die (EXIT_FAILURE, errno, "%s", quotef (device_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (device_name));
if (! eq_mode (&mode, &new_mode))
{
}
}
- die (EXIT_FAILURE, 0,
- _("%s: unable to perform all requested operations"),
- quotef (device_name));
+ error (EXIT_FAILURE, 0,
+ _("%s: unable to perform all requested operations"),
+ quotef (device_name));
}
}
{
last_ibaud = baud;
if (cfsetispeed (mode, baud))
- die (EXIT_FAILURE, 0, "unsupported ispeed %s", quoteaf (arg));
+ error (EXIT_FAILURE, 0, "unsupported ispeed %s", quoteaf (arg));
}
if (type == output_speed || type == both_speeds)
{
last_obaud = baud;
if (cfsetospeed (mode, baud))
- die (EXIT_FAILURE, 0, "unsupported ospeed %s", quoteaf (arg));
+ error (EXIT_FAILURE, 0, "unsupported ospeed %s", quoteaf (arg));
}
}
if (get_win_size (STDIN_FILENO, &win))
{
if (errno != EINVAL)
- die (EXIT_FAILURE, errno, "%s", quotef (device_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (device_name));
memset (&win, 0, sizeof (win));
}
win.ws_col = 1;
if (ioctl (STDIN_FILENO, TIOCSWINSZ, (char *) &win))
- die (EXIT_FAILURE, errno, "%s", quotef (device_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (device_name));
if (ioctl (STDIN_FILENO, TIOCSSIZE, (char *) &ttysz))
- die (EXIT_FAILURE, errno, "%s", quotef (device_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (device_name));
return;
}
# endif
if (ioctl (STDIN_FILENO, TIOCSWINSZ, (char *) &win))
- die (EXIT_FAILURE, errno, "%s", quotef (device_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (device_name));
}
static void
if (get_win_size (STDIN_FILENO, &win))
{
if (errno != EINVAL)
- die (EXIT_FAILURE, errno, "%s", quotef (device_name));
+ error (EXIT_FAILURE, errno, "%s", quotef (device_name));
if (!fancy)
- die (EXIT_FAILURE, 0,
- _("%s: no size information for this device"),
- quotef (device_name));
+ error (EXIT_FAILURE, 0,
+ _("%s: no size information for this device"),
+ quotef (device_name));
}
else
{
{
if (cfgetispeed (mode) != last_ibaud
|| cfgetospeed (mode) != last_obaud)
- die (EXIT_FAILURE, 0,
- _("asymmetric input (%lu), output (%lu) speeds not supported"),
- baud_to_value (last_ibaud), baud_to_value (last_obaud));
+ error (EXIT_FAILURE, 0,
+ _("asymmetric input (%lu), output (%lu) speeds not supported"),
+ baud_to_value (last_ibaud), baud_to_value (last_obaud));
}
}
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "sync"
args_specified = optind < argc;
if (arg_data && arg_file_system)
- {
- die (EXIT_FAILURE, 0,
+ error (EXIT_FAILURE, 0,
_("cannot specify both --data and --file-system"));
- }
if (!args_specified && arg_data)
- die (EXIT_FAILURE, 0, _("--data needs at least one argument"));
+ error (EXIT_FAILURE, 0, _("--data needs at least one argument"));
if (! args_specified || (arg_file_system && ! HAVE_SYNCFS))
mode = MODE_SYNC;
_Noreturn void usage (int status);
+#include "error.h"
+
/* Like error(0, 0, ...), but without an implicit newline.
Also a noop unless the global DEV_DEBUG is set. */
#define devmsg(...) \
/* FIXME */
#include "assure.h"
-#include "die.h"
-
/* FIXME: this is small for testing */
#define BUFFER_SIZE (8)
}
bytes_read = full_read (STDIN_FILENO, buf, BUFFER_SIZE);
if (bytes_read != buffer_size && errno != 0)
- die (EXIT_FAILURE, errno, _("read error"));
+ error (EXIT_FAILURE, errno, _("read error"));
{
struct B_pair bp;
#include <regex.h>
-#include "die.h"
-#include "error.h"
#include "filenamecat.h"
#include "safe-read.h"
#include "stdlib--.h"
regoff_t ret;
if (1 < range)
- die (EXIT_FAILURE, 0, _("record too large"));
+ error (EXIT_FAILURE, 0, _("record too large"));
if (range == 1
|| ((ret = re_search (&compiled_separator, G_buffer,
== -1))
match_start = G_buffer - 1;
else if (ret == -2)
- {
- die (EXIT_FAILURE, 0,
+ error (EXIT_FAILURE, 0,
_("error in regular expression search"));
- }
else
{
match_start = G_buffer + regs.start[0];
if (sentinel_length == 0)
{
if (*separator == 0)
- die (EXIT_FAILURE, 0, _("separator cannot be empty"));
+ error (EXIT_FAILURE, 0, _("separator cannot be empty"));
compiled_separator.buffer = nullptr;
compiled_separator.allocated = 0;
error_message = re_compile_pattern (separator, strlen (separator),
&compiled_separator);
if (error_message)
- die (EXIT_FAILURE, 0, "%s", (error_message));
+ error (EXIT_FAILURE, 0, "%s", (error_message));
}
else
match_length = sentinel_length = *separator ? strlen (separator) : 1;
#include "argmatch.h"
#include "assure.h"
#include "cl-strtod.h"
-#include "die.h"
-#include "error.h"
#include "fcntl--.h"
#include "iopoll.h"
#include "isapipe.h"
if (n_bytes > 0 && fwrite (buffer, 1, n_bytes, stdout) < n_bytes)
{
clearerr (stdout); /* To avoid redundant close_stdout diagnostic. */
- die (EXIT_FAILURE, errno, _("error writing %s"),
- quoteaf ("standard output"));
+ error (EXIT_FAILURE, errno, _("error writing %s"),
+ quoteaf ("standard output"));
}
}
if (bytes_read == SAFE_READ_ERROR)
{
if (errno != EAGAIN)
- die (EXIT_FAILURE, errno, _("error reading %s"),
- quoteaf (pretty_filename));
+ error (EXIT_FAILURE, errno, _("error reading %s"),
+ quoteaf (pretty_filename));
break;
}
if (bytes_read == 0)
the append-only attribute. */
}
else
- die (EXIT_FAILURE, errno,
- _("%s: cannot change nonblocking mode"),
- quotef (name));
+ error (EXIT_FAILURE, errno,
+ _("%s: cannot change nonblocking mode"),
+ quotef (name));
}
else
f[i].blocking = blocking;
}
if ((!any_input || blocking) && fflush (stdout) != 0)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
check_output_alive ();
&& errno != EPERM);
if (!writer_is_dead && xnanosleep (sleep_interval))
- die (EXIT_FAILURE, errno, _("cannot read realtime clock"));
+ error (EXIT_FAILURE, errno, _("cannot read realtime clock"));
}
}
{
*prev_fspec = fspec;
if (fflush (stdout) != 0)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
}
if (follow_mode == Follow_name
&& ! reopen_inaccessible_files
&& hash_get_n_entries (wd_to_name) == 0)
- die (EXIT_FAILURE, 0, _("no files remaining"));
+ error (EXIT_FAILURE, 0, _("no files remaining"));
if (len <= evbuf_off)
{
while (file_change == 0);
if (file_change < 0)
- die (EXIT_FAILURE, errno,
- _("error waiting for inotify and output events"));
+ error (EXIT_FAILURE, errno,
+ _("error waiting for inotify and output events"));
if (pfd[1].revents)
die_pipe ();
}
if (len == 0 || len == SAFE_READ_ERROR)
- die (EXIT_FAILURE, errno, _("error reading inotify event"));
+ error (EXIT_FAILURE, errno, _("error reading inotify event"));
}
void_ev = evbuf + evbuf_off;
else if ((xstrtoumax (n_string, nullptr, 10, n_units, "b")
& ~LONGINT_INVALID_SUFFIX_CHAR)
!= LONGINT_OK)
- {
- die (EXIT_FAILURE, errno, "%s: %s", _("invalid number"),
+ error (EXIT_FAILURE, errno, "%s: %s", _("invalid number"),
quote (argv[1]));
- }
/* Set globals. */
from_start = t_from_start;
{
double s;
if (! (xstrtod (optarg, nullptr, &s, cl_strtod) && 0 <= s))
- die (EXIT_FAILURE, 0,
- _("invalid number of seconds: %s"), quote (optarg));
+ error (EXIT_FAILURE, 0,
+ _("invalid number of seconds: %s"), quote (optarg));
*sleep_interval = s;
}
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- die (EXIT_FAILURE, 0, _("option used in invalid context -- %c"), c);
+ error (EXIT_FAILURE, 0, _("option used in invalid context -- %c"), c);
default:
usage (EXIT_FAILURE);
/* When following by name, there must be a name. */
if (found_hyphen && follow_mode == Follow_name)
- die (EXIT_FAILURE, 0, _("cannot follow %s by name"), quoteaf ("-"));
+ error (EXIT_FAILURE, 0, _("cannot follow %s by name"), quoteaf ("-"));
/* When following forever, and not using simple blocking, warn if
any file is '-' as the stats() used to check for input are ineffective.
so that we exit if the reader goes away. */
struct stat out_stat;
if (fstat (STDOUT_FILENO, &out_stat) < 0)
- die (EXIT_FAILURE, errno, _("standard output"));
+ error (EXIT_FAILURE, errno, _("standard output"));
monitor_output = (S_ISFIFO (out_stat.st_mode)
|| (HAVE_FIFO_PIPES != 1 && isapipe (STDOUT_FILENO)));
tail_forever_inotify flushes only after writing,
not before reading. */
if (fflush (stdout) != 0)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
Hash_table *ht;
tail_forever_inotify (wd, F, n_files, sleep_interval, &ht);
}
if (have_read_stdin && close (STDIN_FILENO) < 0)
- die (EXIT_FAILURE, errno, "-");
+ error (EXIT_FAILURE, errno, "-");
main_exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}
#include "system.h"
#include "argmatch.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "iopoll.h"
#include "stdio--.h"
bool ok = tee_files (argc - optind, &argv[optind], pipe_check);
if (close (STDIN_FILENO) != 0)
- die (EXIT_FAILURE, errno, "%s", _("standard input"));
+ error (EXIT_FAILURE, errno, "%s", _("standard input"));
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
#include "xstrtod.h"
#include "sig2str.h"
#include "operand2sig.h"
-#include "error.h"
#include "quote.h"
#if HAVE_SETRLIMIT
#include "system.h"
#include "argmatch.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "fd-reopen.h"
#include "parse-datetime.h"
#include "posixtm.h"
{
struct timespec result;
if (! parse_datetime (&result, flex_date, &now))
- die (EXIT_FAILURE, 0, _("invalid date format %s"), quote (flex_date));
+ error (EXIT_FAILURE, 0, _("invalid date format %s"), quote (flex_date));
return result;
}
case 't':
if (! posixtime (&newtime[0].tv_sec, optarg,
PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS))
- die (EXIT_FAILURE, 0, _("invalid date format %s"),
- quote (optarg));
+ error (EXIT_FAILURE, 0, _("invalid date format %s"),
+ quote (optarg));
newtime[0].tv_nsec = 0;
newtime[1] = newtime[0];
date_set = true;
might be an object-like macro. */
if (no_dereference ? lstat (ref_file, &ref_stats)
: stat (ref_file, &ref_stats))
- die (EXIT_FAILURE, errno,
- _("failed to get attributes of %s"), quoteaf (ref_file));
+ error (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;
#include "system.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "quote.h"
#include "safe-read.h"
c1 must also transition at the same time. */
if (s2_new_element && class_s2 != UL_NONE
&& !(s1_new_element && class_s1 != UL_NONE))
- die (EXIT_FAILURE, 0,
- _("misaligned [:upper:] and/or [:lower:] construct"));
+ error (EXIT_FAILURE, 0,
+ _("misaligned [:upper:] and/or [:lower:] construct"));
/* If case converting, quickly skip over the elements. */
if (class_s2 != UL_NONE)
indefinite element. */
new_length = length + len;
if (! (length <= new_length && new_length <= REPEAT_COUNT_MAXIMUM))
- die (EXIT_FAILURE, 0, _("too many characters in set"));
+ error (EXIT_FAILURE, 0, _("too many characters in set"));
length = new_length;
}
tr '[:upper:]0-9' '[:lower:]'
That's not portable however, contradicts POSIX and is dependent
on your collating sequence. */
- die (EXIT_FAILURE, 0,
- _("when translating with string1 longer than string2,\nthe\
- latter string must not end with a character class"));
+ error (EXIT_FAILURE, 0,
+ _("when translating with string1 longer than string2,\n"
+ "the latter string must not end with a character class"));
case RE_REPEATED_CHAR:
char_to_repeat = p->u.repeated_char.the_repeated_char;
{
get_s1_spec_stats (s1);
if (s1->n_indefinite_repeats > 0)
- {
- die (EXIT_FAILURE, 0,
+ error (EXIT_FAILURE, 0,
_("the [c*] repeat construct may not appear in string1"));
- }
if (s2)
{
get_s2_spec_stats (s2, s1->length);
if (s2->n_indefinite_repeats > 1)
- {
- die (EXIT_FAILURE, 0,
+ error (EXIT_FAILURE, 0,
_("only one [c*] repeat construct may appear in string2"));
- }
if (translating)
{
if (s2->has_equiv_class)
- {
- die (EXIT_FAILURE, 0,
- _("[=c=] expressions may not appear in string2\
- when translating"));
- }
+ error (EXIT_FAILURE, 0,
+ _("[=c=] expressions may not appear in string2"
+ " when translating"));
if (s2->has_restricted_char_class)
- {
- die (EXIT_FAILURE, 0,
- _("when translating, the only character classes that may\
- appear in\nstring2 are 'upper' and 'lower'"));
- }
+ error (EXIT_FAILURE, 0,
+ _("when translating, the only character classes"
+ " that may appear in\n"
+ "string2 are 'upper' and 'lower'"));
validate_case_classes (s1, s2);
given or string1 is empty. */
if (s2->length == 0)
- die (EXIT_FAILURE, 0,
- _("when not truncating set1, string2 must be non-empty"));
+ error (EXIT_FAILURE, 0,
+ _("when not truncating set1,"
+ " string2 must be non-empty"));
string2_extend (s1, s2);
}
}
if (complement && s1->has_char_class
&& ! (s2->length == s1->length && homogeneous_spec_list (s2)))
- {
- die (EXIT_FAILURE, 0,
- _("when translating with complemented character classes,\
-\nstring2 must map all characters in the domain to one"));
- }
+ error (EXIT_FAILURE, 0,
+ _("when translating with complemented character classes,\n"
+ "string2 must map all characters in the domain to one"));
}
else
/* Not translating. */
{
if (s2->n_indefinite_repeats > 0)
- die (EXIT_FAILURE, 0,
- _("the [c*] construct may appear in string2 only\
- when translating"));
+ error (EXIT_FAILURE, 0,
+ _("the [c*] construct may appear in string2"
+ " only when translating"));
}
}
}
}
if (out_len > 0
&& fwrite (&buf[begin], 1, out_len, stdout) != out_len)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
if (char_to_squeeze != NOT_A_CHAR)
{
size_t nr = safe_read (STDIN_FILENO, buf, size);
if (nr == SAFE_READ_ERROR)
- die (EXIT_FAILURE, errno, _("read error"));
+ error (EXIT_FAILURE, errno, _("read error"));
return nr;
}
if (nr == 0)
break;
if (fwrite (io_buf, 1, nr, stdout) != nr)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
}
else if (squeeze_repeats && delete && non_option_args == 2)
if (bytes_read == 0)
break;
if (fwrite (io_buf, 1, bytes_read, stdout) != bytes_read)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
}
}
if (close (STDIN_FILENO) != 0)
- die (EXIT_FAILURE, errno, _("standard input"));
+ error (EXIT_FAILURE, errno, _("standard input"));
main_exit (EXIT_SUCCESS);
}
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "quote.h"
#include "stat-size.h"
#include "xdectoint.h"
_("Invalid number"), 0);
/* Rounding to multiple of 0 is nonsensical */
if ((rel_mode == rm_rup || rel_mode == rm_rdn) && size == 0)
- die (EXIT_FAILURE, 0, _("division by zero"));
+ error (EXIT_FAILURE, 0, _("division by zero"));
got_size = true;
break;
struct stat sb;
off_t file_size = -1;
if (stat (ref_file, &sb) != 0)
- die (EXIT_FAILURE, errno, _("cannot stat %s"), quoteaf (ref_file));
+ error (EXIT_FAILURE, errno, _("cannot stat %s"), quoteaf (ref_file));
if (usable_st_size (&sb))
file_size = sb.st_size;
else
}
}
if (file_size < 0)
- die (EXIT_FAILURE, errno, _("cannot get the size of %s"),
- quoteaf (ref_file));
+ error (EXIT_FAILURE, errno, _("cannot get the size of %s"),
+ quoteaf (ref_file));
if (!got_size)
size = file_size;
else
#include "system.h"
#include "assure.h"
#include "long-options.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "readtokens.h"
#include "stdio--.h"
root = new_item (nullptr);
if (!is_stdin && ! freopen (file, "r", stdin))
- die (EXIT_FAILURE, errno, "%s", quotef (file));
+ error (EXIT_FAILURE, errno, "%s", quotef (file));
fadvise (stdin, FADVISE_SEQUENTIAL);
if (len == (size_t) -1)
{
if (ferror (stdin))
- die (EXIT_FAILURE, errno, _("%s: read error"), quotef (file));
+ error (EXIT_FAILURE, errno, _("%s: read error"), quotef (file));
break;
}
}
if (k != nullptr)
- die (EXIT_FAILURE, 0, _("%s: input contains an odd number of tokens"),
- quotef (file));
+ error (EXIT_FAILURE, 0, _("%s: input contains an odd number of tokens"),
+ quotef (file));
/* T1. Initialize (N <- n). */
walk_tree (root, count_items);
}
if (fclose (stdin) != 0)
- die (EXIT_FAILURE, errno, "%s",
- is_stdin ? _("standard input") : quotef (file));
+ error (EXIT_FAILURE, errno, "%s",
+ is_stdin ? _("standard input") : quotef (file));
exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}
#include <sys/types.h>
#include "system.h"
-#include "error.h"
#include "quote.h"
/* Exit statuses. */
#endif
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "quote.h"
#include "uname.h"
struct utsname name;
if (uname (&name) == -1)
- die (EXIT_FAILURE, errno, _("cannot get system name"));
+ error (EXIT_FAILURE, errno, _("cannot get system name"));
if (toprint & PRINT_KERNEL_NAME)
print_element_env (name.sysname, "UNAME_SYSNAME");
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-
#include "expand-common.h"
/* The official name of this program (e.g., no 'g' prefix). */
if (convert)
{
if (next_tab_column < column)
- die (EXIT_FAILURE, 0, _("input line is too long"));
+ error (EXIT_FAILURE, 0, _("input line is too long"));
if (c == '\t')
{
{
column++;
if (!column)
- die (EXIT_FAILURE, 0, _("input line is too long"));
+ error (EXIT_FAILURE, 0, _("input line is too long"));
}
if (pending)
if (pending > 1 && one_blank_before_tab_stop)
pending_blank[0] = '\t';
if (fwrite (pending_blank, 1, pending, stdout) != pending)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
pending = 0;
one_blank_before_tab_stop = false;
}
}
if (putchar (c) < 0)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
while (c != '\n');
}
have_tabval = true;
}
if (!DECIMAL_DIGIT_ACCUMULATE (tabval, c - '0', uintmax_t))
- die (EXIT_FAILURE, 0, _("tab stop value is too large"));
+ error (EXIT_FAILURE, 0, _("tab stop value is too large"));
break;
}
}
#include "system.h"
#include "argmatch.h"
#include "linebuffer.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "posixver.h"
#include "stdio--.h"
break;
default:
- die (EXIT_FAILURE, 0, "%s: %s", opt, _(msgid));
+ error (EXIT_FAILURE, 0, "%s: %s", opt, _(msgid));
}
return MIN (size, SIZE_MAX);
struct linebuffer *thisline, *prevline;
if (! (STREQ (infile, "-") || freopen (infile, "r", stdin)))
- die (EXIT_FAILURE, errno, "%s", quotef (infile));
+ error (EXIT_FAILURE, errno, "%s", quotef (infile));
if (! (STREQ (outfile, "-") || freopen (outfile, "w", stdout)))
- die (EXIT_FAILURE, errno, "%s", quotef (outfile));
+ error (EXIT_FAILURE, errno, "%s", quotef (outfile));
fadvise (stdin, FADVISE_SEQUENTIAL);
if (match_count == UINTMAX_MAX)
{
if (count_occurrences)
- die (EXIT_FAILURE, 0, _("too many repeated lines"));
+ error (EXIT_FAILURE, 0, _("too many repeated lines"));
match_count--;
}
closefiles:
if (ferror (stdin) || fclose (stdin) != 0)
- die (EXIT_FAILURE, errno, _("error reading %s"), quoteaf (infile));
+ error (EXIT_FAILURE, errno, _("error reading %s"), quoteaf (infile));
/* stdout is handled via the atexit-invoked close_stdout function. */
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "long-options.h"
#include "quote.h"
}
if (unlink (argv[optind]) != 0)
- die (EXIT_FAILURE, errno, _("cannot unlink %s"), quoteaf (argv[optind]));
+ error (EXIT_FAILURE, errno, _("cannot unlink %s"), quoteaf (argv[optind]));
return EXIT_SUCCESS;
}
#endif
#include "c-strtod.h"
-#include "die.h"
-#include "error.h"
#include "long-options.h"
#include "quote.h"
#include "readutmp.h"
#endif
{
if (boot_time == 0)
- die (EXIT_FAILURE, errno, _("couldn't get boot time"));
+ error (EXIT_FAILURE, errno, _("couldn't get boot time"));
uptime = time_now - boot_time;
}
updays = uptime / 86400;
#if HAVE_STRUCT_UTMP_UT_TYPE || HAVE_STRUCT_UTMPX_UT_TYPE
if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (filename));
+ error (EXIT_FAILURE, errno, "%s", quotef (filename));
#endif
print_uptime (n_users, utmp_buf);
#include <sys/types.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "long-options.h"
#include "quote.h"
#include "readutmp.h"
STRUCT_UTMP *utmp_buf;
if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (filename));
+ error (EXIT_FAILURE, errno, "%s", quotef (filename));
list_entries_users (n_users, utmp_buf);
#include "assure.h"
#include "argmatch.h"
#include "argv-iter.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "mbchar.h"
#include "physmem.h"
{
stream = fopen (files_from, "r");
if (stream == nullptr)
- die (EXIT_FAILURE, errno, _("cannot open %s for reading"),
- quoteaf (files_from));
+ error (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
read_tokens = true;
readtokens0_init (&tok);
if (! readtokens0 (stream, &tok) || fclose (stream) != 0)
- die (EXIT_FAILURE, 0, _("cannot read file names from %s"),
- quoteaf (files_from));
+ error (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);
free (fstatus);
if (have_read_stdin && close (STDIN_FILENO) != 0)
- die (EXIT_FAILURE, errno, "-");
+ error (EXIT_FAILURE, errno, "-");
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
#include <config.h>
#include "system.h"
-#include "error.h"
#include "safe-read.h"
#include <x86intrin.h>
#include "c-ctype.h"
#include "canon-host.h"
#include "readutmp.h"
-#include "die.h"
-#include "error.h"
#include "hard-locale.h"
#include "quote.h"
STRUCT_UTMP *utmp_buf;
if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
- die (EXIT_FAILURE, errno, "%s", quotef (filename));
+ error (EXIT_FAILURE, errno, "%s", quotef (filename));
if (short_list)
list_entries_who (n_users, utmp_buf);
#include <pwd.h>
#include "system.h"
-#include "die.h"
-#include "error.h"
#include "long-options.h"
#include "quote.h"
uid = geteuid ();
pw = uid == NO_UID && errno ? nullptr : getpwuid (uid);
if (!pw)
- die (EXIT_FAILURE, errno, _("cannot find name for user ID %lu"),
- (unsigned long int) uid);
+ error (EXIT_FAILURE, errno, _("cannot find name for user ID %lu"),
+ (unsigned long int) uid);
puts (pw->pw_name);
return EXIT_SUCCESS;
}
#include "system.h"
-#include "error.h"
#include "full-write.h"
#include "long-options.h"