diff options
author | Neil Booth <neil@daikokuya.demon.co.uk> | 2002-06-04 13:07:06 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2002-06-04 13:07:06 +0000 |
commit | 82eda77ed5c4548bd5cbb3f5bbe6f3453a3d1eea (patch) | |
tree | 3c0127db39d15911aba3137af7f41daa9c7866bf /gcc/cpptrad.c | |
parent | 589005ff217dde6c3c22842e27315d597a8fe710 (diff) | |
download | gcc-82eda77ed5c4548bd5cbb3f5bbe6f3453a3d1eea.zip gcc-82eda77ed5c4548bd5cbb3f5bbe6f3453a3d1eea.tar.gz gcc-82eda77ed5c4548bd5cbb3f5bbe6f3453a3d1eea.tar.bz2 |
cpphash.h (FIRST, [...]): New.
* cpphash.h (FIRST, LAST, CUR, RLIMIT): New.
(struct cpp_context): Add traditional fields.
* cppmacro.c (paste_all_tokens, push_ptoken_context,
push_token_context, cpp_get_token, _cpp_backup_tokens): Update.
* cpptrad.c (skip_comment, lex_identifier,
_cpp_read_logical_line_trad, scan_out_logical_line): Update.
From-SVN: r54242
Diffstat (limited to 'gcc/cpptrad.c')
-rw-r--r-- | gcc/cpptrad.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/gcc/cpptrad.c b/gcc/cpptrad.c index d5c2126..4f4d97c 100644 --- a/gcc/cpptrad.c +++ b/gcc/cpptrad.c @@ -23,7 +23,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Lexing TODO: Handle -C, maybe -CC, and space in escaped newlines. Stop cpplex.c from recognizing comments and directives during its - lexing pass. */ + lexing pass. Get rid of line_base usage - seems pointless? */ static const uchar *handle_newline PARAMS ((cpp_reader *, const uchar *)); static const uchar *skip_escaped_newlines PARAMS ((cpp_reader *, @@ -90,8 +90,8 @@ skip_comment (pfile, cur) const uchar *cur; { unsigned int from_line = pfile->line; - unsigned int c = 0, prevc; - const uchar *limit = pfile->buffer->rlimit; + unsigned int c = 0, prevc = 0; + const uchar *limit = RLIMIT (pfile->context); while (cur < limit) { @@ -138,7 +138,7 @@ lex_identifier (pfile, cur) } while (ISIDNUM (*cur)); - pfile->buffer->cur = cur; + CUR (pfile->context) = cur; len = out - pfile->trad_out_cur; pfile->trad_out_cur = out; return (cpp_hashnode *) ht_lookup (pfile->hash_table, pfile->trad_out_cur, @@ -206,8 +206,12 @@ _cpp_read_logical_line_trad (pfile) return false; } + CUR (pfile->context) = buffer->cur; + RLIMIT (pfile->context) = buffer->rlimit; pfile->trad_out_cur = pfile->trad_out_base; scan_out_logical_line (pfile); + buffer->cur = CUR (pfile->context); + pfile->trad_line = pfile->line; pfile->line = first_line; _cpp_overlay_buffer (pfile, pfile->trad_out_base, @@ -222,12 +226,12 @@ static void scan_out_logical_line (pfile) cpp_reader *pfile; { - cpp_buffer *buffer = pfile->buffer; - const uchar *cur = buffer->cur; + cpp_context *context = pfile->context; + const uchar *cur = CUR (context); unsigned int c, quote = 0; uchar *out; - check_output_buffer (pfile, buffer->rlimit - cur); + check_output_buffer (pfile, RLIMIT (context) - cur); out = pfile->trad_out_cur; for (;;) @@ -240,20 +244,20 @@ scan_out_logical_line (pfile) switch (c) { case '\0': - if (cur - 1 != buffer->rlimit) + if (cur - 1 != RLIMIT (context)) break; cur--; - if (!buffer->from_stage3) + if (!pfile->buffer->from_stage3) cpp_error (pfile, DL_PEDWARN, "no newline at end of file"); pfile->line++; - if (0) - { - case '\r': case '\n': - cur = handle_newline (pfile, cur - 1); - } + goto finish_output; + + case '\r': case '\n': + cur = handle_newline (pfile, cur - 1); + finish_output: out[-1] = '\n'; out[0] = '\0'; - buffer->cur = cur; + CUR (context) = cur; pfile->trad_out_cur = out; return; @@ -306,7 +310,7 @@ scan_out_logical_line (pfile) pfile->trad_out_cur = --out; node = lex_identifier (pfile, cur - 1); out = pfile->trad_out_cur; - cur = buffer->cur; + cur = CUR (context); } break; |