summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1995-03-07 22:31:01 +0000
committerRoland McGrath <roland@redhat.com>1995-03-07 22:31:01 +0000
commit636435e5c25d39fc5d52edf936e8e7a410b31b1a (patch)
tree4d919a44a8b370ff258e29faae6cef860a0bc5d1
parent0733d6947d326c78d04cd9d37e3dce8c1aed4e5a (diff)
downloadgunmake-636435e5c25d39fc5d52edf936e8e7a410b31b1a.tar.gz
(decode_switches): If non-option arg is "-", ignore it.
-rw-r--r--main.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/main.c b/main.c
index 43a6b89..29615e0 100644
--- a/main.c
+++ b/main.c
@@ -1223,30 +1223,31 @@ decode_switches (argc, argv, env)
/* Reset getopt's state. */
optind = 0;
- c = 0;
while (optind < argc)
{
+ /* Parse the next argument. */
+ c = getopt_long (argc, argv, options, long_options, (int *) 0);
if (c == EOF)
{
/* There are no more options according to getting getopt, but
there are some arguments left. Since we have asked for
non-option arguments to be returned in order, I think this
only happens when there is a "--" argument to prevent later
- argument from being options. Since getopt has finished its
+ arguments from being options. Since getopt has finished its
job, just update its state variables for the next argument and
set C as if it had returned 1, indicating a non-option
argument. */
optarg = argv[optind++];
c = 1;
}
- else
- /* Parse the next argument. */
- c = getopt_long (argc, argv, options, long_options, (int *) 0);
if (c == 1)
{
/* Non-option argument. It might be a variable definition. */
struct variable *v;
+ if (optarg[0] == '-' && optarg[1] == '\0')
+ /* Ignore plain `-' for compatibility. */
+ continue;
v = try_variable_definition ((char *) 0, 0, optarg, o_command);
if (v != 0)
{