aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-ppoutput.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.co.uk>2003-03-06 23:12:30 +0000
committerNeil Booth <neil@gcc.gnu.org>2003-03-06 23:12:30 +0000
commit9d10c9a9eb26bb822177b177e0f8edc7000a3b70 (patch)
tree67d3347376b5ce3e8f6b568c099d8391313de175 /gcc/c-ppoutput.c
parentd1867128b29a772691b9d5909558cf8f478cb531 (diff)
Makefile.in (c-ppoutput.o): Update.
* Makefile.in (c-ppoutput.o): Update. * c-common.h (init_pp_output): New. (preprocess_file): Update. * c-lex.c (init_c_lex): Move mbchar initialization to cpplib. Register builtins. * c-opts.c (c_common_init): Call init_pp_output if preprocessing. Make call to cpp_read_main_file common to whether preprocessing or not. Don't register builtins. * c-ppoutput.c: Include c-pragma.h. (setup_callbacks): Rename init_pp_output. (preprocess_file): No longer setup callbacks or call cpp_read_main_file. * cpphash.h (_cpp_init_mbchar): New. * cppinit.c (init_library): Call _cpp_init_mbchar. * cpplex.c (_cpp_init_mbchar): New. From-SVN: r63913
Diffstat (limited to 'gcc/c-ppoutput.c')
-rw-r--r--gcc/c-ppoutput.c77
1 files changed, 35 insertions, 42 deletions
diff --git a/gcc/c-ppoutput.c b/gcc/c-ppoutput.c
index 16e2dc174bc..14ae31bb0b6 100644
--- a/gcc/c-ppoutput.c
+++ b/gcc/c-ppoutput.c
@@ -24,7 +24,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "cpplib.h"
#include "cpphash.h"
#include "tree.h"
-#include "c-common.h"
+#include "c-common.h" /* For flags. */
+#include "c-pragma.h" /* For parse_in. */
/* Encapsulates state used to convert a stream of tokens into a text
file. */
@@ -38,8 +39,6 @@ static struct
unsigned char printed; /* Nonzero if something output at line. */
} print;
-static void setup_callbacks PARAMS ((cpp_reader *));
-
/* General output routines. */
static void scan_translation_unit PARAMS ((cpp_reader *));
static void scan_translation_unit_trad PARAMS ((cpp_reader *));
@@ -64,44 +63,28 @@ static void cb_def_pragma PARAMS ((cpp_reader *, unsigned int));
/* Preprocess and output. */
void
-preprocess_file (pfile, in_fname, out_stream)
+preprocess_file (pfile)
cpp_reader *pfile;
- const char *in_fname;
- FILE *out_stream;
{
- /* Initialize the print structure. Setting print.line to -1 here is
- a trick to guarantee that the first token of the file will cause
- a linemarker to be output by maybe_print_line. */
- print.line = (unsigned int) -1;
- print.printed = 0;
- print.prev = 0;
- print.map = 0;
- print.outf = out_stream;
+ cpp_finish_options (pfile);
- setup_callbacks (pfile);
-
- if (cpp_read_main_file (pfile, in_fname, NULL))
+ /* A successful cpp_read_main_file guarantees that we can call
+ cpp_scan_nooutput or cpp_get_token next. */
+ if (flag_no_output)
{
- cpp_finish_options (pfile);
-
- /* A successful cpp_read_main_file guarantees that we can call
- cpp_scan_nooutput or cpp_get_token next. */
- if (flag_no_output)
- {
- /* Scan -included buffers, then the main file. */
- while (pfile->buffer->prev)
- cpp_scan_nooutput (pfile);
- cpp_scan_nooutput (pfile);
- }
- else if (cpp_get_options (pfile)->traditional)
- scan_translation_unit_trad (pfile);
- else
- scan_translation_unit (pfile);
-
- /* -dM command line option. Should this be elsewhere? */
- if (flag_dump_macros == 'M')
- cpp_forall_identifiers (pfile, dump_macro, NULL);
+ /* Scan -included buffers, then the main file. */
+ while (pfile->buffer->prev)
+ cpp_scan_nooutput (pfile);
+ cpp_scan_nooutput (pfile);
}
+ else if (cpp_get_options (pfile)->traditional)
+ scan_translation_unit_trad (pfile);
+ else
+ scan_translation_unit (pfile);
+
+ /* -dM command line option. Should this be elsewhere? */
+ if (flag_dump_macros == 'M')
+ cpp_forall_identifiers (pfile, dump_macro, NULL);
/* Flush any pending output. */
if (print.printed)
@@ -109,19 +92,20 @@ preprocess_file (pfile, in_fname, out_stream)
}
/* Set up the callbacks as appropriate. */
-static void
-setup_callbacks (pfile)
- cpp_reader *pfile;
+void
+init_pp_output (out_stream)
+ FILE *out_stream;
{
- cpp_options *options = &pfile->opts;
- cpp_callbacks *cb = cpp_get_callbacks (pfile);
+ cpp_callbacks *cb = cpp_get_callbacks (parse_in);
+
+ cb->register_builtins = cb_register_builtins;
if (!flag_no_output)
{
cb->line_change = cb_line_change;
/* Don't emit #pragma or #ident directives if we are processing
assembly language; the assembler may choke on them. */
- if (options->lang != CLK_ASM)
+ if (cpp_get_options (parse_in)->lang != CLK_ASM)
{
cb->ident = cb_ident;
cb->def_pragma = cb_def_pragma;
@@ -138,6 +122,15 @@ setup_callbacks (pfile)
cb->define = cb_define;
cb->undef = cb_undef;
}
+
+ /* Initialize the print structure. Setting print.line to -1 here is
+ a trick to guarantee that the first token of the file will cause
+ a linemarker to be output by maybe_print_line. */
+ print.line = (unsigned int) -1;
+ print.printed = 0;
+ print.prev = 0;
+ print.map = 0;
+ print.outf = out_stream;
}
/* Writes out the preprocessed file, handling spacing and paste