[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Change error (1, ...) to error (EXIT_FAILURE, ...).
From: |
James Youngman |
Subject: |
[PATCH] Change error (1, ...) to error (EXIT_FAILURE, ...). |
Date: |
Thu, 1 Apr 2010 09:16:22 +0100 |
* find/find.c: Change error (1, ...) to error (EXIT_FAILURE, ...).
* find/fstype.c: Likewise.
* find/ftsfind.c: Likewise.
* find/parser.c: Likewise.
* find/pred.c: Likewise.
* find/tree.c: Likewise.
* find/util.c: Likewise.
* locate/code.c: Likewise.
* locate/frcode.c: Likewise.
* locate/locate.c: Likewise.
* locate/word_io.c: Likewise.
* xargs/xargs.c: Likewise.
* lib/buildcmd.c: Likewise. Also include <stdlib.h>.
* lib/regextype.c: Likewise (both).
Signed-off-by: James Youngman <address@hidden>
---
ChangeLog | 16 +++++++
find/find.c | 18 ++++---
find/fstype.c | 2 +-
find/ftsfind.c | 5 +-
find/parser.c | 127 +++++++++++++++++++++++++++++++-----------------------
find/pred.c | 2 +-
find/tree.c | 58 +++++++++++++++----------
find/util.c | 28 +++++++-----
lib/buildcmd.c | 14 +++---
lib/regextype.c | 8 ++-
locate/code.c | 4 +-
locate/frcode.c | 15 ++++---
locate/locate.c | 26 ++++++------
locate/word_io.c | 5 +-
xargs/xargs.c | 35 ++++++++-------
15 files changed, 215 insertions(+), 148 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f80fb78..0f417cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2010-04-01 James Youngman <address@hidden>
+ Change error (1, ...) to error (EXIT_FAILURE, ...).
+ * find/find.c: Change error (1, ...) to error (EXIT_FAILURE, ...).
+ * find/fstype.c: Likewise.
+ * find/ftsfind.c: Likewise.
+ * find/parser.c: Likewise.
+ * find/pred.c: Likewise.
+ * find/tree.c: Likewise.
+ * find/util.c: Likewise.
+ * locate/code.c: Likewise.
+ * locate/frcode.c: Likewise.
+ * locate/locate.c: Likewise.
+ * locate/word_io.c: Likewise.
+ * xargs/xargs.c: Likewise.
+ * lib/buildcmd.c: Likewise. Also include <stdlib.h>.
+ * lib/regextype.c: Likewise (both).
+
Assume C89 (or C99) C headers. Assume working <ctype.h>.
* xargs/xargs.c: Unconditionally include <ctype.h>. Assume
isblank(c) is defined. Assume memcpy() has a prototype in
diff --git a/find/find.c b/find/find.c
index 9a1866c..59a6525 100644
--- a/find/find.c
+++ b/find/find.c
@@ -139,7 +139,8 @@ main (int argc, char **argv)
state.shared_files = sharefile_init ("w");
if (NULL == state.shared_files)
{
- error (1, errno, _("Failed initialise shared-file hash table"));
+ error (EXIT_FAILURE, errno,
+ _("Failed initialise shared-file hash table"));
}
/* Set the option defaults before we do the locale
@@ -209,12 +210,12 @@ main (int argc, char **argv)
{
starting_dir = xgetcwd ();
if (! starting_dir)
- error (1, errno, _("cannot get current directory"));
+ error (EXIT_FAILURE, errno, _("cannot get current directory"));
}
set_stat_placeholders (&starting_stat_buf);
if ((*options.xstat) (".", &starting_stat_buf) != 0)
- error (1, errno, _("cannot stat current directory"));
+ error (EXIT_FAILURE, errno, _("cannot stat current directory"));
/* If no paths are given, default to ".". */
for (i = end_of_leading_options; i < argc && !looks_like_expression
(argv[i], true); i++)
@@ -305,7 +306,7 @@ init_mounted_dev_list (int mandatory)
mounted_devices = get_mounted_devices (&num_mounted_devices);
if (mandatory && (NULL == mounted_devices))
{
- error (1, 0, _("Cannot read list of mounted devices."));
+ error (EXIT_FAILURE, 0, _("Cannot read list of mounted devices."));
}
}
@@ -499,7 +500,7 @@ wd_sanity_check (const char *thing_to_stat,
case FATAL_IF_SANITY_CHECK_FAILS:
{
fstype = filesystem_type (newinfo, current_dir);
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("%s%s changed during execution of %s (old device number
%ld, new device number %ld, file system type is %s) [ref %ld]"),
safely_quote_err_filename (0, specific_what),
parent ? "/.." : "",
@@ -701,7 +702,7 @@ safely_chdir_lstat (const char *dest,
* can't recover from this and so this error
* is fatal.
*/
- error (1, errno,
+ error (EXIT_FAILURE, errno,
_("failed to return to parent directory"));
}
}
@@ -1508,7 +1509,7 @@ process_dir (char *pathname, char *name, int pathlen,
const struct stat *statp,
break;
case SafeChdirFailWouldBeUnableToReturn:
- error (1, errno, ".");
+ error (EXIT_FAILURE, errno, ".");
return;
case SafeChdirFailNonexistent:
@@ -1517,7 +1518,8 @@ process_dir (char *pathname, char *name, int pathlen,
const struct stat *statp,
case SafeChdirFailSymlink:
case SafeChdirFailNotDir:
case SafeChdirFailChdirFailed:
- error (1, errno, "%s", safely_quote_err_filename (0, pathname));
+ error (EXIT_FAILURE, errno,
+ "%s", safely_quote_err_filename (0, pathname));
return;
}
diff --git a/find/fstype.c b/find/fstype.c
index 88d4208..34875c0 100644
--- a/find/fstype.c
+++ b/find/fstype.c
@@ -201,7 +201,7 @@ must_read_fs_list (bool need_fs_type)
* use because gnulib has abstracted all that stuff away.
* Hence we cannot issue a specific error message here.
*/
- error (1, 0, _("Cannot read mounted file system list"));
+ error (EXIT_FAILURE, 0, _("Cannot read mounted file system list"));
}
return entries;
}
diff --git a/find/ftsfind.c b/find/ftsfind.c
index 1fce8e3..4123b24 100644
--- a/find/ftsfind.c
+++ b/find/ftsfind.c
@@ -674,7 +674,8 @@ main (int argc, char **argv)
state.shared_files = sharefile_init ("w");
if (NULL == state.shared_files)
{
- error (1, errno, _("Failed initialise shared-file hash table"));
+ error (EXIT_FAILURE, errno,
+ _("Failed initialise shared-file hash table"));
}
/* Set the option defaults before we do the locale initialisation as
@@ -740,7 +741,7 @@ main (int argc, char **argv)
{
starting_dir = xgetcwd ();
if (! starting_dir)
- error (1, errno, _("cannot get current directory"));
+ error (EXIT_FAILURE, errno, _("cannot get current directory"));
}
process_all_startpoints (argc-end_of_leading_options,
argv+end_of_leading_options);
diff --git a/find/parser.c b/find/parser.c
index 32b1d20..dde0c8d 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -466,10 +466,11 @@ check_option_combinations (const struct predicate *p)
if (!options.explicit_depth)
{
/* This fixes Savannah bug #20865. */
- error (1, 0, _("The -delete action atomatically turns on -depth, "
- "but -prune does nothing when -depth is in effect. "
- "If you want to carry on anyway, just explicitly use "
- "the -depth option."));
+ error (EXIT_FAILURE, 0,
+ _("The -delete action atomatically turns on -depth, "
+ "but -prune does nothing when -depth is in effect. "
+ "If you want to carry on anyway, just explicitly use "
+ "the -depth option."));
}
}
}
@@ -1110,12 +1111,12 @@ safe_atoi (const char *s)
if (errno == ERANGE)
{
/* too big, or too small. */
- error (1, errno, "%s", s);
+ error (EXIT_FAILURE, errno, "%s", s);
}
else
{
/* not a valid number */
- error (1, errno, "%s", s);
+ error (EXIT_FAILURE, errno, "%s", s);
}
/* Otherwise, we do a range chack against INT_MAX and INT_MIN
* below.
@@ -1126,17 +1127,17 @@ safe_atoi (const char *s)
{
/* The number was in range for long, but not int. */
errno = ERANGE;
- error (1, errno, "%s", s);
+ error (EXIT_FAILURE, errno, "%s", s);
}
else if (*end)
{
- error (1, errno, _("Unexpected suffix %s on %s"),
+ error (EXIT_FAILURE, errno, _("Unexpected suffix %s on %s"),
quotearg_n_style (0, options.err_quoting_style, end),
quotearg_n_style (1, options.err_quoting_style, s));
}
else if (end == s)
{
- error (1, errno, "Expected an integer: %s",
+ error (EXIT_FAILURE, errno, "Expected an integer: %s",
quotearg_n_style (0, options.err_quoting_style, s));
}
return (int)lval;
@@ -1171,11 +1172,12 @@ parse_group (const struct parser_table* entry, char
**argv, int *arg_ptr)
else
{
/* XXX: no test in test suite for this */
- error (1, 0, _("%s is not the name of an existing group and"
- " it does not look like a numeric group ID "
- "because it has the unexpected suffix %s"),
- quotearg_n_style (0, options.err_quoting_style,
groupname),
- quotearg_n_style (1, options.err_quoting_style,
groupname+gid_len));
+ error (EXIT_FAILURE, 0,
+ _("%s is not the name of an existing group and"
+ " it does not look like a numeric group ID "
+ "because it has the unexpected suffix %s"),
+ quotearg_n_style (0, options.err_quoting_style,
groupname),
+ quotearg_n_style (1, options.err_quoting_style,
groupname+gid_len));
*arg_ptr = saved_argc; /* don't consume the invalid argument.
*/
return false;
}
@@ -1185,12 +1187,14 @@ parse_group (const struct parser_table* entry, char
**argv, int *arg_ptr)
if (*groupname)
{
/* XXX: no test in test suite for this */
- error (1, 0, _("%s is not the name of an existing group"),
+ error (EXIT_FAILURE, 0,
+ _("%s is not the name of an existing group"),
quotearg_n_style (0, options.err_quoting_style,
groupname));
}
else
{
- error (1, 0, _("argument to -group is empty, but should be a
group name"));
+ error (EXIT_FAILURE, 0,
+ _("argument to -group is empty, but should be a group
name"));
}
*arg_ptr = saved_argc; /* don't consume the invalid argument. */
return false;
@@ -1296,7 +1300,8 @@ fnmatch_sanitycheck (void)
|| 0 == fnmatch ("Foo", "foo", 0)
|| 0 != fnmatch ("Foo", "foo", FNM_CASEFOLD))
{
- error (1, 0, _("sanity check of the fnmatch() library function
failed."));
+ error (EXIT_FAILURE, 0,
+ _("sanity check of the fnmatch() library function failed."));
return false;
}
checked = true;
@@ -1435,7 +1440,8 @@ insert_depthspec (const struct parser_table* entry, char
**argv, int *arg_ptr,
return parse_noop (entry, argv, arg_ptr);
}
}
- error (1, 0, _("Expected a positive decimal integer argument to %s, but
got %s"),
+ error (EXIT_FAILURE, 0,
+ _("Expected a positive decimal integer argument to %s, but got
%s"),
predicate,
quotearg_n_style (0, options.err_quoting_style, depthstr));
/* NOTREACHED */
@@ -1621,7 +1627,7 @@ parse_newerXY (const struct parser_table* entry, char
**argv, int *arg_ptr)
*/
if (argv[1+*arg_ptr] == NULL)
{
- error (1, 0, _("The %s test needs an argument"),
+ error (EXIT_FAILURE, 0, _("The %s test needs an argument"),
quotearg_n_style (0, options.err_quoting_style,
argv[*arg_ptr]));
}
else
@@ -1657,7 +1663,7 @@ parse_newerXY (const struct parser_table* entry, char
**argv, int *arg_ptr)
argv[*arg_ptr],
&options.start_time))
{
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("I cannot figure out how to interpret %s as a date
or time"),
quotearg_n_style (0, options.err_quoting_style,
argv[*arg_ptr]));
}
@@ -1674,7 +1680,8 @@ parse_newerXY (const struct parser_table* entry, char
**argv, int *arg_ptr)
if (!get_stat_Ytime (&stat_newer, y, &our_pred->args.reftime.ts))
{
/* We cannot extract a timestamp from the struct stat. */
- error (1, 0, _("Cannot obtain birth time of file %s"),
+ error (EXIT_FAILURE, 0,
+ _("Cannot obtain birth time of file %s"),
safely_quote_err_filename (0, argv[*arg_ptr]));
}
}
@@ -1937,7 +1944,8 @@ non_posix_mode (const char *mode)
{
if (options.posixly_correct)
{
- error (1, 0, _("Mode %s is not valid when POSIXLY_CORRECT is on."),
+ error (EXIT_FAILURE, 0,
+ _("Mode %s is not valid when POSIXLY_CORRECT is on."),
quotearg_n_style (0, options.err_quoting_style, mode));
}
}
@@ -2020,7 +2028,7 @@ parse_perm (const struct parser_table* entry, char
**argv, int *arg_ptr)
{
change = mode_compile (perm_expr + mode_start);
if (NULL == change)
- error (1, 0, _("invalid mode %s"),
+ error (EXIT_FAILURE, 0, _("invalid mode %s"),
quotearg_n_style (0, options.err_quoting_style, perm_expr));
}
perm_val[0] = mode_adjust (0, false, 0, change, NULL);
@@ -2227,7 +2235,7 @@ insert_regex (char **argv,
error_message = re_compile_pattern (rx, strlen (rx), re);
if (error_message)
- error (1, 0, "%s", error_message);
+ error (EXIT_FAILURE, 0, "%s", error_message);
our_pred->est_success_rate = estimate_pattern_match_rate (rx, 1);
return true;
}
@@ -2255,7 +2263,7 @@ parse_size (const struct parser_table* entry, char
**argv, int *arg_ptr)
len = strlen (arg);
if (len == 0)
- error (1, 0, _("invalid null argument to -size"));
+ error (EXIT_FAILURE, 0, _("invalid null argument to -size"));
suffix = arg[len - 1];
switch (suffix)
@@ -2303,12 +2311,13 @@ parse_size (const struct parser_table* entry, char
**argv, int *arg_ptr)
break;
default:
- error (1, 0, _("invalid -size type `%c'"), argv[*arg_ptr][len - 1]);
+ error (EXIT_FAILURE, 0,
+ _("invalid -size type `%c'"), argv[*arg_ptr][len - 1]);
}
/* TODO: accept fractional megabytes etc. ? */
if (!get_num (arg, &num, &c_type))
{
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("Invalid argument `%s%c' to -size"),
arg, (int)suffix);
return false;
@@ -2497,7 +2506,7 @@ parse_show_control_chars (const struct parser_table*
entry,
if ((argv == NULL) || (argv[*arg_ptr] == NULL))
{
- error (1, errno, "%s", errmsg);
+ error (EXIT_FAILURE, errno, "%s", errmsg);
return false;
}
else
@@ -2514,7 +2523,7 @@ parse_show_control_chars (const struct parser_table*
entry,
}
else
{
- error (1, errno, "%s", errmsg);
+ error (EXIT_FAILURE, errno, "%s", errmsg);
return false;
}
(*arg_ptr)++; /* consume the argument. */
@@ -2604,7 +2613,8 @@ parse_used (const struct parser_table* entry, char
**argv, int *arg_ptr)
}
else
{
- error (1, 0, _("Invalid argument %s to -used"), offset_str);
+ error (EXIT_FAILURE, 0,
+ _("Invalid argument %s to -used"), offset_str);
/*NOTREACHED*/
return false;
}
@@ -2644,13 +2654,15 @@ parse_user (const struct parser_table* entry, char
**argv, int *arg_ptr)
* not as helpful). */
if (username[0])
{
- error (1, 0, _("%s is not the name of a known user"),
+ error (EXIT_FAILURE, 0,
+ _("%s is not the name of a known user"),
quotearg_n_style (0, options.err_quoting_style,
username));
}
else
{
- error (1, 0, _("The argument to -user should not be empty"));
+ error (EXIT_FAILURE, 0,
+ _("The argument to -user should not be empty"));
}
/*NOTREACHED*/
return false;
@@ -2751,7 +2763,8 @@ parse_context (const struct parser_table* entry, char
**argv, int *arg_ptr)
if (is_selinux_enabled () <= 0)
{
- error (1, 0, _("invalid predicate -context: SELinux is not enabled."));
+ error (EXIT_FAILURE, 0,
+ _("invalid predicate -context: SELinux is not enabled."));
return false;
}
our_pred = insert_primary (entry, NULL);
@@ -2814,7 +2827,8 @@ insert_type (char **argv, int *arg_ptr,
{
if (strlen (typeletter) != 1u)
{
- error (1, 0, _("Arguments to -type should contain only one letter"));
+ error (EXIT_FAILURE, 0,
+ _("Arguments to -type should contain only one letter"));
/*NOTREACHED*/
return false;
}
@@ -2862,7 +2876,8 @@ insert_type (char **argv, int *arg_ptr,
break;
#endif
default: /* None of the above ... nuke 'em. */
- error (1, 0, _("Unknown argument to -type: %c"), (*typeletter));
+ error (EXIT_FAILURE, 0,
+ _("Unknown argument to -type: %c"), (*typeletter));
/*NOTREACHED*/
return false;
}
@@ -3000,7 +3015,8 @@ insert_fprintf (struct format_val *vec,
if (scan[1] == 0)
{
/* Trailing %. We don't like those. */
- error (1, 0, _("error: %s at end of format string"), scan);
+ error (EXIT_FAILURE, 0,
+ _("error: %s at end of format string"), scan);
}
else if (scan[1] == '%')
{
@@ -3192,7 +3208,7 @@ make_segment (struct segment **segment,
case '{':
case '[':
case '(':
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("error: the format directive `%%%c' is reserved for future use"),
(int)kind);
/*NOTREACHED*/
@@ -3227,21 +3243,23 @@ check_path_safety (const char *action, char **argv)
{
if (0 == strcmp (s, "."))
{
- error (1, 0, _("The current directory is included in the PATH "
- "environment variable, which is insecure in "
- "combination with the %s action of find. "
- "Please remove the current directory from your "
- "$PATH (that is, remove \".\" or leading or trailing "
- "colons)"),
+ error (EXIT_FAILURE, 0,
+ _("The current directory is included in the PATH "
+ "environment variable, which is insecure in "
+ "combination with the %s action of find. "
+ "Please remove the current directory from your "
+ "$PATH (that is, remove \".\" or leading or trailing "
+ "colons)"),
action);
}
else if ('/' != s[0])
{
/* Relative paths are also dangerous in $PATH. */
- error (1, 0, _("The relative path %s is included in the PATH "
- "environment variable, which is insecure in "
- "combination with the %s action of find. "
- "Please remove that entry from $PATH"),
+ error (EXIT_FAILURE, 0,
+ _("The relative path %s is included in the PATH "
+ "environment variable, which is insecure in "
+ "combination with the %s action of find. "
+ "Please remove that entry from $PATH"),
safely_quote_err_filename (0, s),
action);
}
@@ -3341,9 +3359,10 @@ new_insert_exec_ok (const char *action,
* allowed. We can specify this as those options are
* not defined by POSIX.
*/
- error (1, 0, _("You may not use {} within the utility name for "
- "-execdir and -okdir, because this is a potential "
- "security problem."));
+ error (EXIT_FAILURE, 0,
+ _("You may not use {} within the utility name for "
+ "-execdir and -okdir, because this is a potential "
+ "security problem."));
}
}
}
@@ -3365,7 +3384,7 @@ new_insert_exec_ok (const char *action,
else
suffix = "";
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("Only one instance of {} is supported with -exec%s ... +"),
suffix);
}
@@ -3382,7 +3401,7 @@ new_insert_exec_ok (const char *action,
{
case BC_INIT_ENV_TOO_BIG:
case BC_INIT_CANNOT_ACCOMODATE_HEADROOM:
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("The environment is too large for exec()."));
break;
case BC_INIT_OK:
@@ -3520,7 +3539,7 @@ get_relative_timestamp (const char *str,
if ((origin.tv_sec < result->ts.tv_sec) != (seconds < 0))
{
/* an overflow has occurred. */
- error (1, 0, overflowmessage, str);
+ error (EXIT_FAILURE, 0, overflowmessage, str);
}
result->ts.tv_nsec = origin.tv_nsec - nanosec;
@@ -3586,7 +3605,7 @@ parse_time (const struct parser_table* entry, char
*argv[], int *arg_ptr)
origin.tv_sec += (DAYSECS-1);
if (origin.tv_sec != expected)
{
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("arithmetic overflow when trying to calculate the end of
today"));
}
}
diff --git a/find/pred.c b/find/pred.c
index 2f6beef..34c75a4 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -2028,7 +2028,7 @@ launch (struct buildcmd_control *ctl, void *usercontext,
int argc, char **argv)
child_pid = fork ();
if (child_pid == -1)
- error (1, errno, _("cannot fork"));
+ error (EXIT_FAILURE, errno, _("cannot fork"));
if (child_pid == 0)
{
/* We are the child. */
diff --git a/find/tree.c b/find/tree.c
index 1332e52..5238e90 100644
--- a/find/tree.c
+++ b/find/tree.c
@@ -121,17 +121,19 @@ get_expr (struct predicate **input,
struct predicate *this_pred = (*input);
if (*input == NULL)
- error (1, 0, _("invalid expression"));
+ error (EXIT_FAILURE, 0, _("invalid expression"));
switch ((*input)->p_type)
{
case NO_TYPE:
- error (1, 0, _("invalid expression"));
+ error (EXIT_FAILURE, 0, _("invalid expression"));
break;
case BI_OP:
/* e.g. "find . -a" */
- error (1, 0, _("invalid expression; you have used a binary operator '%s'
with nothing before it."), this_pred->p_name);
+ error (EXIT_FAILURE, 0,
+ _("invalid expression; you have used a binary operator '%s' with
nothing before it."),
+ this_pred->p_name);
break;
case CLOSE_PAREN:
@@ -140,7 +142,8 @@ get_expr (struct predicate **input,
&& !this_pred->artificial)
{
/* e.g. "find \( -not \)" or "find \( -true -a \" */
- error (1, 0, _("expected an expression between '%s' and ')'"),
+ error (EXIT_FAILURE, 0,
+ _("expected an expression between '%s' and ')'"),
prev_pred->p_name);
}
else if ( (*input)->artificial )
@@ -149,11 +152,13 @@ get_expr (struct predicate **input,
* unexpectedly.
*/
/* e.g. "find . -true -a" */
- error (1, 0, _("expected an expression after '%s'"),
prev_pred->p_name);
+ error (EXIT_FAILURE, 0,
+ _("expected an expression after '%s'"), prev_pred->p_name);
}
else
{
- error (1, 0, _("invalid expression; you have too many ')'"));
+ error (EXIT_FAILURE, 0,
+ _("invalid expression; you have too many ')'"));
}
break;
@@ -175,23 +180,27 @@ get_expr (struct predicate **input,
* looking at is from the artificial "( ) -print" that we
* add.
*/
- error (1, 0, _("invalid expression; expected to find a ')' but didn't
see one. Perhaps you need an extra predicate after '%s'"), this_pred->p_name);
+ error (EXIT_FAILURE, 0,
+ _("invalid expression; expected to find a ')' but didn't see
one. Perhaps you need an extra predicate after '%s'"),
+ this_pred->p_name);
}
prev_pred = (*input);
*input = (*input)->pred_next;
if ( (*input)->p_type == CLOSE_PAREN )
{
- error (1, 0, _("invalid expression; empty parentheses are not
allowed."));
+ error (EXIT_FAILURE, 0,
+ _("invalid expression; empty parentheses are not allowed."));
}
next = get_expr (input, NO_PREC, prev_pred);
if ((*input == NULL)
|| ((*input)->p_type != CLOSE_PAREN))
- error (1, 0, _("invalid expression; I was expecting to find a ')'
somewhere but did not see one."));
+ error (EXIT_FAILURE, 0,
+ _("invalid expression; I was expecting to find a ')' somewhere
but did not see one."));
*input = (*input)->pred_next; /* move over close */
break;
default:
- error (1, 0, _("oops -- invalid expression type!"));
+ error (EXIT_FAILURE, 0, _("oops -- invalid expression type!"));
break;
}
@@ -206,7 +215,7 @@ get_expr (struct predicate **input,
{
next = scan_rest (input, next, prev_prec);
if (next == NULL)
- error (1, 0, _("invalid expression"));
+ error (EXIT_FAILURE, 0, _("invalid expression"));
}
return (next);
}
@@ -245,7 +254,7 @@ scan_rest (struct predicate **input,
/* I'm not sure how we get here, so it is not obvious what
* sort of mistakes might give rise to this condition.
*/
- error (1, 0, _("invalid expression"));
+ error (EXIT_FAILURE, 0, _("invalid expression"));
break;
case BI_OP:
@@ -262,7 +271,7 @@ scan_rest (struct predicate **input,
return tree;
default:
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("oops -- invalid expression type (%d)!"),
(int)(*input)->p_type);
break;
@@ -825,7 +834,7 @@ opt_expr (struct predicate **eval_treep)
all of the user's parentheses. */
default:
- error (1, 0, _("oops -- invalid expression type!"));
+ error (EXIT_FAILURE, 0, _("oops -- invalid expression type!"));
break;
}
@@ -1089,7 +1098,8 @@ get_pred_cost (const struct predicate *p)
sizeof(costlookup[0]),
cost_table_comparison))
{
- error(1, 0, "Failed to sort the costlookup array (indirect).");
+ error (EXIT_FAILURE, 0,
+ "Failed to sort the costlookup array (indirect).");
}
pred_table_sorted = 1;
}
@@ -1283,7 +1293,7 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
if (parse_entry == NULL)
{
/* Command line option not recognized */
- error (1, 0, _("unknown predicate `%s'"), predicate_name);
+ error (EXIT_FAILURE, 0, _("unknown predicate `%s'"), predicate_name);
}
/* We have recognised a test of the form -foo. Eat that,
@@ -1303,19 +1313,20 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
/* The special parse function spat out the
* predicate. It must be invalid, or not tasty.
*/
- error (1, 0, _("invalid predicate `%s'"),
+ error (EXIT_FAILURE, 0, _("invalid predicate `%s'"),
predicate_name);
}
else
{
- error (1, 0, _("invalid argument `%s' to `%s'"),
+ error (EXIT_FAILURE, 0, _("invalid argument `%s' to `%s'"),
argv[i], predicate_name);
}
}
else
{
/* Command line option requires an argument */
- error (1, 0, _("missing argument to `%s'"), predicate_name);
+ error (EXIT_FAILURE, 0,
+ _("missing argument to `%s'"), predicate_name);
}
}
else
@@ -1391,14 +1402,15 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
if (pred_is (cur_pred, pred_closeparen))
{
/* e.g. "find \( -true \) \)" */
- error (1, 0, _("you have too many ')'"));
+ error (EXIT_FAILURE, 0, _("you have too many ')'"));
}
else
{
if (cur_pred->p_name)
- error (1, 0, _("unexpected extra predicate '%s'"),
cur_pred->p_name);
+ error (EXIT_FAILURE, 0,
+ _("unexpected extra predicate '%s'"), cur_pred->p_name);
else
- error (1, 0, _("unexpected extra predicate"));
+ error (EXIT_FAILURE, 0, _("unexpected extra predicate"));
}
}
@@ -1531,7 +1543,7 @@ get_new_pred_chk_op (const struct parser_table *entry,
switch (last_pred->p_type)
{
case NO_TYPE:
- error (1, 0, _("oops -- invalid default insertion of and!"));
+ error (EXIT_FAILURE, 0, _("oops -- invalid default insertion of and!"));
break;
case PRIMARY_TYPE:
diff --git a/find/util.c b/find/util.c
index 243b721..0c038ad 100644
--- a/find/util.c
+++ b/find/util.c
@@ -806,7 +806,7 @@ process_debug_options (char *arg)
}
if (empty)
{
- error(1, 0, _("Empty argument to the -D option."));
+ error(EXIT_FAILURE, 0, _("Empty argument to the -D option."));
}
else if (options.debug_options & DebugHelp)
{
@@ -821,7 +821,8 @@ process_optimisation_option (const char *arg)
{
if (0 == arg[0])
{
- error (1, 0, _("The -O option must be immediately followed by a decimal
integer"));
+ error (EXIT_FAILURE, 0,
+ _("The -O option must be immediately followed by a decimal
integer"));
}
else
{
@@ -830,7 +831,8 @@ process_optimisation_option (const char *arg)
if (!isdigit ( (unsigned char) arg[0] ))
{
- error (1, 0, _("Please specify a decimal number immediately after
-O"));
+ error (EXIT_FAILURE, 0,
+ _("Please specify a decimal number immediately after -O"));
}
else
{
@@ -840,26 +842,29 @@ process_optimisation_option (const char *arg)
opt_level = strtoul (arg, &end, 10);
if ( (0==opt_level) && (end==arg) )
{
- error (1, 0, _("Please specify a decimal number immediately after
-O"));
+ error (EXIT_FAILURE, 0,
+ _("Please specify a decimal number immediately after -O"));
}
else if (*end)
{
/* unwanted trailing characters. */
- error (1, 0, _("Invalid optimisation level %s"), arg);
+ error (EXIT_FAILURE, 0, _("Invalid optimisation level %s"), arg);
}
else if ( (ULONG_MAX==opt_level) && errno)
{
- error (1, errno, _("Invalid optimisation level %s"), arg);
+ error (EXIT_FAILURE, errno,
+ _("Invalid optimisation level %s"), arg);
}
else if (opt_level > USHRT_MAX)
{
/* tricky to test, as on some platforms USHORT_MAX and ULONG_MAX
* can have the same value, though this is unusual.
*/
- error (1, 0, _("Optimisation level %lu is too high. "
- "If you want to find files very quickly, "
- "consider using GNU locate."),
- opt_level);
+ error (EXIT_FAILURE, 0,
+ _("Optimisation level %lu is too high. "
+ "If you want to find files very quickly, "
+ "consider using GNU locate."),
+ opt_level);
}
else
{
@@ -999,7 +1004,8 @@ set_option_defaults (struct options *p)
if (getenv ("FIND_BLOCK_SIZE"))
{
- error (1, 0, _("The environment variable FIND_BLOCK_SIZE is not
supported, the only thing that affects the block size is the POSIXLY_CORRECT
environment variable"));
+ error (EXIT_FAILURE, 0,
+ _("The environment variable FIND_BLOCK_SIZE is not supported, the
only thing that affects the block size is the POSIXLY_CORRECT environment
variable"));
}
#if LEAF_OPTIMISATION
diff --git a/lib/buildcmd.c b/lib/buildcmd.c
index c279d22..400425e 100644
--- a/lib/buildcmd.c
+++ b/lib/buildcmd.c
@@ -26,6 +26,7 @@
# endif
# endif
+#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <locale.h>
@@ -173,7 +174,7 @@ bc_do_insert (struct buildcmd_control *ctl,
}
while (*arg);
if (*arg)
- error (1, 0, _("command too long"));
+ error (EXIT_FAILURE, 0, _("command too long"));
*p++ = '\0';
bc_push_arg (ctl, state,
@@ -312,7 +313,7 @@ bc_do_exec (struct buildcmd_control *ctl,
{
/* No room to reduce the length of the argument list.
Issue an error message and give up. */
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("can't call exec() due to argument size
restrictions"));
}
else
@@ -383,12 +384,13 @@ bc_push_arg (struct buildcmd_control *ctl,
if (state->cmd_argv_chars + len > ctl->arg_max)
{
if (initial_args || state->cmd_argc == ctl->initial_argc)
- error (1, 0, _("can not fit single argument within argument list
size limit"));
+ error (EXIT_FAILURE, 0,
+ _("can not fit single argument within argument list size
limit"));
/* xargs option -i (replace_pat) implies -x (exit_if_size_exceeded)
*/
if (ctl->replace_pat
|| (ctl->exit_if_size_exceeded &&
(ctl->lines_per_exec || ctl->args_per_exec)))
- error (1, 0, _("argument list too long"));
+ error (EXIT_FAILURE, 0, _("argument list too long"));
bc_do_exec (ctl, state);
}
if (bc_argc_limit_reached (initial_args, ctl, state))
@@ -670,8 +672,8 @@ exceeds (const char *env_var_name, size_t quantity)
}
else
{
- error (1, errno, "Environment variable %s "
- "is not set to a valid decimal number",
+ error (EXIT_FAILURE, errno,
+ "Environment variable %s is not set to a valid decimal number",
env_var_name);
return 0;
}
diff --git a/lib/regextype.c b/lib/regextype.c
index 1253d5a..10b956d 100644
--- a/lib/regextype.c
+++ b/lib/regextype.c
@@ -23,6 +23,7 @@
# include <config.h>
#endif
+#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -103,9 +104,10 @@ get_regex_type (const char *s)
p += sprintf (p, "%s", quote (regex_map[i].name));
}
- error (1, 0, _("Unknown regular expression type %s; valid types are %s."),
- quote (s),
- buf);
+ error (EXIT_FAILURE, 0,
+ _("Unknown regular expression type %s; valid types are %s."),
+ quote (s),
+ buf);
/*NOTREACHED*/
return -1;
}
diff --git a/locate/code.c b/locate/code.c
index 1cf5093..daa816a 100644
--- a/locate/code.c
+++ b/locate/code.c
@@ -141,7 +141,7 @@ static void outerr (void)
ATTRIBUTE_NORETURN;
static void
inerr (const char *filename)
{
- error (1, errno, "%s", filename);
+ error (EXIT_FAILURE, errno, "%s", filename);
/*NOTREACHED*/
abort ();
}
@@ -149,7 +149,7 @@ inerr (const char *filename)
static void
outerr (void)
{
- error (1, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
/*NOTREACHED*/
abort ();
}
diff --git a/locate/frcode.c b/locate/frcode.c
index da500fe..67b5471 100644
--- a/locate/frcode.c
+++ b/locate/frcode.c
@@ -178,21 +178,24 @@ get_seclevel (char *s)
result = strtol (s, &p, 10);
if ((0==result) && (p == optarg))
{
- error (1, 0, _("You need to specify a security level as a decimal
integer."));
+ error (EXIT_FAILURE, 0,
+ _("You need to specify a security level as a decimal integer."));
/*NOTREACHED*/
return -1;
}
else if ((LONG_MIN==result || LONG_MAX==result) && errno)
{
- error (1, 0, _("Security level %s is outside the convertible range."),
s);
+ error (EXIT_FAILURE, 0,
+ _("Security level %s is outside the convertible range."), s);
/*NOTREACHED*/
return -1;
}
else if (*p)
{
/* Some suffix exists */
- error (1, 0, _("Security level %s has unexpected suffix %s."), s, p);
+ error (EXIT_FAILURE, 0,
+ _("Security level %s has unexpected suffix %s."), s, p);
/*NOTREACHED*/
return -1;
}
@@ -206,7 +209,7 @@ static void
outerr (void)
{
/* Issue the same error message as closeout () would. */
- error (1, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
int
@@ -247,7 +250,7 @@ main (int argc, char **argv)
slocate_seclevel = get_seclevel (optarg);
if (slocate_seclevel < 0 || slocate_seclevel > 1)
{
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("slocate security level %ld is unsupported."),
slocate_seclevel);
}
@@ -286,7 +289,7 @@ main (int argc, char **argv)
if (fwrite (LOCATEDB_MAGIC, 1, sizeof (LOCATEDB_MAGIC), stdout)
!= sizeof (LOCATEDB_MAGIC))
{
- error (1, errno, _("Failed to write to standard output"));
+ error (EXIT_FAILURE, errno, _("Failed to write to standard output"));
}
}
diff --git a/locate/locate.c b/locate/locate.c
index e90524e..592f754 100644
--- a/locate/locate.c
+++ b/locate/locate.c
@@ -193,8 +193,8 @@ set_max_db_age (const char *s)
if (0 == *s)
{
- error (1, 0,
- _("The argument for option --max-database-age must not be empty"));
+ error (EXIT_FAILURE, 0,
+ _("The argument for option --max-database-age must not be empty"));
}
@@ -209,16 +209,16 @@ set_max_db_age (const char *s)
if ((ULONG_MAX == val && ERANGE == errno) ||
(0 == val && EINVAL == errno))
{
- error (1, errno,
- _("Invalid argument %s for option --max-database-age"),
- quotearg_n_style (0, locale_quoting_style, s));
+ error (EXIT_FAILURE, errno,
+ _("Invalid argument %s for option --max-database-age"),
+ quotearg_n_style (0, locale_quoting_style, s));
}
else if (*end)
{
/* errno wasn't set, don't print its message */
- error (1, 0,
- _("Invalid argument %s for option --max-database-age"),
- quotearg_n_style (0, locale_quoting_style, s));
+ error (EXIT_FAILURE, 0,
+ _("Invalid argument %s for option --max-database-age"),
+ quotearg_n_style (0, locale_quoting_style, s));
}
else
{
@@ -468,7 +468,7 @@ visit_justprint_unquoted (struct process_data *procdata,
void *context)
static void
toolong (struct process_data *procdata)
{
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("locate database %s contains a "
"filename longer than locate can handle"),
procdata->dbfile);
@@ -604,7 +604,7 @@ visit_locate02_format (struct process_data *procdata, void
*context)
* reading in data which is outside our control, we
* cannot prevent it.
*/
- error (1, 0, _("locate database %s is corrupt or invalid"),
+ error (EXIT_FAILURE, 0, _("locate database %s is corrupt or invalid"),
quotearg_n_style (0, locale_quoting_style, procdata->dbfile));
}
@@ -1193,7 +1193,7 @@ search_one_database (int argc,
256 - nread, procdata.fp);
if ( (more_read + nread) != 256 )
{
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("Old-format locate database %s is "
"too short to be valid"),
quotearg_n_style (0, locale_quoting_style, dbfile));
@@ -1238,7 +1238,7 @@ search_one_database (int argc,
&p->regex);
if (error_message)
{
- error (1, 0, "%s", error_message);
+ error (EXIT_FAILURE, 0, "%s", error_message);
}
else
{
@@ -1531,7 +1531,7 @@ drop_privs (void)
return 0;
fail:
- error (1, errno, "%s",
+ error (EXIT_FAILURE, errno, "%s",
quotearg_n_style (0, locale_quoting_style, what));
abort ();
kill (0, SIGKILL);
diff --git a/locate/word_io.c b/locate/word_io.c
index ff17200..dad88b3 100644
--- a/locate/word_io.c
+++ b/locate/word_io.c
@@ -141,9 +141,10 @@ getword (FILE *fp,
* Either condition is fatal.
*/
if (feof (fp))
- error (1, 0, _("unexpected EOF in %s"), quoted_name);
+ error (EXIT_FAILURE, 0, _("unexpected EOF in %s"), quoted_name);
else
- error (1, errno, _("error reading a word from %s"), quoted_name);
+ error (EXIT_FAILURE, errno,
+ _("error reading a word from %s"), quoted_name);
abort ();
}
else
diff --git a/xargs/xargs.c b/xargs/xargs.c
index d8ea2ec..5cda8e2 100644
--- a/xargs/xargs.c
+++ b/xargs/xargs.c
@@ -245,7 +245,7 @@ get_char_oct_or_hex_escape (const char *s)
else
{
p = NULL; /* Silence compiler warning. */
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("Invalid escape sequence %s in input delimiter specification."),
s);
}
@@ -263,13 +263,13 @@ get_char_oct_or_hex_escape (const char *s)
{
if (16 == base)
{
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("Invalid escape sequence %s in input delimiter
specification; character values must not exceed %lx."),
s, (unsigned long)UCHAR_MAX);
}
else
{
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("Invalid escape sequence %s in input delimiter
specification; character values must not exceed %lo."),
s, (unsigned long)UCHAR_MAX);
}
@@ -278,7 +278,7 @@ get_char_oct_or_hex_escape (const char *s)
/* check for trailing garbage */
if (0 != *endp)
{
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("Invalid escape sequence %s in input delimiter specification;
trailing characters %s not recognised."),
s, endp);
}
@@ -323,7 +323,7 @@ get_input_delimiter (const char *s)
}
else
{
- error (1, 0,
+ error (EXIT_FAILURE, 0,
_("Invalid input delimiter specification %s: the delimiter
must be either a single character or an escape sequence starting with \\."),
s);
/*NOTREACHED*/
@@ -341,7 +341,7 @@ noop (void)
static void
fail_due_to_env_size (void)
{
- error (1, 0, _("environment is too large for exec"));
+ error (EXIT_FAILURE, 0, _("environment is too large for exec"));
}
static size_t
@@ -613,7 +613,7 @@ main (int argc, char **argv)
input_stream = fopen (input_file, "r");
if (NULL == input_stream)
{
- error (1, errno,
+ error (EXIT_FAILURE, errno,
_("Cannot open input file %s"),
quotearg_n_style (0, locale_quoting_style, input_file));
}
@@ -786,7 +786,7 @@ read_line (void)
if (state == QUOTE)
{
exec_if_possible ();
- error (1, 0, _("unmatched %s quote; by default quotes are special
to xargs unless you use the -0 option"),
+ error (EXIT_FAILURE, 0, _("unmatched %s quote; by default quotes
are special to xargs unless you use the -0 option"),
quotc == '"' ? _("double") : _("single"));
}
if (first && EOF_STR (linebuf))
@@ -879,7 +879,7 @@ read_line (void)
if (c == '\n')
{
exec_if_possible ();
- error (1, 0, _("unmatched %s quote; by default quotes are special
to xargs unless you use the -0 option"),
+ error (EXIT_FAILURE, 0, _("unmatched %s quote; by default quotes
are special to xargs unless you use the -0 option"),
quotc == '"' ? _("double") : _("single"));
}
if (c == quotc)
@@ -909,7 +909,7 @@ read_line (void)
if (p >= endbuf)
{
exec_if_possible ();
- error (1, 0, _("argument line too long"));
+ error (EXIT_FAILURE, 0, _("argument line too long"));
}
*p++ = c;
#else
@@ -966,7 +966,7 @@ read_string (void)
if (p >= endbuf)
{
exec_if_possible ();
- error (1, 0, _("argument line too long"));
+ error (EXIT_FAILURE, 0, _("argument line too long"));
}
*p++ = c;
}
@@ -993,7 +993,8 @@ print_args (boolean ask)
{
tty_stream = fopen ("/dev/tty", "r");
if (!tty_stream)
- error (1, errno, _("failed to open /dev/tty for reading"));
+ error (EXIT_FAILURE, errno,
+ _("failed to open /dev/tty for reading"));
}
fputs ("?...", stderr);
fflush (stderr);
@@ -1076,7 +1077,7 @@ xargs_do_exec (struct buildcmd_control *ctl, void
*usercontext, int argc, char *
wait_for_proc (false, 0u);
if (pipe (fd))
- error (1, errno, _("could not create pipe before fork"));
+ error (EXIT_FAILURE, errno, _("could not create pipe before fork"));
fcntl (fd[1], F_SETFD, FD_CLOEXEC);
/* If we run out of processes, wait for a child to return and
@@ -1087,7 +1088,7 @@ xargs_do_exec (struct buildcmd_control *ctl, void
*usercontext, int argc, char *
switch (child)
{
case -1:
- error (1, errno, _("cannot fork"));
+ error (EXIT_FAILURE, errno, _("cannot fork"));
case 0: /* Child. */
{
@@ -1195,7 +1196,8 @@ xargs_do_exec (struct buildcmd_control *ctl, void
*usercontext, int argc, char *
}
default:
{
- error (1, errno, "read returned unexpected value %d! BUG?", r);
+ error (EXIT_FAILURE, errno,
+ "read returned unexpected value %d! BUG?", r);
}
} /* switch on bytes read */
close (fd[0]);
@@ -1283,7 +1285,8 @@ wait_for_proc (boolean all, unsigned int minreap)
while ((pid = waitpid (-1, &status, wflags)) == (pid_t) -1)
{
if (errno != EINTR)
- error (1, errno, _("error waiting for child process"));
+ error (EXIT_FAILURE, errno,
+ _("error waiting for child process"));
}
/* Find the entry in `pids' for the child process
--
1.5.6.5