aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorNeil Booth <neil@cat.daikokuya.demon.co.uk>2001-08-01 06:19:39 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-08-01 06:19:39 +0000
commit1444f2ed7cfaf30f6e50da21f9a74e164f1fad84 (patch)
tree31a44a63f5280d362281e3aedf7c120f4aed024a /gcc/cpplex.c
parent7f8a212577aa9bc71a1828635b426c3f2157c3b6 (diff)
downloadgcc-1444f2ed7cfaf30f6e50da21f9a74e164f1fad84.zip
gcc-1444f2ed7cfaf30f6e50da21f9a74e164f1fad84.tar.gz
gcc-1444f2ed7cfaf30f6e50da21f9a74e164f1fad84.tar.bz2
cpphash.h (struct cpp_reader): New members line, pseudo_newlines.
* cpphash.h (struct cpp_reader): New members line, pseudo_newlines. * cpplex.c (handle_newline): Update prototype. Maintain logical line number. (skip_escaped_newlines, skip_block_comment, parse_string): Update accordingly. (_cpp_lex_token): Update, and store token position within the token. * cpplib.h (struct cpp_token): Add line and column entries. * cppmacro.c (replace_args): Position stringified tokens correctly. From-SVN: r44533
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 5248a42..5970442 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -80,7 +80,7 @@ const struct token_spelling token_spellings [N_TTYPES] = {TTYPE_TABLE };
#define TOKEN_SPELL(token) (token_spellings[(token)->type].category)
#define TOKEN_NAME(token) (token_spellings[(token)->type].name)
-static cppchar_t handle_newline PARAMS ((cpp_buffer *, cppchar_t));
+static cppchar_t handle_newline PARAMS ((cpp_reader *, cppchar_t));
static cppchar_t skip_escaped_newlines PARAMS ((cpp_buffer *, cppchar_t));
static cppchar_t get_effective_char PARAMS ((cpp_buffer *));
@@ -124,12 +124,17 @@ cpp_ideq (token, string)
/* Call when meeting a newline. Returns the character after the newline
(or carriage-return newline combination), or EOF. */
static cppchar_t
-handle_newline (buffer, newline_char)
- cpp_buffer *buffer;
+handle_newline (pfile, newline_char)
+ cpp_reader *pfile;
cppchar_t newline_char;
{
+ cpp_buffer *buffer;
cppchar_t next = EOF;
+ pfile->line++;
+ pfile->pseudo_newlines++;
+
+ buffer = pfile->buffer;
buffer->col_adjust = 0;
buffer->lineno++;
buffer->line_base = buffer->cur;
@@ -264,7 +269,7 @@ skip_escaped_newlines (buffer, next)
cpp_warning (buffer->pfile,
"backslash and newline separated by space");
- next = handle_newline (buffer, next1);
+ next = handle_newline (buffer->pfile, next1);
if (next == EOF)
cpp_pedwarn (buffer->pfile, "backslash-newline at end of file");
}
@@ -348,7 +353,7 @@ skip_block_comment (pfile)
}
else if (is_vspace (c))
{
- prevc = c, c = handle_newline (buffer, c);
+ prevc = c, c = handle_newline (pfile, c);
goto next_char;
}
else if (c == '\t')
@@ -706,7 +711,7 @@ parse_string (pfile, token, terminator)
if (pfile->mlstring_pos.line == 0)
pfile->mlstring_pos = pfile->lexer_pos;
- c = handle_newline (buffer, c);
+ c = handle_newline (pfile, c);
*dest++ = '\n';
goto have_char;
}
@@ -866,6 +871,7 @@ _cpp_lex_token (pfile, result)
buffer->saved_flags = 0;
next_char:
pfile->lexer_pos.line = buffer->lineno;
+ result->line = pfile->line;
next_char2:
pfile->lexer_pos.col = CPP_BUF_COLUMN (buffer, buffer->cur);
@@ -875,6 +881,7 @@ _cpp_lex_token (pfile, result)
c = *buffer->cur++;
pfile->lexer_pos.col++;
}
+ result->col = pfile->lexer_pos.col;
do_switch:
buffer->read_ahead = EOF;
@@ -901,7 +908,9 @@ _cpp_lex_token (pfile, result)
case '\n': case '\r':
if (!pfile->state.in_directive)
{
- handle_newline (buffer, c);
+ handle_newline (pfile, c);
+ if (!pfile->state.parsing_args)
+ pfile->pseudo_newlines = 0;
bol = 1;
pfile->lexer_pos.output_line = buffer->lineno;
/* This is a new line, so clear any white space flag.