Module Name:    src
Committed By:   rillig
Date:           Mon May 15 17:28:14 UTC 2023

Modified Files:
        src/tests/usr.bin/indent: lex_ident.c
        src/usr.bin/indent: lexi.c

Log Message:
indent: remove backslash line continuation outside preprocessing

The indenter did not handle these backslashes well, interpreting them as
unary operators, and they are an edge case anyway.  Line continuations
in string literals and character constants are kept.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/lex_ident.c
cvs rdiff -u -r1.189 -r1.190 src/usr.bin/indent/lexi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/lex_ident.c
diff -u src/tests/usr.bin/indent/lex_ident.c:1.5 src/tests/usr.bin/indent/lex_ident.c:1.6
--- src/tests/usr.bin/indent/lex_ident.c:1.5	Sun Apr 24 09:04:12 2022
+++ src/tests/usr.bin/indent/lex_ident.c	Mon May 15 17:28:14 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lex_ident.c,v 1.5 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: lex_ident.c,v 1.6 2023/05/15 17:28:14 rillig Exp $ */
 
 /*
  * Test lexing of word-like tokens, such as keywords, identifiers, numeric
@@ -43,9 +43,7 @@ struct long_tag_name_to_overflow_the_tok
 //indent end
 
 //indent run
-/* $ XXX: The indentation of the backslash is one short of a tab. */
-int	       \
-		variable;
+int		variable;
 
 int
 		no_backslash;

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.189 src/usr.bin/indent/lexi.c:1.190
--- src/usr.bin/indent/lexi.c:1.189	Mon May 15 13:37:16 2023
+++ src/usr.bin/indent/lexi.c	Mon May 15 17:28:14 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.189 2023/05/15 13:37:16 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.190 2023/05/15 17:28:14 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.189 2023/05/15 13:37:16 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.190 2023/05/15 17:28:14 rillig Exp $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -476,9 +476,16 @@ lexi(void)
     ps.curr_col_1 = ps.next_col_1;
     ps.next_col_1 = false;
 
-    while (ch_isblank(inp_peek())) {
-	ps.curr_col_1 = false;
-	inp_skip();
+    for (;;) {
+	if (ch_isblank(inp_peek())) {
+	    ps.curr_col_1 = false;
+	    inp_skip();
+	} else if (inp_peek() == '\\' && inp_lookahead(1) == '\n') {
+	    inp_skip();
+	    inp_skip();
+	    line_no++;
+	} else
+	    break;
     }
 
     lexer_symbol alnum_lsym = lexi_alnum();

Reply via email to