summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-01-07 12:13:21 +0100
committerSergei Golubchik <serg@mariadb.org>2015-02-10 10:21:15 +0100
commit4280b25ed85dba6e231d483e58a1c90b91730434 (patch)
tree1452e410e8e8c47c0a83f40f24eb8c90519b79d5 /mysys
parent0ce8703e99dabfa95d1cc0cd720c14f68d4cdda5 (diff)
downloadmariadb-git-4280b25ed85dba6e231d483e58a1c90b91730434.tar.gz
--getopt-prefix-matching command-line option
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_getopt.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 594f519a6a3..88fa3d493fc 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -56,7 +56,7 @@ enum enum_special_opt
char *disabled_my_option= (char*) "0";
char *enabled_my_option= (char*) "1";
-/*
+/*
This is a flag that can be set in client programs. 0 means that
my_getopt will not print error messages, but the client should do
it by itself
@@ -64,13 +64,21 @@ char *enabled_my_option= (char*) "1";
my_bool my_getopt_print_errors= 1;
-/*
+/*
This is a flag that can be set in client programs. 1 means that
my_getopt will skip over options it does not know how to handle.
*/
my_bool my_getopt_skip_unknown= 0;
+
+/*
+ This is a flag that can be set in client programs. 1 means that
+ my_getopt will reconize command line options by their unambiguous
+ prefixes. 0 means an option must be always specified in full.
+*/
+my_bool my_getopt_prefix_matching= 1;
+
static void default_reporter(enum loglevel level,
const char *format, ...)
{
@@ -851,6 +859,9 @@ static int findopt(char *optpat, uint length,
if (!opt->name[length]) /* Exact match */
DBUG_RETURN(1);
+ if (!my_getopt_prefix_matching)
+ continue;
+
if (!count)
{
/* We only need to know one prev */
@@ -867,6 +878,14 @@ static int findopt(char *optpat, uint length,
}
}
}
+
+ if (count == 1)
+ my_getopt_error_reporter(INFORMATION_LEVEL,
+ "Using unique option prefix '%.*s' is error-prone "
+ "and can break in the future. "
+ "Please use the full name '%s' instead.",
+ length, optpat, *ffname);
+
DBUG_RETURN(count);
}