mirror of
https://sourceware.org/git/glibc.git
synced 2025-12-24 17:51:17 +03:00
Fix -W with optional parameters in getopt.
According to the getopt documentation, if "W;" is part of optstring, then '-W foo' should behave like '--foo'. But if "foo" uses an optional_argument, this is not the case, since optarg is not NULL when using -W.
This commit is contained in:
committed by
Ulrich Drepper
parent
22ef35456e
commit
aa7f642769
@@ -911,7 +911,10 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring,
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
}
|
||||
else
|
||||
else if (long_only
|
||||
|| pfound->has_arg != p->has_arg
|
||||
|| pfound->flag != p->flag
|
||||
|| pfound->val != p->val)
|
||||
/* Second or later nonexact match found. */
|
||||
ambig = 1;
|
||||
}
|
||||
@@ -1028,6 +1031,8 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring,
|
||||
return optstring[0] == ':' ? ':' : '?';
|
||||
}
|
||||
}
|
||||
else
|
||||
d->optarg = NULL;
|
||||
d->__nextchar += strlen (d->__nextchar);
|
||||
if (longind != NULL)
|
||||
*longind = option_index;
|
||||
|
||||
Reference in New Issue
Block a user