diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-09 21:18:15 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-09 21:18:15 +0000 |
commit | e14c5993de27982232381cc1d9f42d42514e982a (patch) | |
tree | faf4076c83d65bd44e0d82d85813fd94e77029cf /gcc/cpplex.c | |
parent | 83b2aef3ec267ff247aeb25b373128e947eb7283 (diff) | |
download | gcc-e14c5993de27982232381cc1d9f42d42514e982a.tar.gz |
* cpphash.c: Move cpp_defined here from cpplib.c.
* cpplib.c: Update comments, move cpp_defined to cpphash.c.
* cpplex.c (_cpp_lex_token): Don't leave the lexer at EOL.
* cppmacro.c (cpp_get_token): Update comments, no need now
to catch the CPP_EOF meaning EOL case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37345 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r-- | gcc/cpplex.c | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c index fb5eec55929..9aff13d82b2 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -846,8 +846,7 @@ _cpp_lex_token (pfile, result) cppchar_t c; cpp_buffer *buffer; const unsigned char *comment_start; - unsigned char was_skip_newlines = pfile->state.skip_newlines; - unsigned char newline_in_args = 0; + unsigned char bol = pfile->state.skip_newlines; done_directive: buffer = pfile->buffer; @@ -884,33 +883,23 @@ _cpp_lex_token (pfile, result) goto next_char2; case '\n': case '\r': - /* Don't let directives spill over to the next line. */ - if (pfile->state.in_directive) - buffer->read_ahead = c; - else + if (!pfile->state.in_directive) { handle_newline (buffer, c); - + bol = 1; pfile->lexer_pos.output_line = buffer->lineno; - /* Skip newlines in macro arguments (except in directives). */ + /* Newlines in arguments are white space (6.10.3.10). + Otherwise, clear any white space flag. */ if (pfile->state.parsing_args) - { - /* Set the whitespace flag. */ - newline_in_args = 1; - result->flags |= PREV_WHITE; - goto next_char; - } - - if (was_skip_newlines) - { - /* Clear any whitespace flag. */ - result->flags &= ~PREV_WHITE; - goto next_char; - } + result->flags |= PREV_WHITE; + else + result->flags &= ~PREV_WHITE; + goto next_char; } - /* Next we're at BOL, so skip new lines. */ + /* Don't let directives spill over to the next line. */ + buffer->read_ahead = c; pfile->state.skip_newlines = 1; result->type = CPP_EOF; break; @@ -1172,12 +1161,16 @@ _cpp_lex_token (pfile, result) c = get_effective_char (buffer); if (c == '#') - ACCEPT_CHAR (CPP_PASTE); - else { - result->type = CPP_HASH; - do_hash: - if (newline_in_args) + ACCEPT_CHAR (CPP_PASTE); + break; + } + + result->type = CPP_HASH; + do_hash: + if (bol) + { + if (pfile->state.parsing_args) { /* 6.10.3 paragraph 11: If there are sequences of preprocessing tokens within the list of arguments that @@ -1200,11 +1193,11 @@ _cpp_lex_token (pfile, result) if (pfile->lexer_pos.col == 1) result->flags &= ~PREV_WHITE; } - else if (was_skip_newlines) + else { /* This is the hash introducing a directive. */ if (_cpp_handle_directive (pfile, result->flags & PREV_WHITE)) - goto done_directive; /* was_skip_newlines still 1. */ + goto done_directive; /* bol still 1. */ /* This is in fact an assembler #. */ } } |