From 2b2a353188fa3bbf45631bcb876f419b9cb6364a Mon Sep 17 00:00:00 2001 From: Dave Brolley Date: Wed, 8 Apr 1998 23:30:28 +0000 Subject: [PATCH] lex.c (finput): New variable. * lex.c (finput): New variable. (init_cpp_parse): Renamed from init_parse. (init_parse): Handle !USE_CPPLIB. Call init_cpp_parse when finished. (finish_parse): New function. * cp-tree.h (init_lex, init_parse): Remove declarations. From-SVN: r19065 --- gcc/cp/ChangeLog | 8 ++++++ gcc/cp/cp-tree.h | 2 -- gcc/cp/lex.c | 69 +++++++++++++++++++++++++++++++++++------------- gcc/cp/spew.c | 2 +- 4 files changed, 59 insertions(+), 22 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 02b3f696a4a..64f5a592cb1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +Thu Apr 9 00:18:44 1998 Dave Brolley (brolley@cygnus.com) + + * lex.c (finput): New variable. + (init_cpp_parse): Renamed from init_parse. + (init_parse): Handle !USE_CPPLIB. Call init_cpp_parse when finished. + (finish_parse): New function. + * cp-tree.h (init_lex, init_parse): Remove declarations. + Mon Apr 6 02:25:05 1998 Jason Merrill * call.c (build_call): Still evaluate the actual argument. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 443c83edc4f..3da7f89178a 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2345,9 +2345,7 @@ extern void init_filename_times PROTO((void)); #if 0 extern void reinit_lang_specific PROTO((void)); #endif -extern void init_lex PROTO((void)); extern void reinit_parse_for_function PROTO((void)); -extern int *init_parse PROTO((void)); extern void print_parse_statistics PROTO((void)); extern void extract_interface_info PROTO((void)); extern void do_pending_inlines PROTO((void)); diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 9d724a535ff..60333008db4 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -108,6 +108,9 @@ file_name_nondirectory (x) struct obstack inline_text_obstack; char *inline_text_firstobj; +#if !USE_CPPLIB +FILE *finput; +#endif int end_of_file; /* Pending language change. @@ -425,7 +428,7 @@ init_filename_times () /* Change by Bryan Boreham, Kewill, Thu Jul 27 09:46:05 1989. Stuck this hack in to get the files open correctly; this is called - in place of init_lex if we are an unexec'd binary. */ + in place of init_parse if we are an unexec'd binary. */ #if 0 void @@ -436,14 +439,48 @@ reinit_lang_specific () } #endif +static int * +init_cpp_parse () +{ +#ifdef GATHER_STATISTICS +#ifdef REDUCE_LENGTH + reduce_count = (int *)malloc (sizeof (int) * (REDUCE_LENGTH + 1)); + bzero (reduce_count, sizeof (int) * (REDUCE_LENGTH + 1)); + reduce_count += 1; + token_count = (int *)malloc (sizeof (int) * (TOKEN_LENGTH + 1)); + bzero (token_count, sizeof (int) * (TOKEN_LENGTH + 1)); + token_count += 1; +#endif +#endif + return token_count; +} + void -init_lex () +init_parse (filename) + char *filename; { extern int flag_no_gnu_keywords; extern int flag_operator_names; int i; +#if !USE_CPPLIB + /* Open input file. */ + if (filename == 0 || !strcmp (filename, "-")) + { + finput = stdin; + filename = "stdin"; + } + else + finput = fopen (filename, "r"); + if (finput == 0) + pfatal_with_name (filename); + +#ifdef IO_BUFFER_SIZE + setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE); +#endif +#endif /* !USE_CPPLIB */ + /* Initialize the lookahead machinery. */ init_spew (); @@ -851,10 +888,20 @@ init_lex () UNSET_RESERVED_WORD ("xor_eq"); } - token_count = init_parse (); + token_count = init_cpp_parse (); interface_unknown = 1; } +void +finish_parse () +{ +#if USE_CPPLIB + cpp_finish (&parse_in); +#else + fclose (finput); +#endif +} + void reinit_parse_for_function () { @@ -922,22 +969,6 @@ int *token_count; #define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0])) #endif -int * -init_parse () -{ -#ifdef GATHER_STATISTICS -#ifdef REDUCE_LENGTH - reduce_count = (int *)malloc (sizeof (int) * (REDUCE_LENGTH + 1)); - bzero (reduce_count, sizeof (int) * (REDUCE_LENGTH + 1)); - reduce_count += 1; - token_count = (int *)malloc (sizeof (int) * (TOKEN_LENGTH + 1)); - bzero (token_count, sizeof (int) * (TOKEN_LENGTH + 1)); - token_count += 1; -#endif -#endif - return token_count; -} - #ifdef GATHER_STATISTICS #ifdef REDUCE_LENGTH void diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c index 08446792901..ceee4e66d13 100644 --- a/gcc/cp/spew.c +++ b/gcc/cp/spew.c @@ -69,7 +69,7 @@ static unsigned int yylex_ctr = 0; static int debug_yychar (); #endif -/* Initialize token_obstack. Called once, from init_lex. */ +/* Initialize token_obstack. Called once, from init_parse. */ void init_spew () -- 2.30.2