* src/lex.c (parse_percent_token): Change type of variable `tx', which

is now an option_table_struct*.
(option_strcmp): New function option_strcmp.
(parse_percent_token): Call option_strcmp.
* src/getargs.c (xalloc.h, options.h): Include it.
(getargs): Call create_long_option_table.
(getargs): Free longopts at the end of the function.
(shortopts): Move in options.c.
* src/options.c (create_long_option_table): New function.  Convert
information from option_table to option structure.
* src/reader.c (options.h): Include it.
* src/Makefile.am: Adjust.
* src/options.c (option_table): Create from longopts and percent_table.
* src/getargs.c (longopts): Delete.
* src/lex.c (struct percent_table_struct): Delete.
(percent_table): Delete.
(options.h): Include it.
* src/options.c: Create.
* src/options.h: Create.
Declare enum opt_access_e.
Define struct option_table_struct.
This commit is contained in:
Pascal Bart
2001-09-20 18:32:20 +00:00
parent 75f5aaea27
commit 82b6d266fd
8 changed files with 269 additions and 90 deletions

62
src/options.h Normal file
View File

@@ -0,0 +1,62 @@
/* Concentrate all options use in bison,
Copyright 2001 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
Bison is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Bison is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Bison; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef OPTIONS_H_
# define OPTIONS_H_
/* opt_access_t and struct option_table_struct need to be declare
here, for the parse_percent_token function in lex.c. */
/* Option accessibility. */
typedef enum opt_access_e
{
opt_cmd_line = 1,
opt_percent,
opt_both
} opt_access_t;
/* This is the general struct, which contains user's options from
command line or in grammar with percent flag. */
struct option_table_struct
{
/* Set the accessibility. */
opt_access_t access;
/* This name is used for long option et percent directives. */
const char *name;
/* Use for command line. */
int has_arg;
/* A set_flag value causes the named flag to be set. */
int *set_flag;
/* A retval action returns the code. */
int ret_val;
/* The short option value, frequently a letter. */
int val;
};
extern const char *shortopts;
extern struct option *longopts;
/* Table which contain all options. */
extern const struct option_table_struct option_table[];
/* Set the longopts variable from option_table. */
void create_long_option_table PARAMS (());
#endif /* !OPTIONS_H_ */