diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-17 20:16:48 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-17 20:16:48 +0000 |
commit | 0bb657046056b7eb4f07247102f7178955569f48 (patch) | |
tree | 06c8cca4d252c4189a9e560a900afba199add8fc /gcc/cppinit.c | |
parent | 9f3643d19552a7736160ffa7a06b5c006f2bedf0 (diff) | |
download | gcc-0bb657046056b7eb4f07247102f7178955569f48.tar.gz |
* Makefile.in: Update for cpptrad.c.
* cpphash.h (struct cpp_buffer): New members for buffer
overlays.
(struct cpp_reader): New members for traditional output.
(_cpp_read_logical_line, _cpp_overlay_buffer): New.
* cppinit.c (cpp_create_reader): Set trad_line.
(cpp_destroy): Free trad_out_base if used.
(cpp_read_main_file): Overlay an empty buffer if traditional.
(cpp_finish_options): Don't do builtins.
(COMMAND_LINE_OPTIONS): Add -traditional-cpp.
(cpp_handle_option): Handle it.
* cpplex.c (continue_after_nul): New.
(_cpp_lex_direct): Use handle_nul.
* cpplib.h (struct cpp_options): New traditional option.
* cpptrad.c: New file.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53568 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r-- | gcc/cppinit.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c index cb3f483d550..c7d51b765e9 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -510,7 +510,7 @@ cpp_create_reader (lang) /* Initialise the line map. Start at logical line 1, so we can use a line number of zero for special states. */ init_line_maps (&pfile->line_maps); - pfile->line = 1; + pfile->trad_line = pfile->line = 1; /* Initialize lexer state. */ pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments); @@ -565,6 +565,9 @@ cpp_destroy (pfile) while (CPP_BUFFER (pfile) != NULL) _cpp_pop_buffer (pfile); + if (pfile->trad_out_base) + free (pfile->trad_out_base); + if (pfile->macro_buffer) { free ((PTR) pfile->macro_buffer); @@ -950,6 +953,9 @@ cpp_read_main_file (pfile, fname, table) of the front ends. */ if (CPP_OPTION (pfile, preprocessed)) read_original_filename (pfile); + /* Overlay an empty buffer to seed traditional preprocessing. */ + else if (CPP_OPTION (pfile, traditional)) + _cpp_overlay_buffer (pfile, U"", 0); return pfile->map->to_file; } @@ -998,10 +1004,12 @@ cpp_finish_options (pfile) struct pending_option *p; _cpp_do_file_change (pfile, LC_RENAME, _("<built-in>"), 1, 0); - init_builtins (pfile); + if (!CPP_OPTION (pfile, traditional) /* REMOVEME */) + init_builtins (pfile); _cpp_do_file_change (pfile, LC_RENAME, _("<command line>"), 1, 0); - for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next) - (*p->handler) (pfile, p->arg); + if (!CPP_OPTION (pfile, traditional) /* REMOVEME */) + for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next) + (*p->handler) (pfile, p->arg); /* Scan -imacros files after -D, -U, but before -include. pfile->next_include_file is NULL, so _cpp_pop_buffer does not @@ -1195,6 +1203,7 @@ new_pending_directive (pend, text, handler) DEF_OPT("std=iso9899:199409", 0, OPT_std_iso9899_199409) \ DEF_OPT("std=iso9899:1999", 0, OPT_std_iso9899_1999) \ DEF_OPT("std=iso9899:199x", 0, OPT_std_iso9899_199x) \ + DEF_OPT("traditional-cpp", 0, OPT_traditional_cpp) \ DEF_OPT("trigraphs", 0, OPT_trigraphs) \ DEF_OPT("v", 0, OPT_v) \ DEF_OPT("version", 0, OPT_version) \ @@ -1444,6 +1453,9 @@ cpp_handle_option (pfile, argc, argv, ignore) case OPT_remap: CPP_OPTION (pfile, remap) = 1; break; + case OPT_traditional_cpp: + CPP_OPTION (pfile, traditional) = 1; + break; case OPT_iprefix: CPP_OPTION (pfile, include_prefix) = arg; CPP_OPTION (pfile, include_prefix_len) = strlen (arg); |