summaryrefslogtreecommitdiff
path: root/src/split.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-10-13 17:53:47 +0000
committerJim Meyering <jim@meyering.net>1996-10-13 17:53:47 +0000
commitbc2d814543bc427bd4900abbd0958605fa993248 (patch)
treec39737f4583d8a140b52db842aa4c9ba29b8553e /src/split.c
parent8cb23387cbe71194651f956170f9332fa939ae0f (diff)
downloadcoreutils-bc2d814543bc427bd4900abbd0958605fa993248.tar.xz
(usage): Remove parameter, REASON.
(main): Update callers to use combination of error (0, 0, ... and usage (EXIT_FAILURE).
Diffstat (limited to 'src/split.c')
-rw-r--r--src/split.c55
1 files changed, 40 insertions, 15 deletions
diff --git a/src/split.c b/src/split.c
index 3e3684144..42cf2f90d 100644
--- a/src/split.c
+++ b/src/split.c
@@ -91,11 +91,8 @@ static struct option const longopts[] =
};
static void
-usage (int status, const char *reason)
+usage (int status)
{
- if (reason != NULL)
- fprintf (stderr, "%s: %s\n", program_name, reason);
-
if (status != 0)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
@@ -396,31 +393,50 @@ main (int argc, char **argv)
case 'b':
if (split_type != type_undef)
- usage (2, _("cannot split in more than one way"));
+ {
+ error (0, 0, _("cannot split in more than one way"));
+ usage (EXIT_FAILURE);
+ }
split_type = type_bytes;
if (xstrtol (optarg, NULL, 10, &tmp_long, "bkm") != LONGINT_OK
|| tmp_long < 0 || tmp_long > INT_MAX)
- usage (2, _("invalid number of bytes"));
+ {
+ error (0, 0, _("%s: invalid number of bytes"), optarg);
+ usage (EXIT_FAILURE);
+ }
accum = (int) tmp_long;
break;
case 'l':
if (split_type != type_undef)
- usage (2, _("cannot split in more than one way"));
+ {
+ error (0, 0, _("cannot split in more than one way"));
+ usage (EXIT_FAILURE);
+ }
split_type = type_lines;
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long < 0 || tmp_long > INT_MAX)
- usage (2, _("invalid number of lines"));
+ {
+ error (0, 0, _("%s: invalid number of lines"), optarg);
+ usage (EXIT_FAILURE);
+ }
accum = (int) tmp_long;
break;
case 'C':
if (split_type != type_undef)
- usage (2, _("cannot split in more than one way"));
+ {
+ error (0, 0, _("cannot split in more than one way"));
+ usage (EXIT_FAILURE);
+ }
+
split_type = type_byteslines;
if (xstrtol (optarg, NULL, 10, &tmp_long, "bkm") != LONGINT_OK
|| tmp_long < 0 || tmp_long > INT_MAX)
- usage (2, _("invalid number of bytes"));
+ {
+ error (0, 0, _("%s: invalid number of bytes"), optarg);
+ usage (EXIT_FAILURE);
+ }
accum = (int) tmp_long;
break;
@@ -435,7 +451,10 @@ main (int argc, char **argv)
case '8':
case '9':
if (split_type != type_undef && split_type != type_digits)
- usage (2, _("cannot split in more than one way"));
+ {
+ error (0, 0, _("cannot split in more than one way"));
+ usage (EXIT_FAILURE);
+ }
if (digits_optind != 0 && digits_optind != this_optind)
accum = 0; /* More than one number given; ignore other. */
digits_optind = this_optind;
@@ -448,7 +467,7 @@ main (int argc, char **argv)
break;
default:
- usage (2, (char *)0);
+ usage (EXIT_FAILURE);
}
}
@@ -459,7 +478,7 @@ main (int argc, char **argv)
}
if (show_help)
- usage (0, (char *)0);
+ usage (0);
/* Handle default case. */
if (split_type == type_undef)
@@ -469,7 +488,10 @@ main (int argc, char **argv)
}
if (accum < 1)
- usage (2, _("invalid number"));
+ {
+ error (0, 0, _("invalid number"));
+ usage (EXIT_FAILURE);
+ }
num = accum;
/* Get out the filename arguments. */
@@ -481,7 +503,10 @@ main (int argc, char **argv)
outbase = argv[optind++];
if (optind < argc)
- usage (2, _("too many arguments"));
+ {
+ error (0, 0, _("too many arguments"));
+ usage (EXIT_FAILURE);
+ }
/* Open the input file. */
if (!strcmp (infile, "-"))