mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-10 21:38:19 -05:00
check for -1 return value from getopt_long
getopt_long returns -1 when it has finished parsing all args. A return value of 0 indicates that a flag was set directly by getopt_long and parsing should continue. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
1c5b94e6bb
commit
08191b13f2
@ -879,10 +879,8 @@ static int parseargs(int argc, char *argv[])
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* parse operation */
|
/* parse operation */
|
||||||
while((opt = getopt_long(argc, argv, optstring, opts, &option_index))) {
|
while((opt = getopt_long(argc, argv, optstring, opts, &option_index)) != -1) {
|
||||||
if(opt < 0) {
|
if(opt == 0) {
|
||||||
break;
|
|
||||||
} else if(opt == 0) {
|
|
||||||
continue;
|
continue;
|
||||||
} else if(opt == '?') {
|
} else if(opt == '?') {
|
||||||
/* unknown option, getopt printed an error */
|
/* unknown option, getopt printed an error */
|
||||||
@ -906,10 +904,8 @@ static int parseargs(int argc, char *argv[])
|
|||||||
|
|
||||||
/* parse all other options */
|
/* parse all other options */
|
||||||
optind = 1;
|
optind = 1;
|
||||||
while((opt = getopt_long(argc, argv, optstring, opts, &option_index))) {
|
while((opt = getopt_long(argc, argv, optstring, opts, &option_index)) != -1) {
|
||||||
if(opt < 0) {
|
if(opt == 0) {
|
||||||
break;
|
|
||||||
} else if(opt == 0) {
|
|
||||||
continue;
|
continue;
|
||||||
} else if(opt == '?') {
|
} else if(opt == '?') {
|
||||||
/* this should have failed during first pass already */
|
/* this should have failed during first pass already */
|
||||||
|
Loading…
Reference in New Issue
Block a user