diff options
author | Neil Booth <neil@cat.daikokuya.demon.co.uk> | 2001-08-04 12:01:59 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2001-08-04 12:01:59 +0000 |
commit | ef6e958a8611ff372211d0fd3cd9659614583bb4 (patch) | |
tree | 0aaaf48e2153d5621bc68cb09f9c0d2ef9a3854a /gcc/cppmain.c | |
parent | 03997728b499f76a20356705aa4d05d808ab9c3c (diff) | |
download | gcc-ef6e958a8611ff372211d0fd3cd9659614583bb4.zip gcc-ef6e958a8611ff372211d0fd3cd9659614583bb4.tar.gz gcc-ef6e958a8611ff372211d0fd3cd9659614583bb4.tar.bz2 |
Makefile.in (CPPLIB_H): New, so that dependencies on cpplib.h are also on line-map.h.
* Makefile.in (CPPLIB_H): New, so that dependencies on cpplib.h
are also on line-map.h.
* cppfiles.c (stack_include_file): Update.
* cpphash.h (struct cpp_buffer): New member return_at_eof.
(_cpp_pop_buffer): New.
* cppinit.c (cpp_destroy, cpp_finish): Update.
(do_includes): Mark each buffer to return at EOF.
* cpplex.c (_cpp_lex_token): Pop buffers at EOF. Continue or
return as requested.
* cpplib.c (run_directive, do_line, cpp_push_buffer): Update.
(cpp_pop_buffer): Rename _cpp_pop_buffer. Stop skipping.
* cpplib.h (cpp_pop_buffer): Remove.
(cpp_scan_buffer_nooutput): Rename cpp_scan_nooutput.
* cppmacro.c (cpp_scan_buffer_nooutput): Similarly. No need to pop
buffers.
* cppmain.c (scan_buffer): Rename scan_translation_unit. No need
to pop buffers.
(do_preprocessing): Update.
* fix-header.c (read_scan_file): Update. No need to pop buffers.
* c-parse.in (_yylex): Similarly.
* scan-decls.c (scan_decls): Similarly.
* line-map.h: Update comments.
* cp/spew.c (read_token): No need to pop buffers.
* objc/Make-lang.in (objc-act.o): Update dependencies.
From-SVN: r44634
Diffstat (limited to 'gcc/cppmain.c')
-rw-r--r-- | gcc/cppmain.c | 88 |
1 files changed, 42 insertions, 46 deletions
diff --git a/gcc/cppmain.c b/gcc/cppmain.c index cc3b81d..9dfb680 100644 --- a/gcc/cppmain.c +++ b/gcc/cppmain.c @@ -44,7 +44,7 @@ static void do_preprocessing PARAMS ((int, char **)); static void setup_callbacks PARAMS ((void)); /* General output routines. */ -static void scan_buffer PARAMS ((cpp_reader *)); +static void scan_translation_unit PARAMS ((cpp_reader *)); static void check_multiline_token PARAMS ((cpp_string *)); static int printer_init PARAMS ((cpp_reader *)); static int dump_macro PARAMS ((cpp_reader *, cpp_hashnode *, void *)); @@ -151,11 +151,11 @@ do_preprocessing (argc, argv) if (cpp_start_read (pfile, options->in_fname)) { /* A successful cpp_start_read guarantees that we can call - cpp_scan_buffer_nooutput or cpp_get_token next. */ + cpp_scan_nooutput or cpp_get_token next. */ if (options->no_output) - cpp_scan_buffer_nooutput (pfile, 1); + cpp_scan_nooutput (pfile); else - scan_buffer (pfile); + scan_translation_unit (pfile); /* -dM command line option. Should this be in cpp_finish? */ if (options->dump_macros == dump_only) @@ -200,60 +200,56 @@ setup_callbacks () /* Writes out the preprocessed file. Alternates between two tokens, so that we can avoid accidental token pasting. */ static void -scan_buffer (pfile) +scan_translation_unit (pfile) cpp_reader *pfile; { unsigned int index, line; cpp_token tokens[2], *token; - do + for (index = 0;; index = 1 - index) { - for (index = 0;; index = 1 - index) - { - token = &tokens[index]; - cpp_get_token (pfile, token); + token = &tokens[index]; + cpp_get_token (pfile, token); - if (token->type == CPP_EOF) - break; + if (token->type == CPP_EOF) + break; - line = cpp_get_line (pfile)->output_line; - if (print.lineno != line) + line = cpp_get_line (pfile)->output_line; + if (print.lineno != line) + { + unsigned int col = cpp_get_line (pfile)->col; + + /* Supply enough whitespace to put this token in its original + column. Don't bother trying to reconstruct tabs; we can't + get it right in general, and nothing ought to care. (Yes, + some things do care; the fault lies with them.) */ + maybe_print_line (line); + if (col > 1) { - unsigned int col = cpp_get_line (pfile)->col; - - /* Supply enough whitespace to put this token in its original - column. Don't bother trying to reconstruct tabs; we can't - get it right in general, and nothing ought to care. (Yes, - some things do care; the fault lies with them.) */ - maybe_print_line (line); - if (col > 1) - { - if (token->flags & PREV_WHITE) - col--; - while (--col) - putc (' ', print.outf); - } + if (token->flags & PREV_WHITE) + col--; + while (--col) + putc (' ', print.outf); } - else if ((token->flags & (PREV_WHITE | AVOID_LPASTE)) - == AVOID_LPASTE - && cpp_avoid_paste (pfile, &tokens[1 - index], token)) - token->flags |= PREV_WHITE; - /* Special case '# <directive name>': insert a space between - the # and the token. This will prevent it from being - treated as a directive when this code is re-preprocessed. - XXX Should do this only at the beginning of a line, but how? */ - else if (token->type == CPP_NAME && token->val.node->directive_index - && tokens[1 - index].type == CPP_HASH) - token->flags |= PREV_WHITE; - - cpp_output_token (token, print.outf); - print.printed = 1; - if (token->type == CPP_STRING || token->type == CPP_WSTRING - || token->type == CPP_COMMENT) - check_multiline_token (&token->val.str); } + else if ((token->flags & (PREV_WHITE | AVOID_LPASTE)) + == AVOID_LPASTE + && cpp_avoid_paste (pfile, &tokens[1 - index], token)) + token->flags |= PREV_WHITE; + /* Special case '# <directive name>': insert a space between + the # and the token. This will prevent it from being + treated as a directive when this code is re-preprocessed. + XXX Should do this only at the beginning of a line, but how? */ + else if (token->type == CPP_NAME && token->val.node->directive_index + && tokens[1 - index].type == CPP_HASH) + token->flags |= PREV_WHITE; + + cpp_output_token (token, print.outf); + print.printed = 1; + if (token->type == CPP_STRING || token->type == CPP_WSTRING + || token->type == CPP_COMMENT) + check_multiline_token (&token->val.str); } - while (cpp_pop_buffer (pfile) != 0); } /* Adjust print.lineno for newlines embedded in tokens. */ |