This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcc/cpplex.c


This cleans up the _cpp_skip_block_comment function so it's more optimized 
and easier to read/understand.
--- /test/src/cvs/gcc/gcc/cpplex.c	Thu Oct  2 03:49:44 2003
+++ /home/joseph/gcc/cpplex.c	Thu Oct  2 03:51:01 2003
@@ -270,40 +270,46 @@
 
   buffer->cur++;
   if (*buffer->cur == '/')
     buffer->cur++;
 
-  for (;;)
+  do
     {
-      c = *buffer->cur++;
-
       /* People like decorating comments with '*', so check for '/'
-	 instead for efficiency.  */
-      if (c == '/')
-	{
-	  if (buffer->cur[-2] == '*')
-	    break;
-
-	  /* Warn about potential nested comments, but not if the '/'
-	     comes immediately before the true comment delimiter.
-	     Don't bother to get it right across escaped newlines.  */
-	  if (CPP_OPTION (pfile, warn_comments)
-	      && buffer->cur[0] == '*' && buffer->cur[1] != '/')
-	    cpp_error_with_line (pfile, DL_WARNING,
-				 pfile->line, CPP_BUF_COL (buffer),
-				 "\"/*\" within comment");
-	}
-      else if (c == '\n')
-	{
-	  buffer->cur--;
-	  _cpp_process_line_notes (pfile, true);
-	  if (buffer->next_line >= buffer->rlimit)
-	    return true;
-	  _cpp_clean_line (pfile);
-	  pfile->line++;
-	}
-    }
+         instead for efficiency.  */
+      while (c != '/')
+        {
+          c = *buffer->cur++;
+
+          if (c == '\n')
+            {
+              buffer->cur--;
+              _cpp_process_line_notes (pfile, true);
+              if (buffer->next_line >= buffer->rlimit)
+                {
+                  return true;
+                }
+	      _cpp_clean_line (pfile);
+	      pfile->line++;
+	    }
+        }
+
+      /* Warn about potential nested comments, but not if the '/'
+         comes immediately before the true comment delimiter.
+         Don't bother to get it right across escaped newlines.  */
+      if (CPP_OPTION (pfile, warn_comments)
+          && buffer->cur[0] == '*'
+          && buffer->cur[1] != '/')
+        {
+          cpp_error_with_line (pfile,
+                               DL_WARNING,
+                               pfile->line,
+                               CPP_BUF_COL (buffer),
+                               "\"/*\" within comment");
+        }
+
+    } while (buffer->cur[-2] != '*');
 
   _cpp_process_line_notes (pfile, true);
   return false;
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]