summaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2000-04-10 11:08:12 +0000
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2000-04-10 11:08:12 +0000
commit1db078466a31b5cabd4f59d9b784b0bc1c4692e4 (patch)
treeea7c10d47e64bc4b4b2d6a71203a4f70e05d04fa /gcc/cpplex.c
parent7b8a297dba0c6203c019a0df317040e9e558f650 (diff)
downloadgcc-1db078466a31b5cabd4f59d9b784b0bc1c4692e4.tar.gz
* cpplex.c (skip_block_comment): Use pointer arithmetic rather
than GETC (). * cpphash.h: (CPP_BUMP_BUFFER_LINE_CUR, CPP_BUMP_LINE_CUR): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33052 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index b8a1b071161..0dd6ff7c19a 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -248,33 +248,41 @@ static void
skip_block_comment (pfile)
cpp_reader *pfile;
{
- int c, prev_c = -1;
long line, col;
+ const U_CHAR *limit, *cur;
FORWARD(1);
cpp_buf_line_and_col (CPP_BUFFER (pfile), &line, &col);
- for (;;)
+ limit = CPP_BUFFER (pfile)->rlimit;
+ cur = CPP_BUFFER (pfile)->cur;
+
+ while (cur < limit)
{
- c = GETC ();
- if (c == EOF)
- {
- cpp_error_with_line (pfile, line, col, "unterminated comment");
- return;
- }
- else if (c == '\n' || c == '\r')
+ char c = *cur++;
+ if (c == '\n' || c == '\r')
{
/* \r cannot be a macro escape marker here. */
if (!ACTIVE_MARK_P (pfile))
- CPP_BUMP_LINE (pfile);
+ CPP_BUMP_LINE_CUR (pfile, cur);
}
- else if (c == '/' && prev_c == '*')
- return;
- else if (c == '*' && prev_c == '/'
- && CPP_OPTION (pfile, warn_comments))
- cpp_warning (pfile, "`/*' within comment");
+ else if (c == '*')
+ {
+ /* Check for teminator. */
+ if (cur < limit && *cur == '/')
+ goto out;
- prev_c = c;
+ /* Warn about comment starter embedded in comment. */
+ if (cur[-2] == '/' && CPP_OPTION (pfile, warn_comments))
+ cpp_warning_with_line (pfile, CPP_BUFFER (pfile)->lineno,
+ cur - CPP_BUFFER (pfile)->line_base,
+ "'/*' within comment");
+ }
}
+
+ cpp_error_with_line (pfile, line, col, "unterminated comment");
+ cur--;
+ out:
+ CPP_BUFFER (pfile)->cur = cur + 1;
}
/* Skip a C++/Chill line comment. We know it's a comment, and point