Commit 35399bdc by Neil Booth Committed by Neil Booth

Makefile.in: Rename options.c and options.h to c-options.c and c-options.h.

	* Makefile.in: Rename options.c and options.h to c-options.c and
	c-options.h.
	(OBJS): Remove options.o.
	* c-opts.c: Don'tInclude c-options.h instead of options.h.
	* opts.c: Don't include options.h.
	(find_opt): Can't use enum opt_code or N_OPTS.
	* opts.h (struct cl_option, cl_options, cl_options_count): Move from...
	* opts.sh: ... here.

From-SVN: r67615
parent 8eb6a092
2003-06-08 Neil Booth <neil@daikokuya.co.uk>
* Makefile.in: Rename options.c and options.h to c-options.c and
c-options.h.
(OBJS): Remove options.o.
* c-opts.c: Don'tInclude c-options.h instead of options.h.
* opts.c: Don't include options.h.
(find_opt): Can't use enum opt_code or N_OPTS.
* opts.h (struct cl_option, cl_options, cl_options_count): Move from...
* opts.sh: ... here.
2003-06-07 Eric Botcazou <ebotcazou@libertysurf.fr> 2003-06-07 Eric Botcazou <ebotcazou@libertysurf.fr>
Ulrich Weigand <Ulrich.Weigand@de.ibm.com> Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
......
...@@ -36,7 +36,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -36,7 +36,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "c-incpath.h" #include "c-incpath.h"
#include "debug.h" /* For debug_hooks. */ #include "debug.h" /* For debug_hooks. */
#include "opts.h" #include "opts.h"
#include "options.h" #include "c-options.h"
#ifndef DOLLARS_IN_IDENTIFIERS #ifndef DOLLARS_IN_IDENTIFIERS
# define DOLLARS_IN_IDENTIFIERS true # define DOLLARS_IN_IDENTIFIERS true
......
...@@ -26,9 +26,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -26,9 +26,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "tree.h" #include "tree.h"
#include "langhooks.h" #include "langhooks.h"
#include "opts.h" #include "opts.h"
#include "options.h"
static enum opt_code find_opt (const char *, int); static size_t find_opt (const char *, int);
/* Perform a binary search to find which option the command-line INPUT /* Perform a binary search to find which option the command-line INPUT
matches. Returns its index in the option array, and N_OPTS on matches. Returns its index in the option array, and N_OPTS on
...@@ -41,16 +40,16 @@ static enum opt_code find_opt (const char *, int); ...@@ -41,16 +40,16 @@ static enum opt_code find_opt (const char *, int);
doesn't match any alternatives for the true front end, the index of doesn't match any alternatives for the true front end, the index of
the matched switch is returned anyway. The caller should check for the matched switch is returned anyway. The caller should check for
this case. */ this case. */
static enum opt_code static size_t
find_opt (const char *input, int lang_mask) find_opt (const char *input, int lang_mask)
{ {
size_t md, mn, mx; size_t md, mn, mx;
size_t opt_len; size_t opt_len;
enum opt_code result = N_OPTS; size_t result = cl_options_count;
int comp; int comp;
mn = 0; mn = 0;
mx = N_OPTS; mx = cl_options_count;
while (mx > mn) while (mx > mn)
{ {
...@@ -84,7 +83,7 @@ find_opt (const char *input, int lang_mask) ...@@ -84,7 +83,7 @@ find_opt (const char *input, int lang_mask)
/* If subsequently we don't find a better match, /* If subsequently we don't find a better match,
return this and let the caller report it as a bad return this and let the caller report it as a bad
match. */ match. */
result = (enum opt_code) md; result = md;
continue; continue;
} }
...@@ -97,7 +96,7 @@ find_opt (const char *input, int lang_mask) ...@@ -97,7 +96,7 @@ find_opt (const char *input, int lang_mask)
return the longest valid option-accepting match (mx). return the longest valid option-accepting match (mx).
This loops at most twice with current options. */ This loops at most twice with current options. */
mx = md; mx = md;
for (md = md + 1; md < N_OPTS; md++) for (md = md + 1; md < cl_options_count; md++)
{ {
opt_len = cl_options[md].opt_len; opt_len = cl_options[md].opt_len;
if (strncmp (input, cl_options[md].opt_text, opt_len)) if (strncmp (input, cl_options[md].opt_text, opt_len))
...@@ -137,7 +136,7 @@ handle_option (int argc, char **argv, int lang_mask) ...@@ -137,7 +136,7 @@ handle_option (int argc, char **argv, int lang_mask)
/* Interpret "-" or a non-switch as a file name. */ /* Interpret "-" or a non-switch as a file name. */
if (opt[0] != '-' || opt[1] == '\0') if (opt[0] != '-' || opt[1] == '\0')
{ {
opt_index = N_OPTS; opt_index = cl_options_count;
arg = opt; arg = opt;
result = 1; result = 1;
} }
...@@ -159,7 +158,7 @@ handle_option (int argc, char **argv, int lang_mask) ...@@ -159,7 +158,7 @@ handle_option (int argc, char **argv, int lang_mask)
/* Skip over '-'. */ /* Skip over '-'. */
opt_index = find_opt (opt + 1, lang_mask); opt_index = find_opt (opt + 1, lang_mask);
if (opt_index == N_OPTS) if (opt_index == cl_options_count)
goto done; goto done;
option = &cl_options[opt_index]; option = &cl_options[opt_index];
......
...@@ -23,6 +23,16 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -23,6 +23,16 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
extern int handle_option (int argc, char **argv, int lang_mask); extern int handle_option (int argc, char **argv, int lang_mask);
struct cl_option
{
const char *opt_text;
unsigned char opt_len;
unsigned char flags;
};
extern const struct cl_option cl_options[];
extern const unsigned int cl_options_count;
#define CL_C (1 << 0) /* Only C. */ #define CL_C (1 << 0) /* Only C. */
#define CL_OBJC (1 << 1) /* Only ObjC. */ #define CL_OBJC (1 << 1) /* Only ObjC. */
#define CL_CXX (1 << 2) /* Only C++. */ #define CL_CXX (1 << 2) /* Only C++. */
......
...@@ -61,15 +61,10 @@ cat "$@" | ${AWK} ' ...@@ -61,15 +61,10 @@ cat "$@" | ${AWK} '
FS = "\034" FS = "\034"
print "/* This file is auto-generated by opts.sh. */\n" > h_file print "/* This file is auto-generated by opts.sh. */\n" > h_file
print "/* This file is auto-generated by opts.sh. */\n" > c_file print "/* This file is auto-generated by opts.sh. */\n" > c_file
print "struct cl_option\n{" >> h_file
print " const char *opt_text;" >> h_file
print " unsigned char opt_len;" >> h_file
print " unsigned char flags;" >> h_file
print "};\n\n" >> h_file
print "extern const struct cl_option cl_options[];\n" >> h_file
print "enum opt_code\n{" >> h_file print "enum opt_code\n{" >> h_file
print "#include \"options.h\"" >> c_file print "#include \"" h_file "\"" >> c_file
print "#include \"opts.h\"\n" >> c_file print "#include \"opts.h\"\n" >> c_file
print "const unsigned int cl_options_count = N_OPTS;\n" >> c_file
print "const struct cl_option cl_options[] =\n{" >> c_file print "const struct cl_option cl_options[] =\n{" >> c_file
} }
......
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