summaryrefslogtreecommitdiff
path: root/mysys/my_getopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r--mysys/my_getopt.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index fa870405f70..ab85e231c0f 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -24,7 +24,7 @@
#include <my_getopt.h>
#include <errno.h>
-my_bool my_getopt_is_args_separator(const char* arg);
+my_bool is_file_marker(const char* arg);
typedef void (*init_func_p)(const struct my_option *option, void *variable,
longlong value);
@@ -193,6 +193,7 @@ int handle_options(int *argc, char ***argv, const struct my_option *longopts,
my_bool end_of_options= 0, must_be_var, set_maximum_value,
option_is_loose, option_is_autoset;
char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN];
+ char *filename= (char*)"";
const char *UNINIT_VAR(prev_found);
const struct my_option *optp;
void *value;
@@ -207,34 +208,29 @@ int handle_options(int *argc, char ***argv, const struct my_option *longopts,
(*argv)++; /* --- || ---- */
init_variables(longopts, init_one_value);
- /*
- Search for args_separator, if found, then the first part of the
- arguments are loaded from configs
- */
- for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
- {
- if (my_getopt_is_args_separator(*pos))
- {
- is_cmdline_arg= 0;
- break;
- }
- }
+ is_cmdline_arg= !is_file_marker(**argv);
for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
{
char **first= pos;
char *cur_arg= *pos;
opt_found= 0;
- if (!is_cmdline_arg && (my_getopt_is_args_separator(cur_arg)))
+ if (!is_cmdline_arg)
{
- is_cmdline_arg= 1;
-
- /* save the separator too if skip unknown options */
- if (my_getopt_skip_unknown)
- (*argv)[argvpos++]= cur_arg;
- else
- (*argc)--;
- continue;
+ if (is_file_marker(cur_arg))
+ {
+ pos++;
+ filename= *pos;
+ is_cmdline_arg= *filename == 0; /* empty file name = command line */
+ if (my_getopt_skip_unknown)
+ {
+ (*argv)[argvpos++]= cur_arg;
+ (*argv)[argvpos++]= filename;
+ }
+ else
+ (*argc)-= 2;
+ continue;
+ }
}
if (cur_arg[0] == '-' && cur_arg[1] && !end_of_options) /* must be opt */
{