- Fixed some option types in my_getopt struct in all clients.

- Added special option/variable prefix '--loose-' to my_getopt.c
parent b292571c
......@@ -56,3 +56,4 @@ tonu@x3.internalnet
venu@work.mysql.com
zak@balfor.local
zak@linux.local
jani@dsl-jkl1657.dial.inet.fi
......@@ -41,7 +41,7 @@
#include <signal.h>
#include <violite.h>
const char *VER= "12.3";
const char *VER= "12.4";
/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024
......@@ -480,7 +480,7 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"no-beep", 'b', "Turn off beep on error.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (gptr*) &current_host,
{"host", 'h', "Connect to host.", (gptr*) &current_host,
(gptr*) &current_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"html", 'H', "Produce HTML output.", (gptr*) &opt_html, (gptr*) &opt_html,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
......@@ -524,8 +524,9 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"port", 'P', "Port number to use for connection.", 0, 0, 0,
GET_LONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
0},
{"prompt", OPT_PROMPT, "Set the mysql prompt to this value.", 0, 0, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"quick", 'q',
......@@ -562,19 +563,19 @@ static struct my_option my_long_options[] =
{"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"connect_timeout", OPT_CONNECT_TIMEOUT, "", (gptr*) &opt_connect_timeout,
(gptr*) &opt_connect_timeout, 0, GET_LONG, REQUIRED_ARG, 0, 0, 3600*12, 0,
(gptr*) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0,
0, 1},
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "",
(gptr*) &max_allowed_packet, (gptr*) &max_allowed_packet, 0, GET_LONG,
(gptr*) &max_allowed_packet, (gptr*) &max_allowed_packet, 0, GET_ULONG,
REQUIRED_ARG, 16 *1024L*1024L, 4096, 512*1024L*1024L, MALLOC_OVERHEAD,
1024, 0},
{"net_buffer_length", OPT_NET_BUFFER_LENGTH, "",
(gptr*) &net_buffer_length, (gptr*) &net_buffer_length, 0, GET_LONG,
(gptr*) &net_buffer_length, (gptr*) &net_buffer_length, 0, GET_ULONG,
REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0},
{"select_limit", OPT_SELECT_LIMIT, "", (gptr*) &select_limit,
(gptr*) &select_limit, 0, GET_LONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0},
(gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0},
{"max_join_size", OPT_MAX_JOIN_SIZE, "", (gptr*) &max_join_size,
(gptr*) &max_join_size, 0, GET_LONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1,
(gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1,
0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
......
......@@ -24,7 +24,7 @@
#include <my_pthread.h> /* because of signal() */
#endif
#define ADMIN_VERSION "8.30"
#define ADMIN_VERSION "8.31"
#define MAX_MYSQL_VAR 64
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */
#define MAX_TRUNC_LENGTH 3
......@@ -124,8 +124,8 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"port", 'P', "Port number to use for connection.", 0, 0, 0,
GET_LONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &tcp_port,
(gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"relative", 'r',
"Show difference between current and previous values when used with -i. Currently works only with extended-status.",
(gptr*) &opt_relative, (gptr*) &opt_relative, 0, GET_BOOL, NO_ARG, 0, 0, 0,
......@@ -138,7 +138,8 @@ static struct my_option my_long_options[] =
{"socket", 'S', "Socket file to use for connection.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"sleep", 'i', "Execute commands again and again with a sleep between.",
0, 0, 0, GET_LONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
(gptr*) &interval, (gptr*) &interval, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0,
0, 0},
#include "sslopt-longopts.h"
#ifndef DONT_ALLOW_USER_CHANGE
{"user", 'u', "User for login if not current user.", (gptr*) &user,
......@@ -155,10 +156,10 @@ static struct my_option my_long_options[] =
{"wait", 'w', "Wait and retry if connection is down", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"connect_timeout", OPT_CONNECT_TIMEOUT, "", (gptr*) &opt_connect_timeout,
(gptr*) &opt_connect_timeout, 0, GET_LONG, REQUIRED_ARG, 3600*12, 0,
(gptr*) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 3600*12, 0,
3600*12, 0, 1, 0},
{"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", (gptr*) &opt_shutdown_timeout,
(gptr*) &opt_shutdown_timeout, 0, GET_LONG, REQUIRED_ARG,
(gptr*) &opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG,
SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
......
......@@ -16,7 +16,7 @@
/* By Jani Tolonen, 2001-04-20, MySQL Development Team */
#define CHECK_VERSION "2.0"
#define CHECK_VERSION "2.1"
#include "client_priv.h"
#include <my_getopt.h>
......@@ -107,8 +107,9 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"port", 'P', "Port number to use for connection.", 0, 0, 0, GET_LONG,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
0},
{"quick", 'q',
"If you are using this option with CHECK TABLE, it prevents the check from scanning the rows to check for wrong links. This is the fastest check. If you are using this option with REPAIR TABLE, it will try to repair only the index tree. This is the fastest repair method for a table.",
(gptr*) &opt_quick, (gptr*) &opt_quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
......
......@@ -35,7 +35,7 @@
** and adapted to mysqldump 05/11/01 by Jani Tolonen
*/
#define DUMP_VERSION "9.02"
#define DUMP_VERSION "9.03"
#include <my_global.h>
#include <my_sys.h>
......@@ -192,8 +192,9 @@ static struct my_option my_long_options[] =
{"pipe", 'W', "Use named pipes to connect to server", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"port", 'P', "Port number to use for connection.", 0, 0, 0, GET_LONG,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
0},
{"quick", 'q', "Don't buffer query, dump directly to stdout.",
(gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"quote-names",'Q', "Quote table and column names with a `",
......@@ -224,15 +225,15 @@ static struct my_option my_long_options[] =
(gptr*) &where, (gptr*) &where, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"xml", 'X', "Dump a database as well formed XML.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{ "max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "",
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "",
(gptr*) &max_allowed_packet, (gptr*) &max_allowed_packet, 0,
GET_LONG, REQUIRED_ARG, 24*1024*1024, 4096, 512*1024L*1024L,
GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096, 512*1024L*1024L,
MALLOC_OVERHEAD, 1024, 0},
{ "net_buffer_length", OPT_NET_BUFFER_LENGTH, "",
{"net_buffer_length", OPT_NET_BUFFER_LENGTH, "",
(gptr*) &net_buffer_length, (gptr*) &net_buffer_length, 0,
GET_LONG, REQUIRED_ARG, 1024*1024L-1025, 4096, 16*1024L*1024L,
GET_ULONG, REQUIRED_ARG, 1024*1024L-1025, 4096, 16*1024L*1024L,
MALLOC_OVERHEAD-1024, 1024, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static const char *load_default_groups[]= { "mysqldump","client",0 };
......
......@@ -25,7 +25,7 @@
** * *
** *************************
*/
#define IMPORT_VERSION "3.0"
#define IMPORT_VERSION "3.1"
#include "client_priv.h"
#include "mysql_version.h"
......@@ -91,7 +91,7 @@ static struct my_option my_long_options[] =
{"ignore", 'i', "If duplicate unique key was found, keep old row.",
(gptr*) &ignore, (gptr*) &ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.", 0, 0,
0, GET_LL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...",
(gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
......@@ -110,7 +110,8 @@ static struct my_option my_long_options[] =
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_LONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
0},
{"replace", 'r', "If duplicate unique key was found, replace old row.",
(gptr*) &replace, (gptr*) &replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent, 0,
......
......@@ -16,7 +16,7 @@
/* Show databases, tables or columns */
#define SHOW_VERSION "9.0"
#define SHOW_VERSION "9.1"
#include <my_global.h>
#include "client_priv.h"
......@@ -144,8 +144,9 @@ static struct my_option my_long_options[] =
{"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", 0, 0, 0, GET_LONG,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
0},
#ifdef __WIN__
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
......
......@@ -155,7 +155,7 @@ static struct my_option my_long_options[] =
{"analyze", 'a',
"Analyze distribution of keys. Will make some joins in MySQL faster. You can check the calculated distribution.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
0, 0, 0, 0},
{"block-search", 'b', "No help available.", 0, 0, 0, GET_LONG, REQUIRED_ARG,
{"block-search", 'b', "No help available.", 0, 0, 0, GET_ULONG, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"backup", 'B', "Make a backup of the .MYD file as 'filename-time.BAK'", 0,
0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
......@@ -211,10 +211,10 @@ static struct my_option my_long_options[] =
"Uses old recovery method; Slower than '-r' but can handle a couple of cases where '-r' reports that it can't fix the data file.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"start-check-pos", OPT_START_CHECK_POS, "No help available.", 0, 0, 0,
GET_LONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"set-auto-increment", 'A',
"Force auto_increment to start at this or higher value. If no value is given, then sets the next auto_increment value to the highest used value for the auto key + 1.", (gptr*) &check_param.auto_increment_value,
(gptr*) &check_param.auto_increment_value, 0, GET_LL, OPT_ARG, 0, 0, 0,
(gptr*) &check_param.auto_increment_value, 0, GET_ULL, OPT_ARG, 0, 0, 0,
0, 0, 0},
{"set-character-set", OPT_SET_CHARSET,
"Change the character set used by the index", 0, 0, 0, GET_STR,
......@@ -231,7 +231,7 @@ static struct my_option my_long_options[] =
{"sort-records", 'R',
"Sort records according to an index. This makes your data much more localized and may speed up things. (It may be VERY slow to do a sort the first time!)",
(gptr*) &check_param.opt_sort_key, (gptr*) &check_param.opt_sort_key, 0,
GET_LONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"sort-recover", 'n',
"Force recovering with sorting even if the temporary file was very big.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
......@@ -250,7 +250,7 @@ static struct my_option my_long_options[] =
0, 0, 0, 0},
{ "key_buffer_size", OPT_KEY_BUFFER_SIZE, "",
(gptr*) &check_param.use_buffers, (gptr*) &check_param.use_buffers, 0,
GET_LL, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD,
GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD,
(long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0},
{ "myisam_block_size", OPT_MYISAM_BLOCK_SIZE, "",
(gptr*) &opt_myisam_block_size, (gptr*) &opt_myisam_block_size, 0,
......@@ -258,41 +258,41 @@ static struct my_option my_long_options[] =
MI_MAX_KEY_BLOCK_LENGTH, 0, MI_MIN_KEY_BLOCK_LENGTH, 0},
{ "read_buffer_size", OPT_READ_BUFFER_SIZE, "",
(gptr*) &check_param.read_buffer_length,
(gptr*) &check_param.read_buffer_length, 0, GET_LL, REQUIRED_ARG,
(gptr*) &check_param.read_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
(long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD,
(long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0},
{ "write_buffer_size", OPT_WRITE_BUFFER_SIZE, "",
(gptr*) &check_param.write_buffer_length,
(gptr*) &check_param.write_buffer_length, 0, GET_LL, REQUIRED_ARG,
(gptr*) &check_param.write_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
(long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD,
(long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0},
{ "sort_buffer_size", OPT_SORT_BUFFER_SIZE, "",
(gptr*) &check_param.sort_buffer_length,
(gptr*) &check_param.sort_buffer_length, 0, GET_LL, REQUIRED_ARG,
(gptr*) &check_param.sort_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
(long) SORT_BUFFER_INIT, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD),
(long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0},
{ "sort_key_blocks", OPT_SORT_KEY_BLOCKS, "",
(gptr*) &check_param.sort_key_blocks,
(gptr*) &check_param.sort_key_blocks, 0, GET_LL, REQUIRED_ARG,
(gptr*) &check_param.sort_key_blocks, 0, GET_ULONG, REQUIRED_ARG,
BUFFERS_WHEN_SORTING, 4L, 100L, 0L, 1L, 0},
{ "decode_bits", OPT_DECODE_BITS, "", (gptr*) &decode_bits,
(gptr*) &decode_bits, 0, GET_LONG, REQUIRED_ARG, 9L, 4L, 17L, 0L, 1L, 0},
(gptr*) &decode_bits, 0, GET_UINT, REQUIRED_ARG, 9L, 4L, 17L, 0L, 1L, 0},
{ "ft_min_word_len", OPT_FT_MIN_WORD_LEN, "", (gptr*) &ft_min_word_len,
(gptr*) &ft_min_word_len, 0, GET_LONG, REQUIRED_ARG, 4, 1, HA_FT_MAXLEN,
(gptr*) &ft_min_word_len, 0, GET_ULONG, REQUIRED_ARG, 4, 1, HA_FT_MAXLEN,
0, 1, 0},
{ "ft_max_word_len", OPT_FT_MAX_WORD_LEN, "", (gptr*) &ft_max_word_len,
(gptr*) &ft_max_word_len, 0, GET_LONG, REQUIRED_ARG, HA_FT_MAXLEN, 10,
(gptr*) &ft_max_word_len, 0, GET_ULONG, REQUIRED_ARG, HA_FT_MAXLEN, 10,
HA_FT_MAXLEN, 0, 1, 0},
{ "ft_max_word_len_for_sort", OPT_FT_MAX_WORD_LEN_FOR_SORT, "",
(gptr*) &ft_max_word_len_for_sort, (gptr*) &ft_max_word_len_for_sort, 0,
GET_LONG, REQUIRED_ARG, 20, 4, HA_FT_MAXLEN, 0, 1, 0},
GET_ULONG, REQUIRED_ARG, 20, 4, HA_FT_MAXLEN, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
static void print_version(void)
{
printf("%s Ver 2.3 for %s at %s\n", my_progname, SYSTEM_TYPE,
printf("%s Ver 2.4 for %s at %s\n", my_progname, SYSTEM_TYPE,
MACHINE_TYPE);
}
......
......@@ -32,10 +32,12 @@ static void init_variables(const struct my_option *options);
static int setval (const struct my_option *opts, char *argument,
my_bool set_maximum_value);
#define DISABLE_OPTION_COUNT 2
#define DISABLE_OPTION_COUNT 2 /* currently 'skip' and 'disable' below */
/* 'disable'-option prefixes must be in the beginning, DISABLE_OPTION_COUNT
is the number of disabling prefixes */
static const char *special_opt_prefix[]=
{"skip", "disable", "enable", "maximum", 0};
{"skip", "disable", "enable", "maximum", "loose", 0};
char *disabled_my_option= (char*) "0";
......@@ -69,7 +71,8 @@ int handle_options(int *argc, char ***argv,
char *))
{
uint opt_found, argvpos= 0, length, spec_len, 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,
option_is_loose;
char *progname= *(*argv), **pos, *optend, *prev_found;
const struct my_option *optp;
int error;
......@@ -88,6 +91,7 @@ int handle_options(int *argc, char ***argv,
must_be_var= 0;
set_maximum_value= 0;
special_used= 0;
option_is_loose= 0;
cur_arg++; /* skip '-' */
if (*cur_arg == 'O')
......@@ -177,7 +181,7 @@ int handle_options(int *argc, char ***argv,
if (!must_be_var)
{
if (optend)
must_be_var= 1;
must_be_var= 1; /* option is followed by an argument */
for (i= 0; special_opt_prefix[i]; i++)
{
spec_len= strlen(special_opt_prefix[i]);
......@@ -189,6 +193,8 @@ int handle_options(int *argc, char ***argv,
*/
special_used= 1;
cur_arg+= (spec_len + 1);
if (!compare_strings(special_opt_prefix[i], "loose", 5))
option_is_loose= 1;
if ((opt_found= findopt(cur_arg, length - (spec_len + 1),
&optp, &prev_found)))
{
......@@ -219,14 +225,23 @@ int handle_options(int *argc, char ***argv,
if (must_be_var)
{
fprintf(stderr,
"%s: unknown variable '%s'\n", progname, cur_arg);
return ERR_UNKNOWN_VARIABLE;
"%s: %s: unknown variable '%s'\n", progname,
option_is_loose ? "WARNING" : "ERROR", cur_arg);
if (!option_is_loose)
return ERR_UNKNOWN_VARIABLE;
}
else
{
fprintf(stderr,
"%s: unknown option '--%s'\n", progname, cur_arg);
return ERR_UNKNOWN_OPTION;
"%s: %s: unknown option '--%s'\n", progname,
option_is_loose ? "WARNING" : "ERROR", cur_arg);
if (!option_is_loose)
return ERR_UNKNOWN_OPTION;
}
if (option_is_loose)
{
(*argc)--;
continue;
}
}
}
......@@ -245,11 +260,11 @@ int handle_options(int *argc, char ***argv,
return ERR_AMBIGUOUS_OPTION;
}
}
if (must_be_var && !optp->value)
if (must_be_var && (!optp->value || optp->var_type == GET_BOOL))
{
fprintf(stderr, "%s: argument '%s' is not a variable\n",
progname, *pos);
return ERR_MUST_BE_VARIABLE;
fprintf(stderr, "%s: option '%s' cannot take an argument\n",
progname, optp->name);
return ERR_NO_ARGUMENT_ALLOWED;
}
if (optp->arg_type == NO_ARG)
{
......
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