summaryrefslogtreecommitdiff
path: root/src/md5sum.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-09-19 02:21:09 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-09-19 02:21:09 +0000
commitfdac7ecb116b9cf3e318c3923ff840354b80eb6a (patch)
tree90ab0b13eadf928ec9a8d6a8ad8e25213b1b002e /src/md5sum.c
parent6de3d41d5fe52c3b3472f06916ca2d8b4a008df4 (diff)
downloadcoreutils-fdac7ecb116b9cf3e318c3923ff840354b80eb6a.tar.xz
(STATUS_OPTION, STRING_OPTION): New enums.
(long_options, main): Use them instead of magic numbers 2 and 1. For --string, optarg can't possibly be NULL.
Diffstat (limited to 'src/md5sum.c')
-rw-r--r--src/md5sum.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/md5sum.c b/src/md5sum.c
index 4bf353db5..9a9bdb223 100644
--- a/src/md5sum.c
+++ b/src/md5sum.c
@@ -101,12 +101,20 @@ static bool warn = false;
/* The name this program was run with. */
char *program_name;
+/* For long options that have no equivalent short option, use a
+ non-character as a pseudo short option, starting with CHAR_MAX + 1. */
+enum
+{
+ STATUS_OPTION = CHAR_MAX + 1,
+ STRING_OPTION
+};
+
static const struct option long_options[] =
{
{ "binary", no_argument, 0, 'b' },
{ "check", no_argument, 0, 'c' },
- { "status", no_argument, 0, 2 },
- { "string", required_argument, 0, 1 },
+ { "status", no_argument, 0, STATUS_OPTION },
+ { "string", required_argument, 0, STRING_OPTION },
{ "text", no_argument, 0, 't' },
{ "warn", no_argument, 0, 'w' },
{ GETOPT_HELP_OPTION_DECL },
@@ -576,15 +584,10 @@ main (int argc, char **argv)
while ((opt = getopt_long (argc, argv, "bctw", long_options, NULL)) != -1)
switch (opt)
{
- case 0: /* long option */
- break;
- case 1: /* --string */
+ case STRING_OPTION:
{
if (string == NULL)
string = xnmalloc (argc - 1, sizeof *string);
-
- if (optarg == NULL)
- optarg = "";
string[n_strings++] = optarg;
}
break;
@@ -595,7 +598,7 @@ main (int argc, char **argv)
case 'c':
do_check = true;
break;
- case 2:
+ case STATUS_OPTION:
status_only = true;
warn = false;
break;