summaryrefslogtreecommitdiff
path: root/myisam/ft_test1.c
diff options
context:
space:
mode:
authorunknown <jani@rhols221.arenanet.fi>2002-05-24 14:06:58 +0300
committerunknown <jani@rhols221.arenanet.fi>2002-05-24 14:06:58 +0300
commit072e605cdc5f8803d90f88877c7abe1b4efaa551 (patch)
treedde3a16d80cc4857063e077d484ded67a7697cb5 /myisam/ft_test1.c
parent701d369d1844f19853223860c8610e40b802f428 (diff)
downloadmariadb-git-072e605cdc5f8803d90f88877c7abe1b4efaa551.tar.gz
Changed ft_dump, ft_eval, ft_test1, mi_test1, myisampack, gen_lex_hash,
mysqlmanager from using GNU getopt to use my_getopt. Changed some files that just included old getopt.h to include my_getopt.h now. Fixed a bug in my_print_help() in my_getopt.c. Made better documentation for option -G in mysql client. client/mysql.cc: Documented --named-commands better. myisam/ft_dump.c: Changed getopt to my_getopt. myisam/ft_eval.c: Changed getopt to my_getopt. myisam/ft_test1.c: Changed getopt to my_getopt. myisam/mi_check.c: getopt.h -> my_getopt.h myisam/mi_test1.c: Changed getopt to my_getopt. myisam/myisampack.c: Changed getopt to my_getopt. mysys/my_getopt.c: Fixed a bug when printing help for option that didn't have a description. sql/gen_lex_hash.cc: Changed getopt to my_getopt. tools/mysqlmanager.c: Changed getopt to my_getopt. vio/test-ssl.c: getopt.h -> my_getopt.h vio/test-sslclient.c: getopt.h -> my_getopt.h vio/test-sslserver.c: getopt.h -> my_getopt.h vio/viotest-ssl.c: getopt.h -> my_getopt.h BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'myisam/ft_test1.c')
-rw-r--r--myisam/ft_test1.c88
1 files changed, 62 insertions, 26 deletions
diff --git a/myisam/ft_test1.c b/myisam/ft_test1.c
index e1a47ff87c3..728ea4cd047 100644
--- a/myisam/ft_test1.c
+++ b/myisam/ft_test1.c
@@ -14,11 +14,12 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-/* Written by Sergei A. Golubchik, who has a shared copyright to this code */
+/* Written by Sergei A. Golubchik, who has a shared copyright to this code
+ added support for long options (my_getopt) 22.5.2002 by Jani Tolonen */
#include "ftdefs.h"
#include "ft_test1.h"
-#include <getopt.h>
+#include <my_getopt.h>
static int key_field=FIELD_VARCHAR,extra_field=FIELD_SKIP_ENDSPACE;
static uint key_length=200,extra_length=50;
@@ -33,8 +34,26 @@ static char record[MAX_REC_LENGTH],read_record[MAX_REC_LENGTH];
static int run_test(const char *filename);
static void get_options(int argc, char *argv[]);
static void create_record(char *, int);
+static void usage();
-int main(int argc,char *argv[])
+static struct my_option my_long_options[] =
+{
+ {"", 'v', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"", '?', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"", 'h', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"", 'V', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"", 'v', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"", 's', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"", 'N', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"", 'S', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"", 'K', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"", 'F', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"", 'U', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"", '#', "", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+ { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
+};
+
+int main(int argc, char *argv[])
{
MY_INIT(argv[0]);
@@ -173,7 +192,7 @@ static int run_test(const char *filename)
return (0);
err:
printf("got error: %3d when using myisam-database\n",my_errno);
- return 1; /* skipp warning */
+ return 1; /* skip warning */
}
static char blob_key[MAX_REC_LENGTH];
@@ -232,34 +251,51 @@ void create_record(char *pos, int n)
}
}
+
+static my_bool
+get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+ char *argument)
+{
+ switch(optid) {
+ case 'v': verbose=1; break;
+ case 's': silent=1; break;
+ case 'F': no_fulltext=1; no_search=1;
+ case 'U': skip_update=1; break;
+ case 'K': no_keys=no_search=1; break;
+ case 'N': no_search=1; break;
+ case 'S': no_stopwords=1; break;
+ case '#':
+ DEBUGGER_ON;
+ DBUG_PUSH (argument);
+ break;
+ case 'V':
+ case '?':
+ case 'h':
+ usage();
+ exit(1);
+ }
+ return 0;
+}
+
/* Read options */
static void get_options(int argc,char *argv[])
{
- int c;
- const char *options="hVvsNSKFU#:";
+ int ho_error;
- while ((c=getopt(argc,argv,options)) != -1)
+ if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{
- switch(c) {
- case 'v': verbose=1; break;
- case 's': silent=1; break;
- case 'F': no_fulltext=1; no_search=1;
- case 'U': skip_update=1; break;
- case 'K': no_keys=no_search=1; break;
- case 'N': no_search=1; break;
- case 'S': no_stopwords=1; break;
- case '#':
- DEBUGGER_ON;
- DBUG_PUSH (optarg);
- break;
- case 'V':
- case '?':
- case 'h':
- default:
- printf("%s -[%s]\n", argv[0], options);
- exit(0);
- }
+ printf("%s: handle_options() failed with error %d\n", my_progname,
+ ho_error);
+ exit(1);
}
return;
} /* get options */
+
+
+static void usage()
+{
+ printf("%s [options]\n", my_progname);
+ my_print_help(my_long_options);
+ my_print_variables(my_long_options);
+}