This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
cpplib: Fix trad/maccom*
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 28 Jun 2003 16:16:49 +0100
- Subject: cpplib: Fix trad/maccom*
* cpptrad.c (skip_macro_block_comment): New.
(copy_comment): Use it if appropriate.
Index: cpptrad.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpptrad.c,v
retrieving revision 1.32
diff -u -p -r1.32 cpptrad.c
--- cpptrad.c 17 Jun 2003 06:17:44 -0000 1.32
+++ cpptrad.c 28 Jun 2003 15:13:55 -0000
@@ -116,6 +116,25 @@ check_output_buffer (cpp_reader *pfile,
}
}
+/* Skip a C-style block comment in a macro as a result of -CC.
+ Buffer->cur points to the initial asterisk of the comment. */
+static void
+skip_macro_block_comment (cpp_reader *pfile)
+{
+ const uchar *cur = pfile->buffer->cur;
+
+ cur++;
+ if (*cur == '/')
+ cur++;
+
+ /* People like decorating comments with '*', so check for '/'
+ instead for efficiency. */
+ while(! (*cur++ == '/' && cur[-2] == '*') )
+ ;
+
+ pfile->buffer->cur = cur;
+}
+
/* CUR points to the asterisk introducing a comment in the current
context. IN_DEFINE is true if we are in the replacement text of a
macro.
@@ -136,7 +155,11 @@ copy_comment (cpp_reader *pfile, const u
cpp_buffer *buffer = pfile->buffer;
buffer->cur = cur;
- unterminated = _cpp_skip_block_comment (pfile);
+ if (pfile->context->prev)
+ unterminated = false, skip_macro_block_comment (pfile);
+ else
+ unterminated = _cpp_skip_block_comment (pfile);
+
if (unterminated)
cpp_error_with_line (pfile, DL_ERROR, from_line, 0,
"unterminated comment");