cpplib: backslash-newline

Neil Booth NeilB@earthling.net
Sun Aug 27 06:34:00 GMT 2000


It has been requested by Zack and Per that a backslash and newline
separated by whitespace still be treated as a backslash-newline.  This
does that, and keeps the warning.  At the moment, a comment falls into
the definition of "whitespace" here, but let's leave it be for the
moment.  That'll be simpler to fix with the lexer rewrite I hope to
start soon.

Neil.

	* cpplex.c (lex_line): Treat a whitespace-separated backslash-
	newline as a backslash-newline.

Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplex.c,v
retrieving revision 1.91
diff -u -p -p -r1.91 cpplex.c
--- cpplex.c	2000/08/25 07:04:59	1.91
+++ cpplex.c	2000/08/27 13:30:46
@@ -1516,37 +1516,36 @@ lex_line (pfile, list)
 	  handle_newline (cur, buffer->rlimit, c);
 	  if (PREV_TOKEN_TYPE == CPP_BACKSLASH)
 	    {
-	      if (IMMED_TOKEN ())
-		{
-		  /* Remove the escaped newline.  Then continue to process
-		     any interrupted name or number.  */
-		  cur_token--;
-		  /* Backslash-newline may not be immediately followed by
-		     EOF (C99 5.1.1.2).  */
-		  if (cur >= buffer->rlimit)
-		    {
-		      cpp_pedwarn (pfile, "backslash-newline at end of file");
-		      break;
-		    }
-		  if (IMMED_TOKEN ())
-		    {
-		      cur_token--;
-		      if (cur_token->type == CPP_NAME)
-			goto continue_name;
-		      else if (cur_token->type == CPP_NUMBER)
-			goto continue_number;
-		      cur_token++;
-		    }
-		  /* Remember whitespace setting.  */
-		  flags = cur_token->flags;
-		  break;
-		}
-	      else
+	      /* Warn if the newline is not immediate, but treat it as
+		 a genuine backslash-newline sequence regardless.  */
+	      if (!IMMED_TOKEN ())
 		{
 		  buffer->cur = cur;
 		  cpp_warning (pfile,
 			       "backslash and newline separated by space");
 		}
+	      /* Remove the escaped newline.  Then continue to process
+		 any interrupted name or number.  */
+	      cur_token--;
+	      /* Backslash-newline may not be immediately followed by
+		 EOF (C99 5.1.1.2).  */
+	      if (cur >= buffer->rlimit)
+		{
+		  cpp_pedwarn (pfile, "backslash-newline at end of file");
+		  break;
+		}
+	      if (IMMED_TOKEN ())
+		{
+		  cur_token--;
+		  if (cur_token->type == CPP_NAME)
+		    goto continue_name;
+		  else if (cur_token->type == CPP_NUMBER)
+		    goto continue_number;
+		  cur_token++;
+		}
+	      /* Remember whitespace setting.  */
+	      flags = cur_token->flags;
+	      break;
 	    }
 	  else if (MIGHT_BE_DIRECTIVE ())
 	    {


More information about the Gcc-patches mailing list