]> gcc.gnu.org Git - gcc.git/commitdiff
cpplex.c (skip_block_comment): Use pointer arithmetic rather than GETC ().
authorNeil Booth <neilb@earthling.net>
Mon, 10 Apr 2000 11:08:12 +0000 (11:08 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Mon, 10 Apr 2000 11:08:12 +0000 (11:08 +0000)
* cpplex.c (skip_block_comment): Use pointer arithmetic rather
than GETC ().
* cpphash.h: (CPP_BUMP_BUFFER_LINE_CUR, CPP_BUMP_LINE_CUR): New.

From-SVN: r33052

gcc/ChangeLog
gcc/cpphash.h
gcc/cpplex.c

index 39c6402588bfea75b770eadfff26b2f81165a4b5..be455f9777bfb10c150505a65cf325d0d75e490c 100644 (file)
@@ -1,3 +1,9 @@
+2000-04-10  Neil Booth  <NeilB@earthling.net>
+
+       * cpplex.c (skip_block_comment): Use pointer arithmetic rather
+       than GETC ().
+       * cpphash.h: (CPP_BUMP_BUFFER_LINE_CUR, CPP_BUMP_LINE_CUR): New.
+
 2000-04-10  Martin v. Löwis  <loewis@informatik.hu-berlin.de>
 
        * invoke.texi (-fno-gnu-keywords): Remove classof, headof,
@@ -23561,3 +23567,5 @@ Wed May 19 00:34:40 1999  Jeffrey A Law  (law@cygnus.com)
        gcc-2.95 branch.
 
 See ChangeLog.1 for earlier changes.
+
+       
\ No newline at end of file
index 35d48e85d90f3e2c6a925c2fe1ba7ac8f9083b2b..fb4d913cb274758e8dc4c1bc7c1f3b784e2862db 100644 (file)
@@ -221,6 +221,10 @@ extern unsigned char _cpp_IStable[256];
 #define CPP_BUMP_BUFFER_LINE(PBUF) ((PBUF)->lineno++,\
                                    (PBUF)->line_base = (PBUF)->cur)
 #define CPP_BUMP_LINE(PFILE) CPP_BUMP_BUFFER_LINE(CPP_BUFFER(PFILE))
+#define CPP_BUMP_BUFFER_LINE_CUR(PBUF, CUR) ((PBUF)->lineno++,\
+                                            (PBUF)->line_base = CUR)
+#define CPP_BUMP_LINE_CUR(PFILE, CUR) \
+                            CPP_BUMP_BUFFER_LINE_CUR(CPP_BUFFER(PFILE), CUR)
 #define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->prev)
 
 /* Are we in column 1 right now?  Used mainly for -traditional handling
index b8a1b0711619b50c76e48213f8a287111dfd626f..0dd6ff7c19a943ac1bb8f6c95a3eb37d9c654977 100644 (file)
@@ -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
This page took 0.108982 seconds and 5 git commands to generate.