summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1993-05-22 20:20:16 +0000
committerRoland McGrath <roland@redhat.com>1993-05-22 20:20:16 +0000
commitfe92d8e656276d1100785ac2e58da3205f1415f7 (patch)
tree403b48922db70afb781dd9d8f3b29572bf348025 /main.c
parentf0080188b73239eba4ce6699270b80aa226fa0a2 (diff)
downloadgunmake-fe92d8e656276d1100785ac2e58da3205f1415f7.tar.gz
Formerly main.c.~82~
Diffstat (limited to 'main.c')
-rw-r--r--main.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/main.c b/main.c
index 50cad3a..c4396e2 100644
--- a/main.c
+++ b/main.c
@@ -91,8 +91,7 @@ struct command_switch
string, /* One string per switch. */
positive_int, /* A positive integer. */
floating, /* A floating-point number (double). */
- ignore, /* Ignored. */
- usage_and_exit /* Ignored; exit after processing switches. */
+ ignore /* Ignored. */
} type;
char *value_ptr; /* Pointer to the value-holding variable. */
@@ -219,6 +218,10 @@ static struct stringlist *old_files = 0;
/* List of files given with -W switches. */
static struct stringlist *new_files = 0;
+
+/* If nonzero, we should just print usage and exit. */
+
+static int print_usage_flag = 0;
/* The table of command switches. */
@@ -239,7 +242,7 @@ static const struct command_switch switches[] =
{ 'f', string, (char *) &makefiles, 0, 0, 0, 0, 0,
"file", "FILE",
"Read FILE as a makefile" },
- { 'h', usage_and_exit, 0, 0, 0, 0, 0, 0,
+ { 'h', flag, (char *) &print_usage_flag, 0, 0, 0, 0, 0,
"help", 0,
"Print this message and exit" },
{ 'i', flag, (char *) &ignore_errors_flag, 1, 1, 0, 0, 0,
@@ -500,7 +503,7 @@ main (argc, argv, envp)
/* `make --version' is supposed to just print the version and exit. */
if (print_version_flag)
- die (1);
+ die (0);
/* Search for command line arguments that define variables,
and do the definitions. Also save up the text of these
@@ -1085,7 +1088,6 @@ init_switches ()
case flag:
case flag_off:
case ignore:
- case usage_and_exit:
long_options[i].has_arg = no_argument;
break;
@@ -1173,10 +1175,6 @@ decode_switches (argc, argv, env)
case ignore:
break;
- case usage_and_exit:
- bad = 1;
- break;
-
case flag:
case flag_off:
if (doit)
@@ -1269,7 +1267,7 @@ positive integral argument",
other_args->list[other_args->idx] = 0;
}
- if (bad && !env)
+ if (!env && (bad || print_usage_flag))
{
/* Print a nice usage message. */
@@ -1355,7 +1353,7 @@ positive integral argument",
buf, cs->description);
}
- die (1);
+ die (bad);
}
}