aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppinit.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2000-08-02 01:13:45 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-08-02 01:13:45 +0000
commit58fea6afd912f7c309c156522391b20462372ceb (patch)
treeaf945d1943c9c6b458fec03b961f8f0d523896bf /gcc/cppinit.c
parent8cd8f856b33bbd6c6627eb0a18e34b046e2163f1 (diff)
downloadgcc-58fea6afd912f7c309c156522391b20462372ceb.zip
gcc-58fea6afd912f7c309c156522391b20462372ceb.tar.gz
gcc-58fea6afd912f7c309c156522391b20462372ceb.tar.bz2
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro.
* cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r--gcc/cppinit.c58
1 files changed, 10 insertions, 48 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index 5f5c620..e1bcda9 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -114,7 +114,6 @@ static int opt_comp PARAMS ((const void *, const void *));
static void sort_options PARAMS ((void));
#endif
static int parse_option PARAMS ((const char *));
-static int dump_macros_helper PARAMS ((cpp_reader *, cpp_hashnode *));
/* Fourth argument to append_include_chain: chain to use */
enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
@@ -415,10 +414,6 @@ cpp_reader_init (pfile)
memset ((char *) pfile, 0, sizeof (cpp_reader));
- pfile->token_buffer_size = 200;
- pfile->token_buffer = (U_CHAR *) xmalloc (pfile->token_buffer_size);
- CPP_SET_WRITTEN (pfile, 0);
-
CPP_OPTION (pfile, dollars_in_ident) = 1;
CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, warn_import) = 1;
@@ -434,6 +429,7 @@ cpp_reader_init (pfile)
_cpp_init_macros (pfile);
_cpp_init_stacks (pfile);
_cpp_init_includes (pfile);
+ _cpp_init_internal_pragmas (pfile);
}
/* Initialize a cpp_printer structure. As a side effect, open the
@@ -470,12 +466,6 @@ cpp_cleanup (pfile)
while (CPP_BUFFER (pfile) != NULL)
cpp_pop_buffer (pfile);
- if (pfile->token_buffer)
- {
- free (pfile->token_buffer);
- pfile->token_buffer = NULL;
- }
-
if (pfile->deps)
deps_free (pfile->deps);
@@ -857,18 +847,6 @@ cpp_start_read (pfile, print, fname)
initialize_dependency_output (pfile);
- /* -D and friends may produce output, which should be identified
- as line 0. */
-
- CPP_BUFFER (pfile)->lineno = 0;
- if (print)
- {
- print->last_fname = CPP_BUFFER (pfile)->nominal_fname;
- print->last_id = pfile->include_depth;
- print->written = CPP_WRITTEN (pfile);
- print->lineno = 0;
- }
-
/* Install __LINE__, etc. */
initialize_builtins (pfile);
@@ -883,12 +861,12 @@ cpp_start_read (pfile, print, fname)
}
pfile->done_initializing = 1;
- /* Now flush any output recorded during initialization, and advance
- to line 1 of the main input file. */
- CPP_BUFFER (pfile)->lineno = 1;
-
- if (print && ! CPP_OPTION (pfile, no_output))
- cpp_output_tokens (pfile, print, 1);
+ /* We start at line 1 of the main input file. */
+ if (print)
+ {
+ print->last_fname = CPP_BUFFER (pfile)->nominal_fname;
+ print->lineno = 1;
+ }
/* The -imacros files can be scanned now, but the -include files
have to be pushed onto the include stack and processed later,
@@ -907,9 +885,7 @@ cpp_start_read (pfile, print, fname)
p = CPP_OPTION (pfile, pending)->include_head;
while (p)
{
- if (cpp_read_file (pfile, p->arg)
- && print && ! CPP_OPTION (pfile, no_output))
- cpp_output_tokens (pfile, print, 1); /* record entry to file */
+ cpp_read_file (pfile, p->arg);
q = p->next;
free (p);
p = q;
@@ -921,18 +897,6 @@ cpp_start_read (pfile, print, fname)
return 1;
}
-
-/* Dump out the hash table. */
-static int
-dump_macros_helper (pfile, hp)
- cpp_reader *pfile;
- cpp_hashnode *hp;
-{
- if (hp->type == T_MACRO)
- _cpp_dump_definition (pfile, hp);
- return 1;
-}
-
/* This is called at the end of preprocessing. It pops the
last buffer and writes dependency output. It should also
clear macro definitions, such that you could call cpp_start_read
@@ -975,13 +939,11 @@ cpp_finish (pfile, print)
}
}
- if (CPP_OPTION (pfile, dump_macros) == dump_only)
- cpp_forall_identifiers (pfile, dump_macros_helper);
-
/* Flush any pending output. */
if (print)
{
- cpp_output_tokens (pfile, print, print->lineno);
+ if (pfile->need_newline)
+ putc ('\n', print->outf);
if (ferror (print->outf) || fclose (print->outf))
cpp_notice_from_errno (pfile, CPP_OPTION (pfile, out_fname));
}