Commit c154ba66 by Neil Booth Committed by Neil Booth

cppinit.c (sort_options): Remove, put functionality in cpp_init.

	* cppinit.c (sort_options): Remove, put functionality in
	cpp_init.
	(cpp_init): New.
	(initialize_builtins): Free memory.
	(cpp_start_read): Move init_IStable to cpp_init.

	* cpplib.h (cpp_init): New prototype.
	* cppmain.c (main): Call cpp_init.

From-SVN: r35763
parent 9c82ac6b
2000-08-17 Neil Booth <NeilB@earthling.net>
* cppinit.c (sort_options): Remove, put functionality in
cpp_init.
(cpp_init): New.
(initialize_builtins): Free memory.
(cpp_start_read): Move init_IStable to cpp_init.
* cpplib.h (cpp_init): New prototype.
* cppmain.c (main): Call cpp_init.
Thu Aug 17 13:20:32 EDT 2000 John Wehle (john@feith.com) Thu Aug 17 13:20:32 EDT 2000 John Wehle (john@feith.com)
* rtlanal.c (rtx_unstable_p): Use CONSTANT_P. * rtlanal.c (rtx_unstable_p): Use CONSTANT_P.
......
...@@ -111,7 +111,6 @@ static void new_pending_directive PARAMS ((struct cpp_pending *, ...@@ -111,7 +111,6 @@ static void new_pending_directive PARAMS ((struct cpp_pending *,
cl_directive_handler)); cl_directive_handler));
#ifdef HOST_EBCDIC #ifdef HOST_EBCDIC
static int opt_comp PARAMS ((const void *, const void *)); static int opt_comp PARAMS ((const void *, const void *));
static void sort_options PARAMS ((void));
#endif #endif
static int parse_option PARAMS ((const char *)); static int parse_option PARAMS ((const char *));
...@@ -402,16 +401,24 @@ merge_include_chains (pfile) ...@@ -402,16 +401,24 @@ merge_include_chains (pfile)
CPP_OPTION (pfile, bracket_include) = brack; CPP_OPTION (pfile, bracket_include) = brack;
} }
void
cpp_init (void)
{
#ifdef HOST_EBCDIC
/* For non-ASCII hosts, the array needs to be sorted at runtime. */
qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
#endif
/* Set up the IStable. This doesn't do anything if we were compiled
with a compiler that supports C99 designated initializers. */
init_IStable ();
}
/* Initialize a cpp_reader structure. */ /* Initialize a cpp_reader structure. */
void void
cpp_reader_init (pfile) cpp_reader_init (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
#ifdef HOST_EBCDIC
sort_options ();
#endif
memset ((char *) pfile, 0, sizeof (cpp_reader)); memset ((char *) pfile, 0, sizeof (cpp_reader));
CPP_OPTION (pfile, dollars_in_ident) = 1; CPP_OPTION (pfile, dollars_in_ident) = 1;
...@@ -592,7 +599,9 @@ initialize_builtins (pfile) ...@@ -592,7 +599,9 @@ initialize_builtins (pfile)
str = xmalloc (b->len + strlen (val) + 2); str = xmalloc (b->len + strlen (val) + 2);
sprintf(str, "%s=%s", b->name, val); sprintf(str, "%s=%s", b->name, val);
} }
cpp_define (pfile, str); cpp_define (pfile, str);
free (str);
} }
else else
{ {
...@@ -806,10 +815,6 @@ cpp_start_read (pfile, print, fname) ...@@ -806,10 +815,6 @@ cpp_start_read (pfile, print, fname)
|| CPP_OPTION (pfile, dump_macros) == dump_definitions || CPP_OPTION (pfile, dump_macros) == dump_definitions
|| CPP_OPTION (pfile, dump_macros) == dump_only; || CPP_OPTION (pfile, dump_macros) == dump_only;
/* Set up the IStable. This doesn't do anything if we were compiled
with a compiler that supports C99 designated initializers. */
init_IStable ();
/* Set up the tables used by read_and_prescan. */ /* Set up the tables used by read_and_prescan. */
_cpp_init_input_buffer (pfile); _cpp_init_input_buffer (pfile);
...@@ -1074,22 +1079,6 @@ static const struct cl_option cl_options[] = ...@@ -1074,22 +1079,6 @@ static const struct cl_option cl_options[] =
#undef DEF_OPT #undef DEF_OPT
#undef COMMAND_LINE_OPTIONS #undef COMMAND_LINE_OPTIONS
#ifdef HOST_EBCDIC
static void
sort_options (void)
{
static int opts_sorted = 0;
if (!opts_sorted)
{
opts_sorted = 1;
/* For non-ASCII hosts, the array needs to be sorted at runtime */
qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
}
}
#endif
/* Perform a binary search to find which, if any, option the given /* Perform a binary search to find which, if any, option the given
command-line matches. Returns its index in the option array, command-line matches. Returns its index in the option array,
negative on failure. Complications arise since some options can be negative on failure. Complications arise since some options can be
......
...@@ -637,6 +637,7 @@ struct cpp_hashnode ...@@ -637,6 +637,7 @@ struct cpp_hashnode
const unsigned char name[1]; /* name[length] */ const unsigned char name[1]; /* name[length] */
}; };
extern void cpp_init PARAMS ((void));
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **)); extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **)); extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
extern void cpp_reader_init PARAMS ((cpp_reader *)); extern void cpp_reader_init PARAMS ((cpp_reader *));
......
...@@ -71,6 +71,7 @@ main (argc, argv) ...@@ -71,6 +71,7 @@ main (argc, argv)
(void) bindtextdomain (PACKAGE, localedir); (void) bindtextdomain (PACKAGE, localedir);
(void) textdomain (PACKAGE); (void) textdomain (PACKAGE);
cpp_init ();
cpp_reader_init (pfile); cpp_reader_init (pfile);
argi += cpp_handle_options (pfile, argc - argi , argv + argi); argi += cpp_handle_options (pfile, argc - argi , argv + argi);
......
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