fix getopt_long_only misinterpreting "--" as an option

This commit is contained in:
Rich Felker 2016-10-20 12:13:33 -04:00
parent 51ab6db4ed
commit b24f1d2520

View File

@ -53,7 +53,7 @@ static int __getopt_long_core(int argc, char *const *argv, const char *optstring
{
optarg = 0;
if (longopts && argv[optind][0] == '-' &&
((longonly && argv[optind][1]) ||
((longonly && argv[optind][1] && argv[optind][1] != '-') ||
(argv[optind][1] == '-' && argv[optind][2])))
{
int colon = optstring[optstring[0]=='+'||optstring[0]=='-']==':';