diff options
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/typelib.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/mysys/typelib.c b/mysys/typelib.c index 4fab6f20493..780e63b4b04 100644 --- a/mysys/typelib.c +++ b/mysys/typelib.c @@ -20,6 +20,28 @@ #include <m_ctype.h> +int find_type_or_exit(const char *x, TYPELIB *typelib, const char *option) +{ + int res; + const char **ptr; + + if ((res= find_type((my_string) x, typelib, 2)) <= 0) + { + ptr= typelib->type_names; + if (!*x) + fprintf(stderr, "No option given to %s\n", option); + else + fprintf(stderr, "Unknown option to %s: %s\n", option, x); + fprintf(stderr, "Alternatives are: '%s'", *ptr); + while (*++ptr) + fprintf(stderr, ",'%s'", *ptr); + fprintf(stderr, "\n"); + exit(1); + } + return res; +} + + /* Search after a string in a list of strings. Endspace in x is not compared. |