summaryrefslogtreecommitdiff
path: root/src/csplit.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/csplit.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/csplit.c')
-rw-r--r--src/csplit.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/src/csplit.c b/src/csplit.c
index 30a97e572..4b90c000d 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -542,7 +542,7 @@ static uintmax_t
get_first_line_in_buffer (void)
{
if (head == NULL && !load_buffer ())
- error (EXIT_FAILURE, errno, _("input disappeared"));
+ die (EXIT_FAILURE, errno, _("input disappeared"));
return head->first_available;
}
@@ -652,8 +652,8 @@ static void
set_input_file (const char *name)
{
if (! STREQ (name, "-") && fd_reopen (STDIN_FILENO, name, O_RDONLY, 0) < 0)
- error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
- quoteaf (name));
+ die (EXIT_FAILURE, errno, _("cannot open %s for reading"),
+ quoteaf (name));
}
/* Write all lines from the beginning of the buffer up to, but
@@ -1090,8 +1090,8 @@ static void
check_for_offset (struct control *p, const char *str, const char *num)
{
if (xstrtoimax (num, NULL, 10, &p->offset, "") != LONGINT_OK)
- error (EXIT_FAILURE, 0, _("%s: integer expected after delimiter"),
- quote (str));
+ die (EXIT_FAILURE, 0, _("%s: integer expected after delimiter"),
+ quote (str));
}
/* Given that the first character of command line arg STR is '{',
@@ -1107,8 +1107,8 @@ parse_repeat_count (int argnum, struct control *p, char *str)
end = str + strlen (str) - 1;
if (*end != '}')
- error (EXIT_FAILURE, 0, _("%s: '}' is required in repeat count"),
- quote (str));
+ die (EXIT_FAILURE, 0, _("%s: '}' is required in repeat count"),
+ quote (str));
*end = '\0';
if (str+1 == end-1 && *(str+1) == '*')
@@ -1117,9 +1117,9 @@ parse_repeat_count (int argnum, struct control *p, char *str)
{
if (xstrtoumax (str + 1, NULL, 10, &val, "") != LONGINT_OK)
{
- error (EXIT_FAILURE, 0,
- _("%s}: integer required between '{' and '}'"),
- quote (global_argv[argnum]));
+ die (EXIT_FAILURE, 0,
+ _("%s}: integer required between '{' and '}'"),
+ quote (global_argv[argnum]));
}
p->repeat = val;
}
@@ -1144,8 +1144,8 @@ extract_regexp (int argnum, bool ignore, char const *str)
closing_delim = strrchr (str + 1, delim);
if (closing_delim == NULL)
- error (EXIT_FAILURE, 0,
- _("%s: closing delimiter '%c' missing"), str, delim);
+ die (EXIT_FAILURE, 0,
+ _("%s: closing delimiter '%c' missing"), str, delim);
len = closing_delim - str - 1;
p = new_control_record ();
@@ -1195,17 +1195,16 @@ parse_patterns (int argc, int start, char **argv)
p->argnum = i;
if (xstrtoumax (argv[i], NULL, 10, &val, "") != LONGINT_OK)
- error (EXIT_FAILURE, 0, _("%s: invalid pattern"), quote (argv[i]));
+ die (EXIT_FAILURE, 0, _("%s: invalid pattern"), quote (argv[i]));
if (val == 0)
- error (EXIT_FAILURE, 0,
- _("%s: line number must be greater than zero"),
- argv[i]);
+ die (EXIT_FAILURE, 0,
+ _("%s: line number must be greater than zero"), argv[i]);
if (val < last_val)
{
char buf[INT_BUFSIZE_BOUND (uintmax_t)];
- error (EXIT_FAILURE, 0,
+ die (EXIT_FAILURE, 0,
_("line number %s is smaller than preceding line number, %s"),
- quote (argv[i]), umaxtostr (last_val, buf));
+ quote (argv[i]), umaxtostr (last_val, buf));
}
if (val == last_val)
@@ -1292,17 +1291,17 @@ check_format_conv_type (char *format, int flags)
default:
if (isprint (ch))
- error (EXIT_FAILURE, 0,
- _("invalid conversion specifier in suffix: %c"), ch);
+ die (EXIT_FAILURE, 0,
+ _("invalid conversion specifier in suffix: %c"), ch);
else
- error (EXIT_FAILURE, 0,
- _("invalid conversion specifier in suffix: \\%.3o"), ch);
+ die (EXIT_FAILURE, 0,
+ _("invalid conversion specifier in suffix: \\%.3o"), ch);
}
if (flags & ~ compatible_flags)
- error (EXIT_FAILURE, 0,
- _("invalid flags in conversion specification: %%%c%c"),
- (flags & ~ compatible_flags & FLAG_ALTERNATIVE ? '#' : '\''), ch);
+ die (EXIT_FAILURE, 0,
+ _("invalid flags in conversion specification: %%%c%c"),
+ (flags & ~ compatible_flags & FLAG_ALTERNATIVE ? '#' : '\''), ch);
}
/* Return the maximum number of bytes that can be generated by
@@ -1317,8 +1316,8 @@ max_out (char *format)
if (*f == '%' && *++f != '%')
{
if (percent)
- error (EXIT_FAILURE, 0,
- _("too many %% conversion specifications in suffix"));
+ die (EXIT_FAILURE, 0,
+ _("too many %% conversion specifications in suffix"));
percent = true;
int flags;
f += get_format_flags (f, &flags);
@@ -1331,8 +1330,8 @@ max_out (char *format)
}
if (! percent)
- error (EXIT_FAILURE, 0,
- _("missing %% conversion specification in suffix"));
+ die (EXIT_FAILURE, 0,
+ _("missing %% conversion specification in suffix"));
int maxlen = snprintf (NULL, 0, format, UINT_MAX);
if (! (0 <= maxlen && maxlen <= SIZE_MAX))