summaryrefslogtreecommitdiff
path: root/mysys/my_getopt.c
diff options
context:
space:
mode:
authorunknown <jani@dsl-jkl1657.dial.inet.fi>2002-05-31 16:23:36 +0300
committerunknown <jani@dsl-jkl1657.dial.inet.fi>2002-05-31 16:23:36 +0300
commit2e86ba7e9e38bc77bdc9fd1c5878711e1fae8d18 (patch)
treeb73ab847a4ef48828e842f70b70edca3388cf241 /mysys/my_getopt.c
parentb379016d8874b8d362f11bce0c5fe19d51adc561 (diff)
downloadmariadb-git-2e86ba7e9e38bc77bdc9fd1c5878711e1fae8d18.tar.gz
Fixed a bug in my_getopt.
mysys/my_getopt.c: Fixed two bugs in my_getopt: - Didn't exit with error if a short option was not recognized. Fixed. - If unrecognized short option was not the first one in the list, printed "unknown option" error for wrong option. Fixed.
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r--mysys/my_getopt.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 720dae7520a..76cdbede78d 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -324,8 +324,9 @@ int handle_options(int *argc, char ***argv,
}
else /* must be short option */
{
- for (optend= cur_arg; *optend; optend++, opt_found= 0)
+ for (optend= cur_arg; *optend; optend++)
{
+ opt_found= 0;
for (optp= longopts; optp->id; optp++)
{
if (optp->id == (int) (uchar) *optend)
@@ -379,7 +380,7 @@ int handle_options(int *argc, char ***argv,
{
if (my_getopt_print_errors)
fprintf(stderr,
- "%s: unknown option '-%c'\n", progname, *cur_arg);
+ "%s: unknown option '-%c'\n", progname, *optend);
return EXIT_UNKNOWN_OPTION;
}
}