Commit b93a973b authored by ram@gw.mysql.r18.ru's avatar ram@gw.mysql.r18.ru

Added global my_getopt_error_reporter function pointer which is

used in the handle_options() function (instead of using additional 
handle_option() parameter). The default value of the 
my_getopt_error_reporter is default_reporter(). One can set it to
other functions if case of need.
parent 86fcffb3
...@@ -759,7 +759,7 @@ static int get_options(int argc, char **argv) ...@@ -759,7 +759,7 @@ static int get_options(int argc, char **argv)
opt_max_allowed_packet= *mysql_params->p_max_allowed_packet; opt_max_allowed_packet= *mysql_params->p_max_allowed_packet;
opt_net_buffer_length= *mysql_params->p_net_buffer_length; opt_net_buffer_length= *mysql_params->p_net_buffer_length;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, 0))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
*mysql_params->p_max_allowed_packet= opt_max_allowed_packet; *mysql_params->p_max_allowed_packet= opt_max_allowed_packet;
......
...@@ -254,7 +254,7 @@ int main(int argc,char *argv[]) ...@@ -254,7 +254,7 @@ int main(int argc,char *argv[])
mysql_init(&mysql); mysql_init(&mysql);
load_defaults("my",load_default_groups,&argc,&argv); load_defaults("my",load_default_groups,&argc,&argv);
save_argv = argv; /* Save for free_defaults */ save_argv = argv; /* Save for free_defaults */
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, 0))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{ {
free_defaults(save_argv); free_defaults(save_argv);
exit(ho_error); exit(ho_error);
......
...@@ -559,7 +559,7 @@ static int parse_args(int *argc, char*** argv) ...@@ -559,7 +559,7 @@ static int parse_args(int *argc, char*** argv)
result_file = stdout; result_file = stdout;
load_defaults("my",load_default_groups,argc,argv); load_defaults("my",load_default_groups,argc,argv);
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
return 0; return 0;
......
...@@ -273,7 +273,7 @@ static int get_options(int *argc, char ***argv) ...@@ -273,7 +273,7 @@ static int get_options(int *argc, char ***argv)
load_defaults("my", load_default_groups, argc, argv); load_defaults("my", load_default_groups, argc, argv);
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, 0))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (!what_to_do) if (!what_to_do)
......
...@@ -413,7 +413,7 @@ static int get_options(int *argc, char ***argv) ...@@ -413,7 +413,7 @@ static int get_options(int *argc, char ***argv)
md_result_file= stdout; md_result_file= stdout;
load_defaults("my",load_default_groups,argc,argv); load_defaults("my",load_default_groups,argc,argv);
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, 0))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
*mysql_params->p_max_allowed_packet= opt_max_allowed_packet; *mysql_params->p_max_allowed_packet= opt_max_allowed_packet;
......
...@@ -206,7 +206,7 @@ static int get_options(int *argc, char ***argv) ...@@ -206,7 +206,7 @@ static int get_options(int *argc, char ***argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, 0))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (enclosed && opt_enclosed) if (enclosed && opt_enclosed)
......
...@@ -95,7 +95,7 @@ int parse_args(int argc, char** argv) ...@@ -95,7 +95,7 @@ int parse_args(int argc, char** argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
return 0; return 0;
......
...@@ -133,7 +133,7 @@ int parse_args(int argc, char **argv) ...@@ -133,7 +133,7 @@ int parse_args(int argc, char **argv)
load_defaults("my",load_default_groups,&argc,&argv); load_defaults("my",load_default_groups,&argc,&argv);
default_argv= argv; default_argv= argv;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
return 0; return 0;
......
...@@ -261,7 +261,7 @@ get_options(int *argc,char ***argv) ...@@ -261,7 +261,7 @@ get_options(int *argc,char ***argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, 0))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (tty_password) if (tty_password)
......
...@@ -2062,7 +2062,7 @@ int parse_args(int argc, char **argv) ...@@ -2062,7 +2062,7 @@ int parse_args(int argc, char **argv)
load_defaults("my",load_default_groups,&argc,&argv); load_defaults("my",load_default_groups,&argc,&argv);
default_argv= argv; default_argv= argv;
if ((handle_options(&argc, &argv, my_long_options, get_one_option, 0))) if ((handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(1); exit(1);
if (argc > 1) if (argc > 1)
......
...@@ -100,7 +100,7 @@ static int get_options(int *argc,char ***argv) ...@@ -100,7 +100,7 @@ static int get_options(int *argc,char ***argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (*argc < 1) if (*argc < 1)
......
...@@ -218,7 +218,7 @@ static int parse_args(int argc, char **argv) ...@@ -218,7 +218,7 @@ static int parse_args(int argc, char **argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
return 0; return 0;
......
...@@ -67,7 +67,7 @@ int main(int argc, char *argv[]) ...@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
progname= argv[0]; progname= argv[0];
if (handle_options(&argc, &argv, my_long_options, get_one_option, NULL)) if (handle_options(&argc, &argv, my_long_options, get_one_option))
exit(-1); exit(-1);
if (!argv[0] || !argv[1] || (pid= atoi(argv[0])) <= 0 || if (!argv[0] || !argv[1] || (pid= atoi(argv[0])) <= 0 ||
(t= atoi(argv[1])) <= 0) (t= atoi(argv[1])) <= 0)
......
...@@ -145,7 +145,7 @@ static int get_options(int *argc,char ***argv) ...@@ -145,7 +145,7 @@ static int get_options(int *argc,char ***argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (!*argc && !print_all_codes) if (!*argc && !print_all_codes)
......
...@@ -121,7 +121,7 @@ static int parse_args(int argc, char **argv) ...@@ -121,7 +121,7 @@ static int parse_args(int argc, char **argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
/* /*
......
...@@ -90,7 +90,7 @@ static int get_options(int *argc,char ***argv) ...@@ -90,7 +90,7 @@ static int get_options(int *argc,char ***argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (*argc == 0) if (*argc == 0)
......
...@@ -50,15 +50,15 @@ struct my_option ...@@ -50,15 +50,15 @@ struct my_option
int app_type; /* To be used by an application */ int app_type; /* To be used by an application */
}; };
extern char *disabled_my_option;
extern my_bool my_getopt_print_errors;
typedef my_bool (* my_get_one_option) (int, const struct my_option *, char * ); typedef my_bool (* my_get_one_option) (int, const struct my_option *, char * );
typedef void (* my_error_reporter) (enum loglevel level, const char *format, ... ); typedef void (* my_error_reporter) (enum loglevel level, const char *format, ... );
extern char *disabled_my_option;
extern my_bool my_getopt_print_errors;
extern my_error_reporter my_getopt_error_reporter;
extern int handle_options (int *argc, char ***argv, extern int handle_options (int *argc, char ***argv,
const struct my_option *longopts, my_get_one_option, const struct my_option *longopts, my_get_one_option);
my_error_reporter );
extern void my_print_help(const struct my_option *options); extern void my_print_help(const struct my_option *options);
extern void my_print_variables(const struct my_option *options); extern void my_print_variables(const struct my_option *options);
......
...@@ -670,7 +670,7 @@ static void get_options(register int *argc, register char ***argv) ...@@ -670,7 +670,7 @@ static void get_options(register int *argc, register char ***argv)
if (isatty(fileno(stdout))) if (isatty(fileno(stdout)))
testflag|=T_WRITE_LOOP; testflag|=T_WRITE_LOOP;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (*argc == 0) if (*argc == 0)
......
...@@ -353,7 +353,7 @@ static void get_options(int *argc, char ***argv) ...@@ -353,7 +353,7 @@ static void get_options(int *argc, char ***argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
my_progname= argv[0][0]; my_progname= argv[0][0];
......
...@@ -643,7 +643,7 @@ static void get_options(int argc, char *argv[]) ...@@ -643,7 +643,7 @@ static void get_options(int argc, char *argv[])
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
return; return;
......
...@@ -66,7 +66,7 @@ int main(int argc,char *argv[]) ...@@ -66,7 +66,7 @@ int main(int argc,char *argv[])
struct { MI_INFO *info; } aio0, *aio=&aio0; /* for GWS_IN_USE */ struct { MI_INFO *info; } aio0, *aio=&aio0; /* for GWS_IN_USE */
MY_INIT(argv[0]); MY_INIT(argv[0]);
if (error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL)) if (error=handle_options(&argc, &argv, my_long_options, get_one_option))
exit(error); exit(error);
if (count || dump) if (count || dump)
verbose=0; verbose=0;
......
...@@ -677,7 +677,7 @@ static void get_options(register int *argc,register char ***argv) ...@@ -677,7 +677,7 @@ static void get_options(register int *argc,register char ***argv)
if (isatty(fileno(stdout))) if (isatty(fileno(stdout)))
check_param.testflag|=T_WRITE_LOOP; check_param.testflag|=T_WRITE_LOOP;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
/* If using repair, then update checksum if one uses --update-state */ /* If using repair, then update checksum if one uses --update-state */
......
...@@ -350,7 +350,7 @@ static void get_options(int *argc,char ***argv) ...@@ -350,7 +350,7 @@ static void get_options(int *argc,char ***argv)
if (isatty(fileno(stdout))) if (isatty(fileno(stdout)))
write_loop=1; write_loop=1;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (!*argc) if (!*argc)
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
#include <mysys_err.h> #include <mysys_err.h>
#include <my_getopt.h> #include <my_getopt.h>
static void default_reporter(enum loglevel level, const char *format, ...);
my_error_reporter my_getopt_error_reporter= &default_reporter;
static int findopt(char *optpat, uint length, static int findopt(char *optpat, uint length,
const struct my_option **opt_res, const struct my_option **opt_res,
char **ffname); char **ffname);
...@@ -56,7 +59,8 @@ char *disabled_my_option= (char*) "0"; ...@@ -56,7 +59,8 @@ char *disabled_my_option= (char*) "0";
my_bool my_getopt_print_errors= 1; my_bool my_getopt_print_errors= 1;
void default_reporter(enum loglevel level, const char *format, ...) static void default_reporter(enum loglevel level __attribute__((unused)),
const char *format, ...)
{ {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
...@@ -76,8 +80,7 @@ void default_reporter(enum loglevel level, const char *format, ...) ...@@ -76,8 +80,7 @@ void default_reporter(enum loglevel level, const char *format, ...)
int handle_options(int *argc, char ***argv, int handle_options(int *argc, char ***argv,
const struct my_option *longopts, const struct my_option *longopts,
my_get_one_option get_one_option, my_get_one_option get_one_option)
my_error_reporter reporter)
{ {
uint opt_found, argvpos= 0, length, i; uint opt_found, argvpos= 0, length, i;
my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used, my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used,
...@@ -91,9 +94,6 @@ int handle_options(int *argc, char ***argv, ...@@ -91,9 +94,6 @@ int handle_options(int *argc, char ***argv,
(*argv)++; /* --- || ---- */ (*argv)++; /* --- || ---- */
init_variables(longopts); init_variables(longopts);
if (! reporter)
reporter= &default_reporter;
for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++) for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
{ {
char *cur_arg= *pos; char *cur_arg= *pos;
...@@ -118,8 +118,9 @@ int handle_options(int *argc, char ***argv, ...@@ -118,8 +118,9 @@ int handle_options(int *argc, char ***argv,
if (!*++pos) if (!*++pos)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(ERROR_LEVEL, my_getopt_error_reporter(ERROR_LEVEL,
"%s: Option '-O' requires an argument\n", progname); "%s: Option '-O' requires an argument\n",
progname);
return EXIT_ARGUMENT_REQUIRED; return EXIT_ARGUMENT_REQUIRED;
} }
cur_arg= *pos; cur_arg= *pos;
...@@ -135,9 +136,9 @@ int handle_options(int *argc, char ***argv, ...@@ -135,9 +136,9 @@ int handle_options(int *argc, char ***argv,
if (!*cur_arg) if (!*cur_arg)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(ERROR_LEVEL, my_getopt_error_reporter(ERROR_LEVEL,
"%s: Option '--set-variable' requires an argument\n", "%s: Option '--set-variable' requires an argument\n",
progname); progname);
return EXIT_ARGUMENT_REQUIRED; return EXIT_ARGUMENT_REQUIRED;
} }
} }
...@@ -149,9 +150,9 @@ int handle_options(int *argc, char ***argv, ...@@ -149,9 +150,9 @@ int handle_options(int *argc, char ***argv,
if (!*++pos) if (!*++pos)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(ERROR_LEVEL, my_getopt_error_reporter(ERROR_LEVEL,
"%s: Option '--set-variable' requires an argument\n", "%s: Option '--set-variable' requires an argument\n",
progname); progname);
return EXIT_ARGUMENT_REQUIRED; return EXIT_ARGUMENT_REQUIRED;
} }
cur_arg= *pos; cur_arg= *pos;
...@@ -210,10 +211,11 @@ int handle_options(int *argc, char ***argv, ...@@ -210,10 +211,11 @@ int handle_options(int *argc, char ***argv,
if (opt_found > 1) if (opt_found > 1)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(ERROR_LEVEL, my_getopt_error_reporter(ERROR_LEVEL,
"%s: ambiguous option '--%s-%s' (--%s-%s)\n", "%s: ambiguous option '--%s-%s' (--%s-%s)\n",
progname, special_opt_prefix[i], cur_arg, progname, special_opt_prefix[i],
special_opt_prefix[i], prev_found); cur_arg, special_opt_prefix[i],
prev_found);
return EXIT_AMBIGUOUS_OPTION; return EXIT_AMBIGUOUS_OPTION;
} }
switch (i) { switch (i) {
...@@ -245,16 +247,20 @@ int handle_options(int *argc, char ***argv, ...@@ -245,16 +247,20 @@ int handle_options(int *argc, char ***argv,
if (must_be_var) if (must_be_var)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, my_getopt_error_reporter(option_is_loose ?
"%s: unknown variable '%s'\n", progname, cur_arg); WARNING_LEVEL : ERROR_LEVEL,
"%s: unknown variable '%s'\n",
progname, cur_arg);
if (!option_is_loose) if (!option_is_loose)
return EXIT_UNKNOWN_VARIABLE; return EXIT_UNKNOWN_VARIABLE;
} }
else else
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, my_getopt_error_reporter(option_is_loose ?
"%s: unknown option '--%s'\n", progname, cur_arg); WARNING_LEVEL : ERROR_LEVEL,
"%s: unknown option '--%s'\n",
progname, cur_arg);
if (!option_is_loose) if (!option_is_loose)
return EXIT_UNKNOWN_OPTION; return EXIT_UNKNOWN_OPTION;
} }
...@@ -270,23 +276,27 @@ int handle_options(int *argc, char ***argv, ...@@ -270,23 +276,27 @@ int handle_options(int *argc, char ***argv,
if (must_be_var) if (must_be_var)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(ERROR_LEVEL, "%s: variable prefix '%s' is not unique\n", my_getopt_error_reporter(ERROR_LEVEL,
progname, cur_arg); "%s: variable prefix '%s' is not unique\n",
progname, cur_arg);
return EXIT_VAR_PREFIX_NOT_UNIQUE; return EXIT_VAR_PREFIX_NOT_UNIQUE;
} }
else else
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(ERROR_LEVEL, "%s: ambiguous option '--%s' (%s, %s)\n", my_getopt_error_reporter(ERROR_LEVEL,
progname, cur_arg, prev_found, optp->name); "%s: ambiguous option '--%s' (%s, %s)\n",
progname, cur_arg, prev_found,
optp->name);
return EXIT_AMBIGUOUS_OPTION; return EXIT_AMBIGUOUS_OPTION;
} }
} }
if (must_be_var && optp->var_type == GET_NO_ARG) if (must_be_var && optp->var_type == GET_NO_ARG)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(ERROR_LEVEL, "%s: option '%s' cannot take an argument\n", my_getopt_error_reporter(ERROR_LEVEL,
progname, optp->name); "%s: option '%s' cannot take an argument\n",
progname, optp->name);
return EXIT_NO_ARGUMENT_ALLOWED; return EXIT_NO_ARGUMENT_ALLOWED;
} }
if (optp->arg_type == NO_ARG) if (optp->arg_type == NO_ARG)
...@@ -294,9 +304,9 @@ int handle_options(int *argc, char ***argv, ...@@ -294,9 +304,9 @@ int handle_options(int *argc, char ***argv,
if (optend && optp->var_type != GET_BOOL) if (optend && optp->var_type != GET_BOOL)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(ERROR_LEVEL, my_getopt_error_reporter(ERROR_LEVEL,
"%s: option '--%s' cannot take an argument\n", "%s: option '--%s' cannot take an argument\n",
progname, optp->name); progname, optp->name);
return EXIT_NO_ARGUMENT_ALLOWED; return EXIT_NO_ARGUMENT_ALLOWED;
} }
if (optp->var_type == GET_BOOL) if (optp->var_type == GET_BOOL)
...@@ -333,9 +343,9 @@ int handle_options(int *argc, char ***argv, ...@@ -333,9 +343,9 @@ int handle_options(int *argc, char ***argv,
if (!*++pos) if (!*++pos)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(ERROR_LEVEL, my_getopt_error_reporter(ERROR_LEVEL,
"%s: option '--%s' requires an argument\n", "%s: option '--%s' requires an argument\n",
progname, optp->name); progname, optp->name);
return EXIT_ARGUMENT_REQUIRED; return EXIT_ARGUMENT_REQUIRED;
} }
argument= *pos; argument= *pos;
...@@ -384,9 +394,9 @@ int handle_options(int *argc, char ***argv, ...@@ -384,9 +394,9 @@ int handle_options(int *argc, char ***argv,
if (!pos[1]) if (!pos[1])
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(ERROR_LEVEL, my_getopt_error_reporter(ERROR_LEVEL,
"%s: option '-%c' requires an argument\n", "%s: option '-%c' requires an argument\n",
progname, optp->id); progname, optp->id);
return EXIT_ARGUMENT_REQUIRED; return EXIT_ARGUMENT_REQUIRED;
} }
argument= *++pos; argument= *++pos;
...@@ -396,9 +406,9 @@ int handle_options(int *argc, char ***argv, ...@@ -396,9 +406,9 @@ int handle_options(int *argc, char ***argv,
} }
if ((error= setval(optp, argument, set_maximum_value))) if ((error= setval(optp, argument, set_maximum_value)))
{ {
reporter(ERROR_LEVEL, my_getopt_error_reporter(ERROR_LEVEL,
"%s: Error while setting value '%s' to '%s'\n", "%s: Error while setting value '%s' to '%s'\n",
progname, argument, optp->name); progname, argument, optp->name);
return error; return error;
} }
get_one_option(optp->id, optp, argument); get_one_option(optp->id, optp, argument);
...@@ -408,8 +418,9 @@ int handle_options(int *argc, char ***argv, ...@@ -408,8 +418,9 @@ int handle_options(int *argc, char ***argv,
if (!opt_found) if (!opt_found)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter(ERROR_LEVEL, my_getopt_error_reporter(ERROR_LEVEL,
"%s: unknown option '-%c'\n", progname, *optend); "%s: unknown option '-%c'\n",
progname, *optend);
return EXIT_UNKNOWN_OPTION; return EXIT_UNKNOWN_OPTION;
} }
} }
...@@ -418,9 +429,9 @@ int handle_options(int *argc, char ***argv, ...@@ -418,9 +429,9 @@ int handle_options(int *argc, char ***argv,
} }
if ((error= setval(optp, argument, set_maximum_value))) if ((error= setval(optp, argument, set_maximum_value)))
{ {
reporter(ERROR_LEVEL, my_getopt_error_reporter(ERROR_LEVEL,
"%s: Error while setting value '%s' to '%s'\n", "%s: Error while setting value '%s' to '%s'\n",
progname, argument, optp->name); progname, argument, optp->name);
return error; return error;
} }
get_one_option(optp->id, optp, argument); get_one_option(optp->id, optp, argument);
......
...@@ -384,7 +384,7 @@ static int get_options(int argc, char **argv) ...@@ -384,7 +384,7 @@ static int get_options(int argc, char **argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, 0))) if ((ho_error= handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (argc >= 1) if (argc >= 1)
......
...@@ -5119,8 +5119,8 @@ static void get_options(int argc,char **argv) ...@@ -5119,8 +5119,8 @@ static void get_options(int argc,char **argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, my_getopt_error_reporter= option_error_reporter;
option_error_reporter))) if ((ho_error= handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
#if defined(HAVE_BROKEN_REALPATH) #if defined(HAVE_BROKEN_REALPATH)
......
...@@ -1333,7 +1333,7 @@ static int parse_args(int argc, char **argv) ...@@ -1333,7 +1333,7 @@ static int parse_args(int argc, char **argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment