Commit cf44ea52 by Neil Booth Committed by Neil Booth

c-lex.h (parse_in): Change parse_in to a cpp_reader *.

	* c-lex.h (parse_in): Change parse_in to a cpp_reader *.
	* c-decl.c (c_decode_option): Update to match.
	* c-lex.c (init_c_lex, yyparse): Update to match.
	* c-lang.c (lang_init_options): Use cpp_create_reader.
	* cppinit.c (cpp_init): Rename initialize.
	(cpp_reader_init): Rename cpp_create_reader.  Create the
	reader.  Initialize cpplib if appropriate.
	* cpplib.h (cpp_create_reader) New prototype.
	(cpp_init, cpp_reader_init): Delete prototypes.
	* cppmain.c (general_init, setup_callbacks): New functions.
	(main): Use them.
	* fix-header.c (scan_in): Change type to cpp_reader *.
	(read_scan_file): Update for new cpplib interface and scan_in type.

	* cp/decl.c (parse_in): Change to cpp_reader *.
	(lang_decode_option): Update.
	* cp/lex.c (lang_init_options): Use new cpplib interface.
	(init_cp_pragma, finish_parse, handle_pragma_implementation): Update.
	* cp/spew.c (read_token): Update.
	* objc/objc-act.c (lang_init_options): Update new cpplib interface.

From-SVN: r37826
parent 74d2f859
2000-11-28 Neil Booth <neilb@earthling.net>
* c-lex.h (parse_in): Change parse_in to a cpp_reader *.
* c-decl.c (c_decode_option): Update to match.
* c-lex.c (init_c_lex, yyparse): Update to match.
* c-lang.c (lang_init_options): Use cpp_create_reader.
* cppinit.c (cpp_init): Rename initialize.
(cpp_reader_init): Rename cpp_create_reader. Create the
reader. Initialize cpplib if appropriate.
* cpplib.h (cpp_create_reader) New prototype.
(cpp_init, cpp_reader_init): Delete prototypes.
* cppmain.c (general_init, setup_callbacks): New functions.
(main): Use them.
* fix-header.c (scan_in): Change type to cpp_reader *.
(read_scan_file): Update for new cpplib interface and scan_in type.
* cp/decl.c (parse_in): Change to cpp_reader *.
(lang_decode_option): Update.
* cp/lex.c (lang_init_options): Use new cpplib interface.
(init_cp_pragma, finish_parse, handle_pragma_implementation): Update.
* cp/spew.c (read_token): Update.
* objc/objc-act.c (lang_init_options): Update new cpplib interface.
2000-11-28 Jakub Jelinek <jakub@redhat.com> 2000-11-28 Jakub Jelinek <jakub@redhat.com>
* loop.c (load_mems): Avoid using next_label to find end_label. If * loop.c (load_mems): Avoid using next_label to find end_label. If
......
...@@ -509,7 +509,7 @@ c_decode_option (argc, argv) ...@@ -509,7 +509,7 @@ c_decode_option (argc, argv)
const char *option_value = NULL; const char *option_value = NULL;
char *p = argv[0]; char *p = argv[0];
strings_processed = cpp_handle_option (&parse_in, argc, argv); strings_processed = cpp_handle_option (parse_in, argc, argv);
if (!strcmp (p, "-lang-objc")) if (!strcmp (p, "-lang-objc"))
c_language = clk_objective_c; c_language = clk_objective_c;
......
...@@ -52,8 +52,7 @@ lang_decode_option (argc, argv) ...@@ -52,8 +52,7 @@ lang_decode_option (argc, argv)
void void
lang_init_options () lang_init_options ()
{ {
cpp_init (); parse_in = cpp_create_reader (CLK_GNUC89);
cpp_reader_init (&parse_in, CLK_GNUC89);
/* Mark as "unspecified". */ /* Mark as "unspecified". */
flag_bounds_check = -1; flag_bounds_check = -1;
......
...@@ -122,12 +122,12 @@ init_c_lex (filename) ...@@ -122,12 +122,12 @@ init_c_lex (filename)
GET_ENVIRONMENT (literal_codeset, "LANG"); GET_ENVIRONMENT (literal_codeset, "LANG");
#endif #endif
parse_in.cb.ident = cb_ident; parse_in->cb.ident = cb_ident;
parse_in.cb.change_file = cb_change_file; parse_in->cb.change_file = cb_change_file;
parse_in.cb.def_pragma = cb_def_pragma; parse_in->cb.def_pragma = cb_def_pragma;
/* Make sure parse_in.digraphs matches flag_digraphs. */ /* Make sure parse_in->digraphs matches flag_digraphs. */
CPP_OPTION (&parse_in, digraphs) = flag_digraphs; CPP_OPTION (parse_in, digraphs) = flag_digraphs;
if (filename == 0 || !strcmp (filename, "-")) if (filename == 0 || !strcmp (filename, "-"))
filename = "stdin"; filename = "stdin";
...@@ -145,7 +145,7 @@ init_c_lex (filename) ...@@ -145,7 +145,7 @@ init_c_lex (filename)
int int
yyparse() yyparse()
{ {
if (! cpp_start_read (&parse_in, orig_filename)) if (! cpp_start_read (parse_in, orig_filename))
return 1; /* cpplib has emitted an error. */ return 1; /* cpplib has emitted an error. */
return yyparse_1(); return yyparse_1();
...@@ -951,13 +951,13 @@ c_lex (value) ...@@ -951,13 +951,13 @@ c_lex (value)
retry: retry:
timevar_push (TV_CPP); timevar_push (TV_CPP);
cpp_get_token (&parse_in, &tok); cpp_get_token (parse_in, &tok);
timevar_pop (TV_CPP); timevar_pop (TV_CPP);
/* The C++ front end does horrible things with the current line /* The C++ front end does horrible things with the current line
number. To ensure an accurate line number, we must reset it number. To ensure an accurate line number, we must reset it
every time we return a token. */ every time we return a token. */
lex_lineno = cpp_get_line (&parse_in)->line; lex_lineno = cpp_get_line (parse_in)->line;
*value = NULL_TREE; *value = NULL_TREE;
lineno = lex_lineno; lineno = lex_lineno;
......
...@@ -35,6 +35,6 @@ extern tree is_class_name PARAMS ((tree)); ...@@ -35,6 +35,6 @@ extern tree is_class_name PARAMS ((tree));
extern int indent_level; extern int indent_level;
struct cpp_reader; struct cpp_reader;
extern struct cpp_reader parse_in; extern struct cpp_reader* parse_in;
#endif #endif
...@@ -46,7 +46,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -46,7 +46,7 @@ Boston, MA 02111-1307, USA. */
#include "ggc.h" #include "ggc.h"
#include "timevar.h" #include "timevar.h"
#include "cpplib.h" #include "cpplib.h"
extern cpp_reader parse_in; extern cpp_reader *parse_in;
/* This structure contains information about the initializations /* This structure contains information about the initializations
and/or destructions required for a particular priority level. */ and/or destructions required for a particular priority level. */
...@@ -569,7 +569,7 @@ lang_decode_option (argc, argv) ...@@ -569,7 +569,7 @@ lang_decode_option (argc, argv)
int strings_processed; int strings_processed;
const char *p = argv[0]; const char *p = argv[0];
strings_processed = cpp_handle_option (&parse_in, argc, argv); strings_processed = cpp_handle_option (parse_in, argc, argv);
if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional")) if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional"))
/* ignore */; /* ignore */;
......
...@@ -79,7 +79,6 @@ static void init_operators PARAMS ((void)); ...@@ -79,7 +79,6 @@ static void init_operators PARAMS ((void));
#endif #endif
#include "cpplib.h" #include "cpplib.h"
extern cpp_reader parse_in;
/* Pending language change. /* Pending language change.
Positive is push count, negative is pop count. */ Positive is push count, negative is pop count. */
...@@ -246,8 +245,7 @@ static const char *cplus_tree_code_name[] = { ...@@ -246,8 +245,7 @@ static const char *cplus_tree_code_name[] = {
void void
lang_init_options () lang_init_options ()
{ {
cpp_init (); parse_in = cpp_create_reader (CLK_GNUCXX);
cpp_reader_init (&parse_in, CLK_GNUCXX);
/* Default exceptions on. */ /* Default exceptions on. */
flag_exceptions = 1; flag_exceptions = 1;
...@@ -661,16 +659,16 @@ init_reswords () ...@@ -661,16 +659,16 @@ init_reswords ()
static void static void
init_cp_pragma () init_cp_pragma ()
{ {
cpp_register_pragma (&parse_in, 0, "vtable", handle_pragma_vtable); cpp_register_pragma (parse_in, 0, "vtable", handle_pragma_vtable);
cpp_register_pragma (&parse_in, 0, "unit", handle_pragma_unit); cpp_register_pragma (parse_in, 0, "unit", handle_pragma_unit);
cpp_register_pragma (&parse_in, 0, "interface", handle_pragma_interface); cpp_register_pragma (parse_in, 0, "interface", handle_pragma_interface);
cpp_register_pragma (&parse_in, 0, "implementation", cpp_register_pragma (parse_in, 0, "implementation",
handle_pragma_implementation); handle_pragma_implementation);
cpp_register_pragma_space (&parse_in, "GCC"); cpp_register_pragma_space (parse_in, "GCC");
cpp_register_pragma (&parse_in, "GCC", "interface", handle_pragma_interface); cpp_register_pragma (parse_in, "GCC", "interface", handle_pragma_interface);
cpp_register_pragma (&parse_in, "GCC", "implementation", cpp_register_pragma (parse_in, "GCC", "implementation",
handle_pragma_implementation); handle_pragma_implementation);
} }
...@@ -742,8 +740,8 @@ init_parse (filename) ...@@ -742,8 +740,8 @@ init_parse (filename)
void void
finish_parse () finish_parse ()
{ {
cpp_finish (&parse_in); cpp_finish (parse_in);
errorcount += parse_in.errors; errorcount += parse_in->errors;
} }
inline void inline void
...@@ -1150,7 +1148,7 @@ handle_pragma_implementation (dfile) ...@@ -1150,7 +1148,7 @@ handle_pragma_implementation (dfile)
else else
{ {
main_filename = TREE_STRING_POINTER (fname); main_filename = TREE_STRING_POINTER (fname);
if (cpp_included (&parse_in, main_filename)) if (cpp_included (parse_in, main_filename))
warning ("#pragma implementation for %s appears after file is included", warning ("#pragma implementation for %s appears after file is included",
main_filename); main_filename);
} }
......
...@@ -323,8 +323,8 @@ read_token (t) ...@@ -323,8 +323,8 @@ read_token (t)
#undef YYCODE #undef YYCODE
case CPP_EOF: case CPP_EOF:
cpp_pop_buffer (&parse_in); cpp_pop_buffer (parse_in);
if (CPP_BUFFER (&parse_in)) if (CPP_BUFFER (parse_in))
goto retry; goto retry;
t->yychar = 0; t->yychar = 0;
break; break;
......
...@@ -398,30 +398,6 @@ merge_include_chains (pfile) ...@@ -398,30 +398,6 @@ merge_include_chains (pfile)
CPP_OPTION (pfile, bracket_include) = brack; CPP_OPTION (pfile, bracket_include) = brack;
} }
/* cpp_init initializes library global state. It might not need to do
anything depending on the platform and compiler, so we have a static
flag to make sure it gets called before cpp_reader_init. */
static int cpp_init_completed = 0;
void
cpp_init ()
{
#ifdef HOST_EBCDIC
/* For non-ASCII hosts, the cl_options array needs to be sorted at
runtime. */
qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
#endif
/* Set up the trigraph map and the IStable. These don't need to do
anything if we were compiled with a compiler that supports C99
designated initializers. */
init_trigraph_map ();
init_IStable ();
cpp_init_completed = 1;
}
/* Sets internal flags correctly for a given language, and defines /* Sets internal flags correctly for a given language, and defines
macros if necessary. */ macros if necessary. */
static void static void
...@@ -516,24 +492,40 @@ set_lang (pfile, lang) ...@@ -516,24 +492,40 @@ set_lang (pfile, lang)
} }
} }
/* initialize initializes library global state. It might not need to
do anything depending on the platform and compiler. */
static int initialized = 0;
static void
initialize ()
{
#ifdef HOST_EBCDIC
/* For non-ASCII hosts, the cl_options array needs to be sorted at
runtime. */
qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
#endif
/* Set up the trigraph map and the IStable. These don't need to do
anything if we were compiled with a compiler that supports C99
designated initializers. */
init_trigraph_map ();
init_IStable ();
initialized = 1;
}
/* Initialize a cpp_reader structure. */ /* Initialize a cpp_reader structure. */
void cpp_reader *
cpp_reader_init (pfile, lang) cpp_create_reader (lang)
cpp_reader *pfile;
enum c_lang lang; enum c_lang lang;
{ {
struct spec_nodes *s; struct spec_nodes *s;
cpp_reader *pfile = (cpp_reader *) xcalloc (1, sizeof (cpp_reader));
memset ((char *) pfile, 0, sizeof (cpp_reader)); /* Initialise this instance of the library if it hasn't been already. */
if (! initialized)
/* If cpp_init hasn't been called, generate a fatal error (by hand) initialize ();
and call it here. */
if (!cpp_init_completed)
{
fputs ("cpp_reader_init: internal error: cpp_init not called.\n", stderr);
pfile->errors = CPP_FATAL_LIMIT;
cpp_init ();
}
CPP_OPTION (pfile, warn_import) = 1; CPP_OPTION (pfile, warn_import) = 1;
CPP_OPTION (pfile, discard_comments) = 1; CPP_OPTION (pfile, discard_comments) = 1;
...@@ -586,6 +578,8 @@ cpp_reader_init (pfile, lang) ...@@ -586,6 +578,8 @@ cpp_reader_init (pfile, lang)
s->n__CHAR_UNSIGNED__ = cpp_lookup (pfile, DSC("__CHAR_UNSIGNED__")); s->n__CHAR_UNSIGNED__ = cpp_lookup (pfile, DSC("__CHAR_UNSIGNED__"));
s->n__VA_ARGS__ = cpp_lookup (pfile, DSC("__VA_ARGS__")); s->n__VA_ARGS__ = cpp_lookup (pfile, DSC("__VA_ARGS__"));
s->n__VA_ARGS__->flags |= NODE_DIAGNOSTIC; s->n__VA_ARGS__->flags |= NODE_DIAGNOSTIC;
return pfile;
} }
/* Free resources used by PFILE. /* Free resources used by PFILE.
......
...@@ -696,16 +696,14 @@ struct cpp_hashnode ...@@ -696,16 +696,14 @@ struct cpp_hashnode
union tree_node *fe_value; /* Front end value. */ union tree_node *fe_value; /* Front end value. */
}; };
extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang));
extern unsigned int cpp_token_len PARAMS ((const cpp_token *)); extern unsigned int cpp_token_len PARAMS ((const cpp_token *));
extern unsigned char *cpp_token_as_text PARAMS ((cpp_reader *, extern unsigned char *cpp_token_as_text PARAMS ((cpp_reader *,
const cpp_token *)); const cpp_token *));
extern unsigned char *cpp_spell_token PARAMS ((cpp_reader *, const cpp_token *, extern unsigned char *cpp_spell_token PARAMS ((cpp_reader *, const cpp_token *,
unsigned char *)); unsigned char *));
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 *, enum c_lang));
extern void cpp_register_pragma PARAMS ((cpp_reader *, extern void cpp_register_pragma PARAMS ((cpp_reader *,
const char *, const char *, const char *, const char *,
void (*) PARAMS ((cpp_reader *)))); void (*) PARAMS ((cpp_reader *))));
......
...@@ -38,6 +38,8 @@ struct printer ...@@ -38,6 +38,8 @@ struct printer
}; };
int main PARAMS ((int, char **)); int main PARAMS ((int, char **));
static void general_init PARAMS ((const char *));
static void setup_callbacks PARAMS ((void));
/* General output routines. */ /* General output routines. */
static void scan_buffer PARAMS ((cpp_reader *)); static void scan_buffer PARAMS ((cpp_reader *));
...@@ -58,8 +60,8 @@ static void cb_change_file PARAMS ((cpp_reader *, const cpp_file_change *)); ...@@ -58,8 +60,8 @@ static void cb_change_file PARAMS ((cpp_reader *, const cpp_file_change *));
static void cb_def_pragma PARAMS ((cpp_reader *)); static void cb_def_pragma PARAMS ((cpp_reader *));
static void do_pragma_implementation PARAMS ((cpp_reader *)); static void do_pragma_implementation PARAMS ((cpp_reader *));
const char *progname; const char *progname; /* Needs to be global. */
static cpp_reader parse_in; static cpp_reader *pfile;
static struct printer print; static struct printer print;
int int
...@@ -67,25 +69,11 @@ main (argc, argv) ...@@ -67,25 +69,11 @@ main (argc, argv)
int argc; int argc;
char **argv; char **argv;
{ {
char *p;
cpp_reader *pfile = &parse_in;
int argi = 1; /* Next argument to handle. */ int argi = 1; /* Next argument to handle. */
p = argv[0] + strlen (argv[0]); general_init (argv[0]);
while (p != argv[0] && ! IS_DIR_SEPARATOR (p[-1])) --p;
progname = p;
xmalloc_set_program_name (progname);
#ifdef HAVE_LC_MESSAGES
setlocale (LC_MESSAGES, "");
#endif
(void) bindtextdomain (PACKAGE, localedir);
(void) textdomain (PACKAGE);
cpp_init ();
/* Default language is GNU C89. */ /* Default language is GNU C89. */
cpp_reader_init (pfile, CLK_GNUC89); pfile = cpp_create_reader (CLK_GNUC89);
argi += cpp_handle_options (pfile, argc - argi , argv + argi); argi += cpp_handle_options (pfile, argc - argi , argv + argi);
if (argi < argc && ! CPP_FATAL_ERRORS (pfile)) if (argi < argc && ! CPP_FATAL_ERRORS (pfile))
...@@ -99,30 +87,7 @@ main (argc, argv) ...@@ -99,30 +87,7 @@ main (argc, argv)
if (printer_init (pfile)) if (printer_init (pfile))
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
/* Set callbacks. */ setup_callbacks ();
if (! CPP_OPTION (pfile, no_output))
{
pfile->cb.ident = cb_ident;
pfile->cb.def_pragma = cb_def_pragma;
if (! CPP_OPTION (pfile, no_line_commands))
pfile->cb.change_file = cb_change_file;
}
if (CPP_OPTION (pfile, dump_includes))
pfile->cb.include = cb_include;
if (CPP_OPTION (pfile, debug_output)
|| CPP_OPTION (pfile, dump_macros) == dump_names
|| CPP_OPTION (pfile, dump_macros) == dump_definitions)
{
pfile->cb.define = cb_define;
pfile->cb.undef = cb_undef;
pfile->cb.poison = cb_def_pragma;
}
/* Register one #pragma which needs special handling. */
cpp_register_pragma(pfile, 0, "implementation", do_pragma_implementation);
cpp_register_pragma(pfile, "GCC", "implementation", do_pragma_implementation);
if (! cpp_start_read (pfile, CPP_OPTION (pfile, in_fname))) if (! cpp_start_read (pfile, CPP_OPTION (pfile, in_fname)))
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
...@@ -148,11 +113,59 @@ main (argc, argv) ...@@ -148,11 +113,59 @@ main (argc, argv)
if (ferror (print.outf) || fclose (print.outf)) if (ferror (print.outf) || fclose (print.outf))
cpp_notice_from_errno (pfile, CPP_OPTION (pfile, out_fname)); cpp_notice_from_errno (pfile, CPP_OPTION (pfile, out_fname));
if (parse_in.errors) if (pfile->errors)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
return (SUCCESS_EXIT_CODE); return (SUCCESS_EXIT_CODE);
} }
/* Store the program name, and set the locale. */
static void
general_init (const char *argv0)
{
progname = argv0 + strlen (argv0);
while (progname != argv0 && ! IS_DIR_SEPARATOR (progname[-1]))
--progname;
xmalloc_set_program_name (progname);
#ifdef HAVE_LC_MESSAGES
setlocale (LC_MESSAGES, "");
#endif
(void) bindtextdomain (PACKAGE, localedir);
(void) textdomain (PACKAGE);
}
/* Set up the callbacks and register the pragmas we handle. */
static void
setup_callbacks ()
{
/* Set callbacks. */
if (! CPP_OPTION (pfile, no_output))
{
pfile->cb.ident = cb_ident;
pfile->cb.def_pragma = cb_def_pragma;
if (! CPP_OPTION (pfile, no_line_commands))
pfile->cb.change_file = cb_change_file;
}
if (CPP_OPTION (pfile, dump_includes))
pfile->cb.include = cb_include;
if (CPP_OPTION (pfile, debug_output)
|| CPP_OPTION (pfile, dump_macros) == dump_names
|| CPP_OPTION (pfile, dump_macros) == dump_definitions)
{
pfile->cb.define = cb_define;
pfile->cb.undef = cb_undef;
pfile->cb.poison = cb_def_pragma;
}
/* Register one #pragma which needs special handling. */
cpp_register_pragma(pfile, 0, "implementation", do_pragma_implementation);
cpp_register_pragma(pfile, "GCC", "implementation", do_pragma_implementation);
}
/* Writes out the preprocessed file. Alternates between two tokens, /* Writes out the preprocessed file. Alternates between two tokens,
so that we can avoid accidental token pasting. */ so that we can avoid accidental token pasting. */
static void static void
......
...@@ -612,36 +612,35 @@ read_scan_file (in_fname, argc, argv) ...@@ -612,36 +612,35 @@ read_scan_file (in_fname, argc, argv)
int argc; int argc;
char **argv; char **argv;
{ {
cpp_reader scan_in; cpp_reader* scan_in;
struct fn_decl *fn; struct fn_decl *fn;
int i; int i;
register struct symbol_list *cur_symbols; register struct symbol_list *cur_symbols;
obstack_init (&scan_file_obstack); obstack_init (&scan_file_obstack);
cpp_init (); /* Initialize cpplib. */ scan_in = cpp_create_reader (CLK_GNUC89);
cpp_reader_init (&scan_in, CLK_GNUC89); scan_in->cb.change_file = cb_change_file;
scan_in.cb.change_file = cb_change_file;
/* We are going to be scanning a header file out of its proper context, /* We are going to be scanning a header file out of its proper context,
so ignore warnings and errors. */ so ignore warnings and errors. */
CPP_OPTION (&scan_in, inhibit_warnings) = 1; CPP_OPTION (scan_in, inhibit_warnings) = 1;
CPP_OPTION (&scan_in, inhibit_errors) = 1; CPP_OPTION (scan_in, inhibit_errors) = 1;
i = cpp_handle_options (&scan_in, argc, argv); i = cpp_handle_options (scan_in, argc, argv);
if (i < argc && ! CPP_FATAL_ERRORS (&scan_in)) if (i < argc && ! CPP_FATAL_ERRORS (scan_in))
cpp_fatal (&scan_in, "Invalid option `%s'", argv[i]); cpp_fatal (scan_in, "Invalid option `%s'", argv[i]);
if (CPP_FATAL_ERRORS (&scan_in)) if (CPP_FATAL_ERRORS (scan_in))
exit (FATAL_EXIT_CODE); exit (FATAL_EXIT_CODE);
if (! cpp_start_read (&scan_in, in_fname)) if (! cpp_start_read (scan_in, in_fname))
exit (FATAL_EXIT_CODE); exit (FATAL_EXIT_CODE);
/* We are scanning a system header, so mark it as such. */ /* We are scanning a system header, so mark it as such. */
cpp_make_system_header (&scan_in, CPP_BUFFER (&scan_in), 1); cpp_make_system_header (scan_in, CPP_BUFFER (scan_in), 1);
scan_decls (&scan_in, argc, argv); scan_decls (scan_in, argc, argv);
for (cur_symbols = &symbol_table[0]; cur_symbols->names; cur_symbols++) for (cur_symbols = &symbol_table[0]; cur_symbols->names; cur_symbols++)
check_macro_names (&scan_in, cur_symbols->names); check_macro_names (scan_in, cur_symbols->names);
/* Traditionally, getc and putc are defined in terms of _filbuf and _flsbuf. /* Traditionally, getc and putc are defined in terms of _filbuf and _flsbuf.
If so, those functions are also required. */ If so, those functions are also required. */
...@@ -650,8 +649,8 @@ read_scan_file (in_fname, argc, argv) ...@@ -650,8 +649,8 @@ read_scan_file (in_fname, argc, argv)
{ {
static const unsigned char getchar_call[] = "getchar();"; static const unsigned char getchar_call[] = "getchar();";
int seen_filbuf = 0; int seen_filbuf = 0;
cpp_buffer *buf = CPP_BUFFER (&scan_in); cpp_buffer *buf = CPP_BUFFER (scan_in);
if (cpp_push_buffer (&scan_in, getchar_call, if (cpp_push_buffer (scan_in, getchar_call,
sizeof(getchar_call) - 1) == NULL) sizeof(getchar_call) - 1) == NULL)
return; return;
...@@ -660,11 +659,11 @@ read_scan_file (in_fname, argc, argv) ...@@ -660,11 +659,11 @@ read_scan_file (in_fname, argc, argv)
{ {
cpp_token t; cpp_token t;
cpp_get_token (&scan_in, &t); cpp_get_token (scan_in, &t);
if (t.type == CPP_EOF) if (t.type == CPP_EOF)
{ {
cpp_pop_buffer (&scan_in); cpp_pop_buffer (scan_in);
if (CPP_BUFFER (&scan_in) == buf) if (CPP_BUFFER (scan_in) == buf)
break; break;
} }
else if (cpp_ideq (&t, "_filbuf")) else if (cpp_ideq (&t, "_filbuf"))
......
...@@ -56,7 +56,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -56,7 +56,6 @@ Boston, MA 02111-1307, USA. */
#include "toplev.h" #include "toplev.h"
#include "ggc.h" #include "ggc.h"
#include "cpplib.h" #include "cpplib.h"
extern cpp_reader parse_in;
/* This is the default way of generating a method name. */ /* This is the default way of generating a method name. */
/* I am not sure it is really correct. /* I am not sure it is really correct.
...@@ -695,8 +694,7 @@ generate_struct_by_value_array () ...@@ -695,8 +694,7 @@ generate_struct_by_value_array ()
void void
lang_init_options () lang_init_options ()
{ {
cpp_init (); parse_in = cpp_create_reader (CLK_GNUC89);
cpp_reader_init (&parse_in, CLK_GNUC89);
} }
void void
......
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