summaryrefslogtreecommitdiff
path: root/locate
diff options
context:
space:
mode:
Diffstat (limited to 'locate')
-rw-r--r--locate/frcode.c29
-rw-r--r--locate/locate.c49
-rw-r--r--locate/word_io.c7
3 files changed, 44 insertions, 41 deletions
diff --git a/locate/frcode.c b/locate/frcode.c
index 109296c0..f0121268 100644
--- a/locate/frcode.c
+++ b/locate/frcode.c
@@ -84,10 +84,11 @@
#include "xalloc.h"
/* find headers. */
-#include "findutils-version.h"
#include "bugreports.h"
-#include "locatedb.h"
+#include "die.h"
+#include "findutils-version.h"
#include "gcc-function-attributes.h"
+#include "locatedb.h"
#if ENABLE_NLS
# include <libintl.h>
@@ -173,24 +174,24 @@ get_seclevel (char *s)
result = strtol (s, &p, 10);
if ((0==result) && (p == optarg))
{
- error (EXIT_FAILURE, 0,
- _("You need to specify a security level as a decimal integer."));
+ die (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 (EXIT_FAILURE, 0,
- _("Security level %s is outside the convertible range."), s);
+ die (EXIT_FAILURE, 0,
+ _("Security level %s is outside the convertible range."), s);
/*NOTREACHED*/
return -1;
}
else if (*p)
{
/* Some suffix exists */
- error (EXIT_FAILURE, 0,
- _("Security level %s has unexpected suffix %s."), s, p);
+ die (EXIT_FAILURE, 0,
+ _("Security level %s has unexpected suffix %s."), s, p);
/*NOTREACHED*/
return -1;
}
@@ -204,7 +205,7 @@ static void
outerr (void)
{
/* Issue the same error message as closeout () would. */
- error (EXIT_FAILURE, errno, _("write error"));
+ die (EXIT_FAILURE, errno, _("write error"));
}
int
@@ -227,7 +228,7 @@ main (int argc, char **argv)
if (atexit (close_stdout))
{
- error (EXIT_FAILURE, errno, _("The atexit library function failed"));
+ die (EXIT_FAILURE, errno, _("The atexit library function failed"));
}
pathsize = oldpathsize = 1026; /* Increased as necessary by getline. */
@@ -250,9 +251,9 @@ main (int argc, char **argv)
slocate_seclevel = get_seclevel (optarg);
if (slocate_seclevel < 0 || slocate_seclevel > 1)
{
- error (EXIT_FAILURE, 0,
- _("slocate security level %ld is unsupported."),
- slocate_seclevel);
+ die (EXIT_FAILURE, 0,
+ _("slocate security level %ld is unsupported."),
+ slocate_seclevel);
}
break;
@@ -287,7 +288,7 @@ main (int argc, char **argv)
if (fwrite (LOCATEDB_MAGIC, 1, sizeof (LOCATEDB_MAGIC), stdout)
!= sizeof (LOCATEDB_MAGIC))
{
- error (EXIT_FAILURE, errno, _("Failed to write to standard output"));
+ die (EXIT_FAILURE, errno, _("Failed to write to standard output"));
}
}
diff --git a/locate/locate.c b/locate/locate.c
index 2fce944d..4f081d18 100644
--- a/locate/locate.c
+++ b/locate/locate.c
@@ -94,12 +94,13 @@
#include "stat-time.h"
/* find headers. */
+#include "bugreports.h"
+#include "die.h"
#include "findutils-version.h"
+#include "gcc-function-attributes.h"
#include "locatedb.h"
#include "printquoted.h"
-#include "bugreports.h"
#include "splitstring.h"
-#include "gcc-function-attributes.h"
#if ENABLE_NLS
@@ -176,8 +177,8 @@ set_max_db_age (const char *s)
if (0 == *s)
{
- error (EXIT_FAILURE, 0,
- _("The argument for option --max-database-age must not be empty"));
+ die (EXIT_FAILURE, 0,
+ _("The argument for option --max-database-age must not be empty"));
}
@@ -192,16 +193,16 @@ set_max_db_age (const char *s)
if ((ULONG_MAX == val && ERANGE == errno) ||
(0 == val && EINVAL == errno))
{
- error (EXIT_FAILURE, errno,
- _("Invalid argument %s for option --max-database-age"),
- quotearg_n_style (0, locale_quoting_style, s));
+ die (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 (EXIT_FAILURE, 0,
- _("Invalid argument %s for option --max-database-age"),
- quotearg_n_style (0, locale_quoting_style, s));
+ die (EXIT_FAILURE, 0,
+ _("Invalid argument %s for option --max-database-age"),
+ quotearg_n_style (0, locale_quoting_style, s));
}
else
{
@@ -449,10 +450,10 @@ visit_justprint_unquoted (struct process_data *procdata, void *context)
static void
toolong (struct process_data *procdata)
{
- error (EXIT_FAILURE, 0,
- _("locate database %s contains a "
- "filename longer than locate can handle"),
- procdata->dbfile);
+ die (EXIT_FAILURE, 0,
+ _("locate database %s contains a "
+ "filename longer than locate can handle"),
+ procdata->dbfile);
}
static void
@@ -561,8 +562,8 @@ visit_locate02_format (struct process_data *procdata, void *context)
* reading in data which is outside our control, we
* cannot prevent it.
*/
- error (EXIT_FAILURE, 0, _("locate database %s is corrupt or invalid"),
- quotearg_n_style (0, locale_quoting_style, procdata->dbfile));
+ die (EXIT_FAILURE, 0, _("locate database %s is corrupt or invalid"),
+ quotearg_n_style (0, locale_quoting_style, procdata->dbfile));
}
/* Overlay the old path with the remainder of the new. */
@@ -1162,10 +1163,10 @@ search_one_database (int argc,
256 - nread, procdata.fp);
if ( (more_read + nread) != 256 )
{
- error (EXIT_FAILURE, 0,
- _("Old-format locate database %s is "
- "too short to be valid"),
- quotearg_n_style (0, locale_quoting_style, dbfile));
+ die (EXIT_FAILURE, 0,
+ _("Old-format locate database %s is "
+ "too short to be valid"),
+ quotearg_n_style (0, locale_quoting_style, dbfile));
}
}
@@ -1207,7 +1208,7 @@ search_one_database (int argc,
&p->regex);
if (error_message)
{
- error (EXIT_FAILURE, 0, "%s", error_message);
+ die (EXIT_FAILURE, 0, "%s", error_message);
}
else
{
@@ -1510,8 +1511,8 @@ drop_privs (void)
return 0;
fail:
- error (EXIT_FAILURE, errno, "%s",
- quotearg_n_style (0, locale_quoting_style, what));
+ die (EXIT_FAILURE, errno, "%s",
+ quotearg_n_style (0, locale_quoting_style, what));
abort ();
kill (0, SIGKILL);
_exit (1);
@@ -1585,7 +1586,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
quote_opts = clone_quoting_options (NULL);
if (atexit (close_stdout) || atexit (cleanup_quote_opts))
{
- error (EXIT_FAILURE, errno, _("The atexit library function failed"));
+ die (EXIT_FAILURE, errno, _("The atexit library function failed"));
}
limits.limit = 0;
diff --git a/locate/word_io.c b/locate/word_io.c
index bc5f4ad8..51be32c3 100644
--- a/locate/word_io.c
+++ b/locate/word_io.c
@@ -32,6 +32,7 @@
#include "quotearg.h"
/* find headers. */
+#include "die.h"
#include "locatedb.h"
#if ENABLE_NLS
@@ -128,10 +129,10 @@ getword (FILE *fp,
* Either condition is fatal.
*/
if (feof (fp))
- error (EXIT_FAILURE, 0, _("unexpected EOF in %s"), quoted_name);
+ die (EXIT_FAILURE, 0, _("unexpected EOF in %s"), quoted_name);
else
- error (EXIT_FAILURE, errno,
- _("error reading a word from %s"), quoted_name);
+ die (EXIT_FAILURE, errno,
+ _("error reading a word from %s"), quoted_name);
abort ();
}
else