summaryrefslogtreecommitdiff
path: root/src/ptx.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2016-10-15 23:10:35 +0100
committerPádraig Brady <P@draigBrady.com>2016-10-16 12:23:55 +0100
commit492dcb2eb191b844a2fd5e51db3eed85289bea1f (patch)
tree910f93d88891b573520ebd5c812d61ddc7fbeed8 /src/ptx.c
parentd035eacfdeba2da0134e606c8a63b2f3c0bd05bb (diff)
downloadcoreutils-492dcb2eb191b844a2fd5e51db3eed85289bea1f.tar.xz
all: use die() rather than error(EXIT_FAILURE)
die() has the advantage of being apparent to the compiler that it doesn't return, which will avoid warnings in some cases, and possibly generate better code. * cfg.mk (sc_die_EXIT_FAILURE): A new syntax check rule to catch any new uses of error (CONSTANT, ...);
Diffstat (limited to 'src/ptx.c')
-rw-r--r--src/ptx.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/ptx.c b/src/ptx.c
index 1f0e9c921..c3b60dfa5 100644
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -22,6 +22,7 @@
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
+#include "die.h"
#include <regex.h>
#include "argmatch.h"
#include "diacrit.h"
@@ -280,8 +281,7 @@ static BLOCK reference; /* reference field for input reference mode */
static void ATTRIBUTE_NORETURN
matcher_error (void)
{
- error (0, errno, _("error in regular expression matcher"));
- exit (EXIT_FAILURE);
+ die (EXIT_FAILURE, errno, _("error in regular expression matcher"));
}
/*------------------------------------------------------.
@@ -416,7 +416,7 @@ compile_regex (struct regex_data *regex)
message = re_compile_pattern (string, strlen (string), pattern);
if (message)
- error (EXIT_FAILURE, 0, _("%s (for regexp %s)"), message, quote (string));
+ die (EXIT_FAILURE, 0, _("%s (for regexp %s)"), message, quote (string));
/* The fastmap should be compiled before 're_match'. The following
call is not mandatory, because 're_search' is always called sooner,
@@ -520,7 +520,7 @@ swallow_file_in_memory (const char *file_name, BLOCK *block)
block->start = read_file (file_name, &used_length);
if (!block->start)
- error (EXIT_FAILURE, errno, "%s", quotef (using_stdin ? "-" : file_name));
+ die (EXIT_FAILURE, errno, "%s", quotef (using_stdin ? "-" : file_name));
block->end = block->start + used_length;
}
@@ -1947,8 +1947,8 @@ main (int argc, char **argv)
unsigned long int tmp_ulong;
if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK
|| ! (0 < tmp_ulong && tmp_ulong <= INT_MAX))
- error (EXIT_FAILURE, 0, _("invalid gap width: %s"),
- quote (optarg));
+ die (EXIT_FAILURE, 0, _("invalid gap width: %s"),
+ quote (optarg));
gap_size = tmp_ulong;
break;
}
@@ -1974,8 +1974,8 @@ main (int argc, char **argv)
unsigned long int tmp_ulong;
if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK
|| ! (0 < tmp_ulong && tmp_ulong <= INT_MAX))
- error (EXIT_FAILURE, 0, _("invalid line width: %s"),
- quote (optarg));
+ die (EXIT_FAILURE, 0, _("invalid line width: %s"),
+ quote (optarg));
line_width = tmp_ulong;
break;
}
@@ -2076,7 +2076,7 @@ main (int argc, char **argv)
if (optind < argc)
{
if (! freopen (argv[optind], "w", stdout))
- error (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
+ die (EXIT_FAILURE, errno, "%s", quotef (argv[optind]));
optind++;
}