};
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);
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;
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;
break;
default:
- usage (2, (char *)0);
+ usage (EXIT_FAILURE);
}
}
}
if (show_help)
- usage (0, (char *)0);
+ usage (0);
/* Handle default case. */
if (split_type == type_undef)
}
if (accum < 1)
- usage (2, _("invalid number"));
+ {
+ error (0, 0, _("invalid number"));
+ usage (EXIT_FAILURE);
+ }
num = accum;
/* Get out the filename arguments. */
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, "-"))