Fix a bug in this code that made it do the wrong thing when an option

was a single '-'.  Thanks to Andrew Kuchling.
This commit is contained in:
Guido van Rossum 1997-09-30 22:00:13 +00:00
parent b55e07f4eb
commit b4102bf5f8
1 changed files with 4 additions and 1 deletions

View File

@ -62,7 +62,10 @@ char optstring[];
opt_ptr = &argv[optind++][1];
}
if ((ptr = strchr(optstring, option = *opt_ptr++)) == NULL) {
if ( (option = *opt_ptr++) == '\0')
return -1;
if ((ptr = strchr(optstring, option)) == NULL) {
if (opterr)
fprintf(stderr, "Unknown option: -%c\n", option);