mirror of
https://github.com/fluencelabs/musl
synced 2025-05-28 23:21:34 +00:00
always set optarg in getopt_long
the standard getopt does not touch optarg unless processing an option with an argument. however, programs using the GNU getopt API, which we attempt to provide in getopt_long, expect optarg to be a null pointer after processing an option without an argument. before argument permutation support was added, such programs typically detected its absence and used their own replacement getopt_long, masking the discrepency in behavior.
This commit is contained in:
parent
78a8ef47c4
commit
e8e4e56a8c
@ -51,7 +51,7 @@ static int __getopt_long(int argc, char *const *argv, const char *optstring, con
|
|||||||
|
|
||||||
static int __getopt_long_core(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly)
|
static int __getopt_long_core(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly)
|
||||||
{
|
{
|
||||||
|
optarg = 0;
|
||||||
if (longopts && argv[optind][0] == '-' &&
|
if (longopts && argv[optind][0] == '-' &&
|
||||||
((longonly && argv[optind][1]) ||
|
((longonly && argv[optind][1]) ||
|
||||||
(argv[optind][1] == '-' && argv[optind][2])))
|
(argv[optind][1] == '-' && argv[optind][2])))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user