corrected the --longoption parser
This commit is contained in:
parent
2918836cef
commit
5b39a48e22
13
src/main.c
13
src/main.c
@ -504,23 +504,26 @@ static int getparameter(char *flag, /* f or -long-flag */
|
|||||||
if('-' == flag[0]) {
|
if('-' == flag[0]) {
|
||||||
/* try a long name */
|
/* try a long name */
|
||||||
int fnam=strlen(&flag[1]);
|
int fnam=strlen(&flag[1]);
|
||||||
|
int numhits=0;
|
||||||
for(j=0; j< sizeof(aliases)/sizeof(aliases[0]); j++) {
|
for(j=0; j< sizeof(aliases)/sizeof(aliases[0]); j++) {
|
||||||
if(strnequal(aliases[j].lname, &flag[1], fnam)) {
|
if(strnequal(aliases[j].lname, &flag[1], fnam)) {
|
||||||
longopt = TRUE;
|
longopt = TRUE;
|
||||||
|
numhits++;
|
||||||
if(strequal(aliases[j].lname, &flag[1])) {
|
if(strequal(aliases[j].lname, &flag[1])) {
|
||||||
parse = aliases[j].letter;
|
parse = aliases[j].letter;
|
||||||
hit = j;
|
hit = j;
|
||||||
|
numhits = 1; /* a single unique hit */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(parse) {
|
|
||||||
/* this is the second match, we can't continue! */
|
|
||||||
helpf("option --%s is ambiguous\n", &flag[1]);
|
|
||||||
return CURLE_FAILED_INIT;
|
|
||||||
}
|
|
||||||
parse = aliases[j].letter;
|
parse = aliases[j].letter;
|
||||||
hit = j;
|
hit = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(numhits>1) {
|
||||||
|
/* this is at least the second match! */
|
||||||
|
helpf("option --%s is ambiguous\n", &flag[1]);
|
||||||
|
return CURLE_FAILED_INIT;
|
||||||
|
}
|
||||||
if(hit < 0) {
|
if(hit < 0) {
|
||||||
helpf("unknown option -%s.\n", flag);
|
helpf("unknown option -%s.\n", flag);
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user