diff options
author | Zack Weinberg <zack@wolery.cumb.org> | 2000-07-15 19:29:14 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-07-15 19:29:14 +0000 |
commit | 2c0accc920f19896d91fc0afb8cb8825a5147dbe (patch) | |
tree | 13e7a6035db05f91cea3851df746122575c0e6a7 /gcc/cpplex.c | |
parent | a8c12308a05ef399cf985d3c9382207a801c310c (diff) | |
download | gcc-2c0accc920f19896d91fc0afb8cb8825a5147dbe.zip gcc-2c0accc920f19896d91fc0afb8cb8825a5147dbe.tar.gz gcc-2c0accc920f19896d91fc0afb8cb8825a5147dbe.tar.bz2 |
cpphash.c (save_expansion): Clear PREV_WHITE on tokens immediately following a paste operator.
* cpphash.c (save_expansion): Clear PREV_WHITE on tokens
immediately following a paste operator.
* cppinit.c (sort_options): New function (only for HOST_EBCDIC).
(cpp_reader_init): Call it, if HOST_EBCDIC.
(cpp_handle_options): Do not sort option list here.
(handle_option): Rename to cpp_handle_option and export.
* cpplex.c (cpp_scan_buffer_nooutput, cpp_scan_buffer): Use
_cpp_get_token directly.
(cpp_scan_line): Return 0 at EOF, 1 otherwise.
* cpplib.c (cpp_push_buffer): Don't set new->lineno to 1.
* cpplib.h: Prototype cpp_handle_option. Update prototype of
cpp_scan_line.
From-SVN: r35052
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r-- | gcc/cpplex.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c index fa5b638..32aaaab 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -412,22 +412,30 @@ void cpp_scan_buffer_nooutput (pfile) cpp_reader *pfile; { - unsigned int old_written = CPP_WRITTEN (pfile); cpp_buffer *stop = CPP_PREV_BUFFER (CPP_BUFFER (pfile)); + const cpp_token *token; + /* In no-output mode, we can ignore everything but directives. */ for (;;) { - /* In no-output mode, we can ignore everything but directives. */ - const cpp_token *token = cpp_get_token (pfile); + token = _cpp_get_token (pfile); + if (token->type == CPP_EOF) { cpp_pop_buffer (pfile); if (CPP_BUFFER (pfile) == stop) break; } + + if (token->type == CPP_HASH && token->flags & BOL + && pfile->token_list.directive) + { + process_directive (pfile, token); + continue; + } + _cpp_skip_rest_of_line (pfile); } - CPP_SET_WRITTEN (pfile, old_written); } /* Scan until CPP_BUFFER (pfile) is exhausted, writing output to PRINT. */ @@ -441,12 +449,13 @@ cpp_scan_buffer (pfile, print) for (;;) { - token = cpp_get_token (pfile); + token = _cpp_get_token (pfile); if (token->type == CPP_EOF) { cpp_pop_buffer (pfile); if (CPP_BUFFER (pfile) == stop) return; + cpp_output_tokens (pfile, print, CPP_BUF_LINE (CPP_BUFFER (pfile))); prev = 0; continue; @@ -454,22 +463,33 @@ cpp_scan_buffer (pfile, print) if (token->flags & BOL) { + if (token->type == CPP_HASH && pfile->token_list.directive) + { + process_directive (pfile, token); + continue; + } + cpp_output_tokens (pfile, print, pfile->token_list.line); prev = 0; } - output_token (pfile, token, prev); + if (token->type != CPP_PLACEMARKER) + output_token (pfile, token, prev); + prev = token; } } /* Scan a single line of the input into the token_buffer. */ -void +int cpp_scan_line (pfile) cpp_reader *pfile; { const cpp_token *token, *prev = 0; + if (pfile->buffer == NULL) + return 0; + do { token = cpp_get_token (pfile); @@ -479,11 +499,18 @@ cpp_scan_line (pfile) break; } + /* If the last token on a line results from a macro expansion, + the check below will fail to stop us from proceeding to the + next line - so make sure we stick in a newline, at least. */ + if (token->flags & BOL) + CPP_PUTC (pfile, '\n'); + output_token (pfile, token, prev); prev = token; } while (pfile->cur_context > 0 || pfile->contexts[0].posn < pfile->contexts[0].count); + return 1; } /* Helper routine used by parse_include, which can't see spell_token. |