CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 21:36:38 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c indent.c indent.h io.c

Log Message:
indent: rename misleading variable

The name started with 'line_start', but the value is not always the
value from the beginning of the line.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.356 -r1.357 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.187 -r1.188 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.216 -r1.217 src/usr.bin/indent/io.c

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



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 21:36:38 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c indent.c indent.h io.c

Log Message:
indent: rename misleading variable

The name started with 'line_start', but the value is not always the
value from the beginning of the line.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.356 -r1.357 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.187 -r1.188 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.216 -r1.217 src/usr.bin/indent/io.c

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

Modified files:

Index: src/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.52 src/usr.bin/indent/debug.c:1.53
--- src/usr.bin/indent/debug.c:1.52	Sat Jun 10 20:37:12 2023
+++ src/usr.bin/indent/debug.c	Sat Jun 10 21:36:38 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.52 2023/06/10 20:37:12 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.52 2023/06/10 20:37:12 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $");
 
 #include 
 #include 
@@ -360,7 +360,7 @@ debug_parser_state(void)
 	state.heading = "spacing inside a statement or declaration";
 	debug_ps_bool(next_unary);
 	debug_ps_bool(want_blank);
-	debug_ps_int(line_start_nparen);
+	debug_ps_int(ind_paren_level);
 	debug_ps_int(nparen);
 	debug_ps_paren();
 

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.356 src/usr.bin/indent/indent.c:1.357
--- src/usr.bin/indent/indent.c:1.356	Sat Jun 10 20:37:12 2023
+++ src/usr.bin/indent/indent.c	Sat Jun 10 21:36:38 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.356 2023/06/10 20:37:12 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.357 2023/06/10 21:36:38 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.356 2023/06/10 20:37:12 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.357 2023/06/10 21:36:38 rillig Exp $");
 
 #include 
 #include 
@@ -378,7 +378,7 @@ is_function_pointer_declaration(void)
 	&& !ps.in_init
 	&& !ps.decl_indent_done
 	&& !ps.line_has_func_def
-	&& ps.line_start_nparen == 0;
+	&& ps.ind_paren_level == 0;
 }
 
 static int
@@ -580,7 +580,7 @@ process_rparen(void)
 		ps.want_blank = true;
 
 	if (code.len == 0)
-		ps.line_start_nparen = ps.nparen;
+		ps.ind_paren_level = ps.nparen;
 
 unbalanced:
 	buf_add_char(&code, token.s[0]);
@@ -631,7 +631,7 @@ process_rbracket(void)
 
 	ps.want_blank = true;
 	if (code.len == 0)
-		ps.line_start_nparen = ps.nparen;
+		ps.ind_paren_level = ps.nparen;
 
 unbalanced:
 	buf_add_char(&code, token.s[0]);
@@ -788,7 +788,7 @@ process_comma(void)
 	 * does not start the line */
 
 	if (ps.in_decl && !ps.line_has_func_def && !ps.in_init &&
-	!ps.decl_indent_done && ps.line_start_nparen == 0) {
+	!ps.decl_indent_done && ps.ind_paren_level == 0) {
 		/* indent leading commas and not the actual identifiers */
 		indent_declarator(ps.decl_ind - 1, ps.tabs_to_var);
 	}
@@ -844,7 +844,7 @@ process_semicolon(void)
 	ps.declaration = ps.declaration == decl_begin ? decl_end : decl_no;
 
 	if (ps.in_decl && code.len == 0 && !ps.in_init &&
-	!ps.decl_indent_done && ps.line_start_nparen == 0) {
+	!ps.decl_indent_done && ps.ind_paren_level == 0) {
 		/* indent stray semicolons in declarations */
 		indent_declarator(ps.decl_ind - 1, ps.tabs_to_var);
 	}
@@ -915,7 +915,7 @@ process_word(lexer_symbol lsym)
 			ps.want_blank = false;
 
 		} else if (!ps.in_init && !ps.decl_indent_done &&
-		ps.line_start_nparen == 0) {
+		ps.ind_paren_level == 0) {
 			if (opt.decl_indent == 0
 			&& code.len > 0 && code.s[code.len - 1] == '}')
 ps.decl_ind = ind_add(0, code.s, code.len) + 1;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.187 src/usr.bin/indent/indent.h:1.188
--- src/usr.bin/indent/indent.h:1.187	Sat Jun 10 16:43:56 2023
+++ src/usr.bin/indent/indent.h	Sat Jun 10 21:36:38 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.187 2023/06/10 16:43:56 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.188 2023/06/10 21:36:38 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -368,10 +368,9 @@ extern struct parser_state {
 	bool want_blank;	/* whether the following token should be
  * prefixed by a blank. (Said prefixing is
  * ignored in some cases.) */
-	int line_start_nparen;	/* the number of parentheses or brackets that
- * were open at the beginning of the current
- * line; used to indent within statements,
- * initializers and declarations */
+	int ind_paren_level;	/* the number of parentheses or brackets that
+ * is used for indenting a continuation line of
+ * a

CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 20:37:13 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c indent.c

Log Message:
indent: fix debug output

When the parser state was first printed, there were unintended diff
markers.  Treat the previous lexer symbol like the other parts of the
parser state, as omitting it from the diff output is confusing.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.355 -r1.356 src/usr.bin/indent/indent.c

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



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 20:37:13 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c indent.c

Log Message:
indent: fix debug output

When the parser state was first printed, there were unintended diff
markers.  Treat the previous lexer symbol like the other parts of the
parser state, as omitting it from the diff output is confusing.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.355 -r1.356 src/usr.bin/indent/indent.c

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

Modified files:

Index: src/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.51 src/usr.bin/indent/debug.c:1.52
--- src/usr.bin/indent/debug.c:1.51	Sat Jun 10 18:46:42 2023
+++ src/usr.bin/indent/debug.c	Sat Jun 10 20:37:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.51 2023/06/10 18:46:42 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.52 2023/06/10 20:37:12 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.51 2023/06/10 18:46:42 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.52 2023/06/10 20:37:12 rillig Exp $");
 
 #include 
 #include 
@@ -233,7 +233,7 @@ debug_buffers(void)
 static void
 write_ps_bool(const char *name, bool prev, bool curr)
 {
-	if (curr != prev) {
+	if (!state.ps_first && curr != prev) {
 		char diff = " -+x"[(prev ? 1 : 0) + (curr ? 2 : 0)];
 		debug_println("[%c]  ps.%s", diff, name);
 	} else if (config.full_parser_state || state.ps_first)
@@ -243,7 +243,7 @@ write_ps_bool(const char *name, bool pre
 static void
 write_ps_int(const char *name, int prev, int curr)
 {
-	if (curr != prev)
+	if (!state.ps_first && curr != prev)
 		debug_println(" %3d -> %3d  ps.%s", prev, curr, name);
 	else if (config.full_parser_state || state.ps_first)
 		debug_println("%3d  ps.%s", curr, name);
@@ -252,7 +252,7 @@ write_ps_int(const char *name, int prev,
 static void
 write_ps_enum(const char *name, const char *prev, const char *curr)
 {
-	if (strcmp(prev, curr) != 0)
+	if (!state.ps_first && strcmp(prev, curr) != 0)
 		debug_println(" %3s -> %3s  ps.%s", prev, curr, name);
 	else if (config.full_parser_state || state.ps_first)
 		debug_println(" %10s  ps.%s", curr, name);
@@ -327,10 +327,9 @@ void
 debug_parser_state(void)
 {
 	debug_blank_line();
-	debug_println(" ps.prev_lsym = %s",
-	lsym_name[ps.prev_lsym]);
 
 	state.heading = "token classification";
+	debug_ps_enum(prev_lsym, lsym_name);
 	debug_ps_bool(in_stmt_or_decl);
 	debug_ps_bool(in_decl);
 	debug_ps_bool(in_var_decl);

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.355 src/usr.bin/indent/indent.c:1.356
--- src/usr.bin/indent/indent.c:1.355	Sat Jun 10 18:46:42 2023
+++ src/usr.bin/indent/indent.c	Sat Jun 10 20:37:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.355 2023/06/10 18:46:42 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.356 2023/06/10 20:37:12 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.355 2023/06/10 18:46:42 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.356 2023/06/10 20:37:12 rillig Exp $");
 
 #include 
 #include 
@@ -1060,12 +1060,12 @@ indent(void)
 
 		process_lsym(lsym);
 
-		debug_parser_state();
-
 		if (lsym != lsym_preprocessing
 		&& lsym != lsym_newline
 		&& lsym != lsym_comment)
 			ps.prev_lsym = lsym;
+
+		debug_parser_state();
 	}
 }
 



CVS commit: src

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 18:46:42 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_if.c
src/usr.bin/indent: debug.c indent.c

Log Message:
indent: fix line break between semicolon and brace


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/lsym_if.c
cvs rdiff -u -r1.50 -r1.51 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.354 -r1.355 src/usr.bin/indent/indent.c

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



CVS commit: src

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 18:46:42 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_if.c
src/usr.bin/indent: debug.c indent.c

Log Message:
indent: fix line break between semicolon and brace


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/lsym_if.c
cvs rdiff -u -r1.50 -r1.51 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.354 -r1.355 src/usr.bin/indent/indent.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/lsym_if.c
diff -u src/tests/usr.bin/indent/lsym_if.c:1.5 src/tests/usr.bin/indent/lsym_if.c:1.6
--- src/tests/usr.bin/indent/lsym_if.c:1.5	Sat Jun 10 16:43:56 2023
+++ src/tests/usr.bin/indent/lsym_if.c	Sat Jun 10 18:46:42 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_if.c,v 1.5 2023/06/10 16:43:56 rillig Exp $ */
+/* $NetBSD: lsym_if.c,v 1.6 2023/06/10 18:46:42 rillig Exp $ */
 
 /*
  * Tests for the token lsym_if, which represents the keyword 'if' that starts
@@ -38,8 +38,8 @@ function(void)
 	if (0)
 		if (1)
 			if (2)
-// $ FIXME: The '{' must be on a separate line, with indentation 8.
-stmt(); {
-}
+stmt();
+	{
+	}
 }
 //indent end

Index: src/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.50 src/usr.bin/indent/debug.c:1.51
--- src/usr.bin/indent/debug.c:1.50	Sat Jun 10 16:43:55 2023
+++ src/usr.bin/indent/debug.c	Sat Jun 10 18:46:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.50 2023/06/10 16:43:55 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.51 2023/06/10 18:46:42 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.50 2023/06/10 16:43:55 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.51 2023/06/10 18:46:42 rillig Exp $");
 
 #include 
 #include 
@@ -395,6 +395,6 @@ debug_psyms_stack(const char *situation)
 	for (int i = 0; i <= psyms->top; ++i)
 		debug_printf(" %d %s",
 		psyms->ind_level[i], psym_name[psyms->sym[i]]);
-	debug_blank_line();
+	debug_println("");
 }
 #endif

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.354 src/usr.bin/indent/indent.c:1.355
--- src/usr.bin/indent/indent.c:1.354	Sat Jun 10 16:43:55 2023
+++ src/usr.bin/indent/indent.c	Sat Jun 10 18:46:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.354 2023/06/10 16:43:55 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.355 2023/06/10 18:46:42 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.354 2023/06/10 16:43:55 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.355 2023/06/10 18:46:42 rillig Exp $");
 
 #include 
 #include 
@@ -314,19 +314,16 @@ set_initial_indentation(void)
 	ps.ind_level = ps.ind_level_follow = ind / opt.indent_size;
 }
 
-static void
-maybe_break_line(lexer_symbol lsym)
+static bool
+should_break_line(lexer_symbol lsym)
 {
-	if (!ps.force_nl)
-		return;
 	if (lsym == lsym_semicolon)
-		return;
-	if (lsym == lsym_lbrace && opt.brace_same_line
-	&& ps.prev_lsym != lsym_lbrace)
-		return;
-
-	output_line();
-	ps.force_nl = false;
+		return false;
+	if (ps.prev_lsym == lsym_lbrace || ps.prev_lsym == lsym_semicolon)
+		return true;
+	if (lsym == lsym_lbrace && opt.brace_same_line)
+		return false;
+	return true;
 }
 
 static void
@@ -1051,7 +1048,10 @@ indent(void)
 		else if (lsym == lsym_comment) {
 			/* no special processing */
 		} else {
-			maybe_break_line(lsym);
+			if (ps.force_nl && should_break_line(lsym)) {
+ps.force_nl = false;
+output_line();
+			}
 			ps.in_stmt_or_decl = true;
 			if (com.len > 0)
 move_com_to_code(lsym);



CVS commit: src/tests/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 17:56:29 UTC 2023

Modified Files:
src/tests/usr.bin/indent: fmt_decl.c psym_if_expr.c

Log Message:
tests/indent: add move coverage tests


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/psym_if_expr.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/fmt_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.53 src/tests/usr.bin/indent/fmt_decl.c:1.54
--- src/tests/usr.bin/indent/fmt_decl.c:1.53	Sat Jun 10 06:38:21 2023
+++ src/tests/usr.bin/indent/fmt_decl.c	Sat Jun 10 17:56:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmt_decl.c,v 1.53 2023/06/10 06:38:21 rillig Exp $	*/
+/*	$NetBSD: fmt_decl.c,v 1.54 2023/06/10 17:56:29 rillig Exp $	*/
 
 /*
  * Tests for declarations of global variables, external functions, and local
@@ -1069,3 +1069,19 @@ b[] = {1, 2};
 	b[] = {1, 2};
 }
 //indent end
+
+
+/*
+ * When a type occurs at the top level, it forces a line break before.
+ */
+//indent input
+__attribute__((__dead__)) void die(void) {}
+//indent end
+
+//indent run
+__attribute__((__dead__))
+void
+die(void)
+{
+}
+//indent end

Index: src/tests/usr.bin/indent/psym_if_expr.c
diff -u src/tests/usr.bin/indent/psym_if_expr.c:1.4 src/tests/usr.bin/indent/psym_if_expr.c:1.5
--- src/tests/usr.bin/indent/psym_if_expr.c:1.4	Sun Apr 24 09:04:12 2022
+++ src/tests/usr.bin/indent/psym_if_expr.c	Sat Jun 10 17:56:29 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: psym_if_expr.c,v 1.4 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: psym_if_expr.c,v 1.5 2023/06/10 17:56:29 rillig Exp $ */
 
 /*
  * Tests for the parser symbol psym_if_expr, representing the parser state
@@ -20,3 +20,27 @@ function(void)
 		stmt();
 }
 //indent end
+
+
+/*
+ * Indent is forgiving about syntax errors such as an 'if' statement in which
+ * the condition is not parenthesized.
+ */
+//indent input
+{
+	if cond {
+	}
+	if cond && cond {
+	}
+}
+//indent end
+
+//indent run
+{
+	if cond {
+	}
+	if cond
+		&& cond {
+		}
+}
+//indent end



CVS commit: src/tests/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 17:56:29 UTC 2023

Modified Files:
src/tests/usr.bin/indent: fmt_decl.c psym_if_expr.c

Log Message:
tests/indent: add move coverage tests


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/psym_if_expr.c

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



CVS commit: src

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 17:35:41 UTC 2023

Modified Files:
src/tests/usr.bin/indent: opt_cli.c psym_else.c t_errors.sh
src/usr.bin/indent: parse.c

Log Message:
indent: fix stack overflow, add more tests

For several parser symbols, 2 symbols are pushed in a row, which led to
an out-of-bounds write.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/opt_cli.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/psym_else.c
cvs rdiff -u -r1.34 -r1.35 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.71 -r1.72 src/usr.bin/indent/parse.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/opt_cli.c
diff -u src/tests/usr.bin/indent/opt_cli.c:1.6 src/tests/usr.bin/indent/opt_cli.c:1.7
--- src/tests/usr.bin/indent/opt_cli.c:1.6	Tue Jun  6 04:37:27 2023
+++ src/tests/usr.bin/indent/opt_cli.c	Sat Jun 10 17:35:41 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_cli.c,v 1.6 2023/06/06 04:37:27 rillig Exp $ */
+/* $NetBSD: opt_cli.c,v 1.7 2023/06/10 17:35:41 rillig Exp $ */
 
 /*
  * Tests for the option '-cli' ("case label indentation"), which sets the
@@ -97,3 +97,54 @@ classify(int n)
 	}
 }
 //indent end
+
+
+/*
+ * Test the combination of left-aligned braces and a deep case indentation.
+ *
+ * When the 'case' labels are that deeply indented, the distance between the
+ * braces and the 'case' is between 1 and 2 indentation levels.
+ */
+//indent input
+{
+switch (expr)
+{
+case 1:
+}
+}
+//indent end
+
+//indent run -br -cli3.25
+{
+	switch (expr) {
+  case 1:
+	}
+}
+//indent end
+
+//indent run -bl -cli3.25
+{
+	switch (expr)
+			{
+  case 1:
+			}
+}
+//indent end
+
+//indent run -bl -cli2.75
+{
+	switch (expr)
+		{
+			  case 1:
+		}
+}
+//indent end
+
+//indent run -bl -cli1.25
+{
+	switch (expr)
+	{
+		  case 1:
+	}
+}
+//indent end

Index: src/tests/usr.bin/indent/psym_else.c
diff -u src/tests/usr.bin/indent/psym_else.c:1.4 src/tests/usr.bin/indent/psym_else.c:1.5
--- src/tests/usr.bin/indent/psym_else.c:1.4	Sun Apr 24 10:36:37 2022
+++ src/tests/usr.bin/indent/psym_else.c	Sat Jun 10 17:35:41 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: psym_else.c,v 1.4 2022/04/24 10:36:37 rillig Exp $ */
+/* $NetBSD: psym_else.c,v 1.5 2023/06/10 17:35:41 rillig Exp $ */
 
 /*
  * Tests for the parser symbol psym_else, which represents the keyword 'else'
@@ -71,3 +71,18 @@ function(void)
 		(var = 3);
 }
 //indent end
+
+
+//indent input
+{
+	else
+}
+//indent end
+
+//indent run
+error: Standard Input:2: Unmatched 'else'
+{
+	else
+}
+exit 1
+//indent end

Index: src/tests/usr.bin/indent/t_errors.sh
diff -u src/tests/usr.bin/indent/t_errors.sh:1.34 src/tests/usr.bin/indent/t_errors.sh:1.35
--- src/tests/usr.bin/indent/t_errors.sh:1.34	Fri Jun  9 11:22:31 2023
+++ src/tests/usr.bin/indent/t_errors.sh	Sat Jun 10 17:35:41 2023
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_errors.sh,v 1.34 2023/06/09 11:22:31 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.35 2023/06/10 17:35:41 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -485,6 +485,32 @@ EOF
 	"$indent" -l34 code.c -st
 }
 
+atf_test_case 'stack_overflow'
+stack_overflow_body()
+{
+	cat <<-EOF > code.c
+		{{ {{ {{ {{ {{
+		{{ {{ {{ {{ {{
+		{{ {{ {{{
+	EOF
+
+	atf_check \
+	-s 'exit:1' \
+	-e 'inline:error: code.c:3: Stuff missing from end of file\n' \
+	"$indent" code.c
+
+	cat <<-EOF > code.c
+		{{ {{ {{ {{ {{
+		{{ {{ {{ {{ {{
+		{{ {{ {{{ {
+	EOF
+
+	atf_check \
+	-s 'exit:1' \
+	-e 'inline:indent: Parser stack overflow\n' \
+	"$indent" code.c
+}
+
 
 atf_init_test_cases()
 {
@@ -524,4 +550,5 @@ atf_init_test_cases()
 	atf_add_test_case 'gcc_statement_expression'
 	atf_add_test_case 'crash_comment_after_controlling_expression'
 	atf_add_test_case 'comment_fits_in_one_line'
+	atf_add_test_case 'stack_overflow'
 }

Index: src/usr.bin/indent/parse.c
diff -u src/usr.bin/indent/parse.c:1.71 src/usr.bin/indent/parse.c:1.72
--- src/usr.bin/indent/parse.c:1.71	Sat Jun 10 16:43:56 2023
+++ src/usr.bin/indent/parse.c	Sat Jun 10 17:35:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.71 2023/06/10 16:43:56 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.72 2023/06/10 17:35:40 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: parse.c,v 1.71 2023/06/10 16:43:56 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.72 2023/06/10 17:35:40 rillig Exp $");
 
 #include 
 
@@ -101,17 +101,13 @@ decl_level(void)
 }
 
 static void
-ps_push(parser_symbol psym)
-{
-	ps.psyms.sym[++ps.psyms.top] = psym;
-	ps.psyms.ind_level[ps.psyms.top] = ps.ind_level;
-}
-
-static void
-ps_push_f

CVS commit: src

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 17:35:41 UTC 2023

Modified Files:
src/tests/usr.bin/indent: opt_cli.c psym_else.c t_errors.sh
src/usr.bin/indent: parse.c

Log Message:
indent: fix stack overflow, add more tests

For several parser symbols, 2 symbols are pushed in a row, which led to
an out-of-bounds write.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/opt_cli.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/psym_else.c
cvs rdiff -u -r1.34 -r1.35 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.71 -r1.72 src/usr.bin/indent/parse.c

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



CVS commit: src/sys/arch/next68k/dev

2023-06-10 Thread Darrin B. Jewell
Module Name:src
Committed By:   dbj
Date:   Sat Jun 10 17:14:57 UTC 2023

Modified Files:
src/sys/arch/next68k/dev: mb8795reg.h

Log Message:
gratuitous commit to fix spelling error


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/next68k/dev/mb8795reg.h

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

Modified files:

Index: src/sys/arch/next68k/dev/mb8795reg.h
diff -u src/sys/arch/next68k/dev/mb8795reg.h:1.4 src/sys/arch/next68k/dev/mb8795reg.h:1.5
--- src/sys/arch/next68k/dev/mb8795reg.h:1.4	Sat Apr 24 19:58:13 2010
+++ src/sys/arch/next68k/dev/mb8795reg.h	Sat Jun 10 17:14:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: mb8795reg.h,v 1.4 2010/04/24 19:58:13 dbj Exp $	*/
+/*	$NetBSD: mb8795reg.h,v 1.5 2023/06/10 17:14:57 dbj Exp $	*/
 /*
  * Copyright (c) 1998 Darrin B. Jewell
  * All rights reserved.
@@ -75,7 +75,7 @@ struct mb8795_regs {
 #define MB8795_TXMASK_BITS \
 "\20\10READYIE\06TXRXIE\04UNDERFLOWIE\03COLLIE\02COLL16IE\01PARERRIE"
 
-/* cummulative receiver status (address 2) */
+/* cumulative receiver status (address 2) */
 #define MB8795_RXSTAT   2
 
 #define MB8795_RXSTAT_OK		0x80	/* packet received is correct */



CVS commit: src/sys/arch/next68k/dev

2023-06-10 Thread Darrin B. Jewell
Module Name:src
Committed By:   dbj
Date:   Sat Jun 10 17:14:57 UTC 2023

Modified Files:
src/sys/arch/next68k/dev: mb8795reg.h

Log Message:
gratuitous commit to fix spelling error


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/next68k/dev/mb8795reg.h

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



Re: CVS commit: src/etc/rc.d

2023-06-10 Thread Martin Husemann
On Sat, Jun 10, 2023 at 04:02:39AM +, Kimmo Suominen wrote:
> Module Name:  src
> Committed By: kim
> Date: Sat Jun 10 04:02:39 UTC 2023
> 
> Modified Files:
>   src/etc/rc.d: sshd
> 
> Log Message:
> Add some backwards compat.  Adjust grammar.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.35 -r1.36 src/etc/rc.d/sshd

I don't like this commit, it mixes:

 - several text improvements (good!)
 - one unrelated cosmetic change (rely on all rc.d scripts being installed
   with x bit, so drop the "sh" from the manual invocation)
 - one unrelated and IMO unneded change (check if kern.entropy.needed
   exists, only usefull for older branches)

Martin


CVS commit: src

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 16:43:56 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_comment.c lsym_if.c lsym_switch.c
src/usr.bin/indent: args.c debug.c indent.c indent.h io.c lexi.c
parse.c pr_comment.c

Log Message:
indent: miscellaneous cleanups


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/tests/usr.bin/indent/lsym_comment.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/lsym_if.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/lsym_switch.c
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/indent/args.c
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.353 -r1.354 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.186 -r1.187 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.215 -r1.216 src/usr.bin/indent/io.c
cvs rdiff -u -r1.224 -r1.225 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/indent/parse.c
cvs rdiff -u -r1.160 -r1.161 src/usr.bin/indent/pr_comment.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/lsym_comment.c
diff -u src/tests/usr.bin/indent/lsym_comment.c:1.19 src/tests/usr.bin/indent/lsym_comment.c:1.20
--- src/tests/usr.bin/indent/lsym_comment.c:1.19	Sat Jun 10 06:38:21 2023
+++ src/tests/usr.bin/indent/lsym_comment.c	Sat Jun 10 16:43:56 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_comment.c,v 1.19 2023/06/10 06:38:21 rillig Exp $ */
+/* $NetBSD: lsym_comment.c,v 1.20 2023/06/10 16:43:56 rillig Exp $ */
 
 /*
  * Tests for the token lsym_comment, which starts a comment.
@@ -32,7 +32,7 @@
  * - block/end-of-line comment to the right of code
  * - block/end-of-line comment to the right of label with code
  *
- * - with/without opt.comment_delimiter_on_blankline (-cdb)
+ * - with/without opt.comment_delimiter_on_blank_line (-cdb)
  * - with/without opt.star_comment_cont (-sc)
  * - with/without opt.format_block_comments (-fbc)
  * - with varying opt.max_line_length (32, 64, 80, 140)
@@ -,3 +,23 @@ a>b;
 	a > b;
 }
 //indent end
+
+
+/*
+ * Line comments are only related to a code snippet if they are on the same
+ * line; they cannot be continued in the next lines.
+ */
+//indent input
+int line;	// comment line 1
+		// comment line 2
+int block;	/* comment line 1
+		 * comment line 2
+		 */
+//indent end
+
+//indent run -di0
+int line;			// comment line 1
+// $ XXX: This comment was probably intended to continue 'comment line 1'.
+// comment line 2
+int block;			/* comment line 1 comment line 2 */
+//indent end

Index: src/tests/usr.bin/indent/lsym_if.c
diff -u src/tests/usr.bin/indent/lsym_if.c:1.4 src/tests/usr.bin/indent/lsym_if.c:1.5
--- src/tests/usr.bin/indent/lsym_if.c:1.4	Sun Apr 24 10:36:37 2022
+++ src/tests/usr.bin/indent/lsym_if.c	Sat Jun 10 16:43:56 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_if.c,v 1.4 2022/04/24 10:36:37 rillig Exp $ */
+/* $NetBSD: lsym_if.c,v 1.5 2023/06/10 16:43:56 rillig Exp $ */
 
 /*
  * Tests for the token lsym_if, which represents the keyword 'if' that starts
@@ -21,3 +21,25 @@ function(void)
 		stmt();
 }
 //indent end
+
+
+/*
+ * After an 'if' statement without an 'else' branch, braces start a separate
+ * block.
+ */
+//indent input
+{
+	if(0)if(1)if(2)stmt();{}
+}
+//indent end
+
+//indent run
+{
+	if (0)
+		if (1)
+			if (2)
+// $ FIXME: The '{' must be on a separate line, with indentation 8.
+stmt(); {
+}
+}
+//indent end

Index: src/tests/usr.bin/indent/lsym_switch.c
diff -u src/tests/usr.bin/indent/lsym_switch.c:1.3 src/tests/usr.bin/indent/lsym_switch.c:1.4
--- src/tests/usr.bin/indent/lsym_switch.c:1.3	Sun Apr 24 09:04:12 2022
+++ src/tests/usr.bin/indent/lsym_switch.c	Sat Jun 10 16:43:56 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_switch.c,v 1.3 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: lsym_switch.c,v 1.4 2023/06/10 16:43:56 rillig Exp $ */
 
 /*
  * Tests for the token lsym_switch, which represents the keyword 'switch' that
@@ -9,8 +9,23 @@
  *	C11 6.8.4.2		"The 'switch' statement"
  */
 
+// TODO: Add systematic tests.
+
+/*
+ * Ensure that an unfinished 'switch' statement does not eat comments.
+ */
 //indent input
-// TODO: add input
+{
+	switch (expr) // comment
+	{
+	}
+}
 //indent end
 
-//indent run-equals-input
+//indent run
+{
+// $ FIXME: The '{' has moved to the comment.
+	switch (expr) // comment {
+	}
+}
+//indent end

Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.82 src/usr.bin/indent/args.c:1.83
--- src/usr.bin/indent/args.c:1.82	Mon Jun  5 10:12:21 2023
+++ src/usr.bin/indent/args.c	Sat Jun 10 16:43:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.82 2023/06/05 10:12:21 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.83 2023/06/10 16:43:55 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: args.c,v 1.82 2023/06/05 10:12:21 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.83 2023/06/10 16:43:55 rillig Ex

CVS commit: src

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 16:43:56 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_comment.c lsym_if.c lsym_switch.c
src/usr.bin/indent: args.c debug.c indent.c indent.h io.c lexi.c
parse.c pr_comment.c

Log Message:
indent: miscellaneous cleanups


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/tests/usr.bin/indent/lsym_comment.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/lsym_if.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/lsym_switch.c
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/indent/args.c
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.353 -r1.354 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.186 -r1.187 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.215 -r1.216 src/usr.bin/indent/io.c
cvs rdiff -u -r1.224 -r1.225 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/indent/parse.c
cvs rdiff -u -r1.160 -r1.161 src/usr.bin/indent/pr_comment.c

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



CVS commit: src

2023-06-10 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jun 10 16:08:41 UTC 2023

Modified Files:
src/distrib/sets: Makefile maketars
src/share/mk: bsd.own.mk

Log Message:
sets: enhance MAKEVERBOSE support

Add more messages for various sets operations.
Add ${_MKMSG_CREATE} to bsd.own.mk.

Enhance maketars to be a bit more verbose even with -q,
to make it more obvious why certain operations may be slow.
May help debugging PR 47562.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/distrib/sets/Makefile
cvs rdiff -u -r1.95 -r1.96 src/distrib/sets/maketars
cvs rdiff -u -r1.1341 -r1.1342 src/share/mk/bsd.own.mk

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

Modified files:

Index: src/distrib/sets/Makefile
diff -u src/distrib/sets/Makefile:1.108 src/distrib/sets/Makefile:1.109
--- src/distrib/sets/Makefile:1.108	Sun Aug 21 07:10:03 2022
+++ src/distrib/sets/Makefile	Sat Jun 10 16:08:41 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.108 2022/08/21 07:10:03 lukem Exp $
+#	$NetBSD: Makefile,v 1.109 2023/06/10 16:08:41 lukem Exp $
 
 # Experimental RCS METALOG versioning
 # (Needs host's rcs(1) commands)
@@ -136,6 +136,7 @@ clean_METALOG: .PHONY
 METALOG.unpriv= -M ${METALOG}.sanitised
 sanitise_METALOG: .PHONY ${METALOG}.sanitised
 ${METALOG}.sanitised: ${METALOG}
+	${_MKMSG_CREATE} METALOG.sanitised
 	<${METALOG} \
 	${${MKUPDATE} != "no" :? ${METALOG_REMOVE_DUPLICATES} | :} \
 	sort | ${TOOL_MTREE} -CSM -k all -R time -N ${NETBSDSRCDIR}/etc \
@@ -170,13 +171,16 @@ clean_METALOG: .PHONY ${METALOG}.sanitis
 
 # This target has debugging value only, really.
 makeflist: .PHONY .PRECIOUS check_DESTDIR
+	${_MKMSG_EXECUTE} "makeflist"
 	${SETSCMD} ./makeflist ${MAKEFLIST_FLAGS}
 
 checkflist: .PRECIOUS .PHONY check_DESTDIR sanitise_METALOG
+	${_MKMSG_EXECUTE} "checkflist"
 	${SETSCMD} ${.CURDIR}/checkflist \
 	${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.unpriv}
 
 checkflist-x11: .PHONY check_DESTDIR
+	${_MKMSG_EXECUTE} "checkflist -x"
 	${SETSCMD} ./checkflist -x ${CHECKFLIST_FLAGS}
 
 .if defined(DESTDIR) && ${DESTDIR} != ""
@@ -214,7 +218,7 @@ maketars: .PRECIOUS .PHONY check_DESTDIR
 
 maketarsetup: .EXEC
 .if defined(DESTDIR) && ${DESTDIR} != ""
-	${_MKMSG} "execute  checkflist"
+	${_MKMSG_EXECUTE} "checkflist"
 	cd ${.CURDIR}; ${MAKE} checkflist
 .endif
 	mkdir -p ${TARDIR}
@@ -268,6 +272,7 @@ installsets: .PHONY check_DESTDIR saniti
 	@echo "setenv INSTALLDIR before doing that!"
 	@false
 .endif
+	${_MKMSG_EXECUTE} "maketars for installsets"
 	${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
 	${METALOG.unpriv} -N ${NETBSDSRCDIR}/etc \
 	${MAKEFLIST_FLAGS} -i ${INSTALLDIR} ${INSTALLSETS}
@@ -292,6 +297,7 @@ REGPKG.update:= ${MKUPDATE:tl:Nno:C/..*/
 SYSPKGSETS?= all
 makesyspkgs: .PHONY check_DESTDIR check_RELEASEDIR \
 		sanitise_METALOG checkflist_if_DESTDIR
+	${_MKMSG_EXECUTE} "regpkgset for makesyspkgs"
 	mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs
 	${SETSCMD} ${.CURDIR}/regpkgset \
 	${REGPKG.verbose} ${REGPKG.force} ${REGPKG.sloppy} \
@@ -301,12 +307,14 @@ makesyspkgs: .PHONY check_DESTDIR check_
 	-t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs ${SYSPKGSETS}
 
 makesyspkgsums: .PHONY check_RELEASEDIR
+	${_MKMSG_CREATE} "syspkgs checksums"
 	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs
 
 # Update the "deps" file.
 # XXX: Why is "deps" checked in to the source tree, instead of
 # just being created as necessary?
 makedeps: .PHONY
+	${_MKMSG_CREATE} "syspkgs checksums"
 	${SETSCMD} ./syspkgdeps all >${.CURDIR}/deps
 
 # Sort the lists files.

Index: src/distrib/sets/maketars
diff -u src/distrib/sets/maketars:1.95 src/distrib/sets/maketars:1.96
--- src/distrib/sets/maketars:1.95	Sat Jun 10 14:11:08 2023
+++ src/distrib/sets/maketars	Sat Jun 10 16:08:41 2023
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: maketars,v 1.95 2023/06/10 14:11:08 lukem Exp $
+# $NetBSD: maketars,v 1.96 2023/06/10 16:08:41 lukem Exp $
 #
 # Make release tar files for some or all lists.  Usage:
 # maketars [-b] [-x] [-i installdir] [-a arch] [-m machine] [-s setsdir]
@@ -173,6 +173,7 @@ trap cleanup 0 2 3 13		# EXIT INT QUIT P
 #
 
 for setname in ${lists}; do
+	msg "Creating flist.${setname}"
 	${HOST_SH} "${setsdir}/makeflist" -a "${MACHINE_ARCH}" -m "${MACHINE}" \
 	-s "${setsdir}" "${setname}" > "${SDIR}/flist.${setname}" \
 	|| exit 1
@@ -180,7 +181,7 @@ for setname in ${lists}; do
 		echo >&2 "makeflist output is empty for ${setname}"
 		exit 1
 	fi
-	${setfilesonly} && msg "Creating ${setlistdir}/set.${setname}"
+	msg "Creating set.${setname}"
 	if [ -n "${metalog}" ]; then
 		${AWK} -f "${rundir}/getdirs.awk" "${SDIR}/flist.${setname}" \
 		> "${SDIR}/flist.${setname}.full" \

Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.1341 src/share/mk/bsd.own.mk:1.1342
--- src/share/mk/bsd.own.mk:1.1341	Sat Jun  3 21:2

CVS commit: src

2023-06-10 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jun 10 16:08:41 UTC 2023

Modified Files:
src/distrib/sets: Makefile maketars
src/share/mk: bsd.own.mk

Log Message:
sets: enhance MAKEVERBOSE support

Add more messages for various sets operations.
Add ${_MKMSG_CREATE} to bsd.own.mk.

Enhance maketars to be a bit more verbose even with -q,
to make it more obvious why certain operations may be slow.
May help debugging PR 47562.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/distrib/sets/Makefile
cvs rdiff -u -r1.95 -r1.96 src/distrib/sets/maketars
cvs rdiff -u -r1.1341 -r1.1342 src/share/mk/bsd.own.mk

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



CVS commit: src/distrib/sets

2023-06-10 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jun 10 14:11:08 UTC 2023

Modified Files:
src/distrib/sets: maketars

Log Message:
maketars: add comments for skipped mtree keywords

Reorder skipkeys alphabetically and add comment explaining
the purpose and why sha256 is not part of the variable.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/distrib/sets/maketars

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



CVS commit: src/distrib/sets

2023-06-10 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jun 10 14:11:08 UTC 2023

Modified Files:
src/distrib/sets: maketars

Log Message:
maketars: add comments for skipped mtree keywords

Reorder skipkeys alphabetically and add comment explaining
the purpose and why sha256 is not part of the variable.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/distrib/sets/maketars

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

Modified files:

Index: src/distrib/sets/maketars
diff -u src/distrib/sets/maketars:1.94 src/distrib/sets/maketars:1.95
--- src/distrib/sets/maketars:1.94	Sun Aug 21 07:10:03 2022
+++ src/distrib/sets/maketars	Sat Jun 10 14:11:08 2023
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: maketars,v 1.94 2022/08/21 07:10:03 lukem Exp $
+# $NetBSD: maketars,v 1.95 2023/06/10 14:11:08 lukem Exp $
 #
 # Make release tar files for some or all lists.  Usage:
 # maketars [-b] [-x] [-i installdir] [-a arch] [-m machine] [-s setsdir]
@@ -30,9 +30,12 @@ setlistdir=
 timestamp=
 setfilesonly=false
 quiet=false
-skipkeys=time,md5,sha1,sha384,sha512,rmd160,cksum
 preserve="-pe"
 
+# mtree(8) keys to skip (exclude) in the generated /etc/mtree/sets.* files.
+# Note: sets contain sha256 so that keyword is not listed here.
+skipkeys=cksum,md5,rmd160,sha1,sha384,sha512,time
+
 usage()
 {
 	cat 1>&2 <

CVS commit: src/doc

2023-06-10 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jun 10 13:16:44 UTC 2023

Modified Files:
src/doc: 3RDPARTY

Log Message:
3RDPARTY: libarchive latest is 3.6.2. note local fixes


To generate a diff of this commit:
cvs rdiff -u -r1.1929 -r1.1930 src/doc/3RDPARTY

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1929 src/doc/3RDPARTY:1.1930
--- src/doc/3RDPARTY:1.1929	Thu Jun  1 01:09:51 2023
+++ src/doc/3RDPARTY	Sat Jun 10 13:16:44 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1929 2023/06/01 01:09:51 gutteridge Exp $
+#	$NetBSD: 3RDPARTY,v 1.1930 2023/06/10 13:16:44 lukem Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -713,7 +713,7 @@ Talk to mrg before importing any new ver
 
 Package:	libarchive
 Version:	3.4.0
-Current Vers:	3.6.1
+Current Vers:	3.6.2
 Maintainer:	kient...@freebsd.org, jo...@netbsd.org
 Archive Site:	https://github.com/libarchive/libarchive/releases
 Home Page: 	http://www.libarchive.org
@@ -723,6 +723,7 @@ License:	BSD (2-clause)
 Location:	external/bsd/libarchive/dist
 Notes:
 Distribution is stripped down to the relevant part.
+Local fix for PR bin/56080 sent back to upstream.
 
 Package:	libdevmapper
 Version:	1.02.40



CVS commit: src/doc

2023-06-10 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jun 10 13:16:44 UTC 2023

Modified Files:
src/doc: 3RDPARTY

Log Message:
3RDPARTY: libarchive latest is 3.6.2. note local fixes


To generate a diff of this commit:
cvs rdiff -u -r1.1929 -r1.1930 src/doc/3RDPARTY

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



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 13:03:17 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c lexi.c

Log Message:
indent: clean up function names, fix blank lines in debug output


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.223 -r1.224 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/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.48 src/usr.bin/indent/debug.c:1.49
--- src/usr.bin/indent/debug.c:1.48	Sat Jun 10 11:01:58 2023
+++ src/usr.bin/indent/debug.c	Sat Jun 10 13:03:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.48 2023/06/10 11:01:58 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.49 2023/06/10 13:03:17 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.48 2023/06/10 11:01:58 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.49 2023/06/10 13:03:17 rillig Exp $");
 
 #include 
 #include 
@@ -287,7 +287,7 @@ debug_ps_paren(void)
 	}
 	if (ps.nparen == 0)
 		debug_printf(" none");
-	debug_blank_line();
+	debug_println("");
 }
 
 static bool
@@ -313,7 +313,7 @@ debug_ps_di_stack(void)
 		debug_printf(" %d", ps.di_stack[i]);
 	if (ps.decl_level == 0)
 		debug_printf(" none");
-	debug_blank_line();
+	debug_println("");
 }
 
 #define debug_ps_bool(name) \

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.223 src/usr.bin/indent/lexi.c:1.224
--- src/usr.bin/indent/lexi.c:1.223	Sat Jun 10 12:59:31 2023
+++ src/usr.bin/indent/lexi.c	Sat Jun 10 13:03:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.223 2023/06/10 12:59:31 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.224 2023/06/10 13:03:17 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: lexi.c,v 1.223 2023/06/10 12:59:31 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.224 2023/06/10 13:03:17 rillig Exp $");
 
 #include 
 #include 
@@ -313,7 +313,7 @@ cmp_keyword_by_name(const void *key, con
  * this starts a function definition or a declaration.
  */
 static bool
-probably_looking_at_definition(void)
+probably_function_definition(void)
 {
 	int paren_level = 0;
 	for (const char *p = inp_p; *p != '\n'; p++) {
@@ -418,7 +418,7 @@ found_typename:
 	if (inp_p[0] == '(' && ps.psyms.top <= 1 && ps.ind_level == 0 &&
 	!ps.in_func_def_params && !ps.in_init) {
 
-		if (ps.nparen == 0 && probably_looking_at_definition()) {
+		if (ps.nparen == 0 && probably_function_definition()) {
 			ps.line_has_func_def = true;
 			if (ps.in_decl)
 ps.in_func_def_params = true;
@@ -434,7 +434,7 @@ found_typename:
 }
 
 static bool
-is_asterisk_unary(void)
+is_asterisk_pointer(void)
 {
 	if (inp_p[strspn(inp_p, "* \t")] == ')')
 		return true;
@@ -464,7 +464,7 @@ probably_in_function_definition(void)
 }
 
 static void
-lex_asterisk_unary(void)
+lex_asterisk_pointer(void)
 {
 	while (inp_p[0] == '*' || ch_isspace(inp_p[0])) {
 		if (inp_p[0] == '*')
@@ -623,8 +623,8 @@ lexi(void)
 		if (inp_p[0] == '=') {
 			token_add_char(*inp_p++);
 			lsym = lsym_binary_op;
-		} else if (is_asterisk_unary()) {
-			lex_asterisk_unary();
+		} else if (is_asterisk_pointer()) {
+			lex_asterisk_pointer();
 			lsym = lsym_unary_op;
 		} else
 			lsym = lsym_binary_op;



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 13:03:17 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c lexi.c

Log Message:
indent: clean up function names, fix blank lines in debug output


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.223 -r1.224 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.



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 12:59:31 UTC 2023

Modified Files:
src/usr.bin/indent: indent.c indent.h io.c lexi.c pr_comment.c

Log Message:
indent: in debug mode, null-terminate buffers


To generate a diff of this commit:
cvs rdiff -u -r1.352 -r1.353 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.185 -r1.186 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/indent/io.c
cvs rdiff -u -r1.222 -r1.223 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.159 -r1.160 src/usr.bin/indent/pr_comment.c

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



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 12:59:31 UTC 2023

Modified Files:
src/usr.bin/indent: indent.c indent.h io.c lexi.c pr_comment.c

Log Message:
indent: in debug mode, null-terminate buffers


To generate a diff of this commit:
cvs rdiff -u -r1.352 -r1.353 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.185 -r1.186 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/indent/io.c
cvs rdiff -u -r1.222 -r1.223 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.159 -r1.160 src/usr.bin/indent/pr_comment.c

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

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.352 src/usr.bin/indent/indent.c:1.353
--- src/usr.bin/indent/indent.c:1.352	Sat Jun 10 08:17:04 2023
+++ src/usr.bin/indent/indent.c	Sat Jun 10 12:59:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.352 2023/06/10 08:17:04 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.353 2023/06/10 12:59:31 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.352 2023/06/10 08:17:04 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.353 2023/06/10 12:59:31 rillig Exp $");
 
 #include 
 #include 
@@ -110,12 +110,23 @@ buf_expand(struct buffer *buf, size_t ad
 	buf->s = nonnull(realloc(buf->s, buf->cap));
 }
 
+#ifdef debug
+void
+buf_terminate(struct buffer *buf)
+{
+	if (buf->len == buf->cap)
+		buf_expand(buf, 1);
+	buf->s[buf->len] = '\0';
+}
+#endif
+
 void
 buf_add_char(struct buffer *buf, char ch)
 {
 	if (buf->len == buf->cap)
 		buf_expand(buf, 1);
 	buf->s[buf->len++] = ch;
+	buf_terminate(buf);
 }
 
 void
@@ -127,6 +138,7 @@ buf_add_chars(struct buffer *buf, const 
 		buf_expand(buf, len);
 	memcpy(buf->s + buf->len, s, len);
 	buf->len += len;
+	buf_terminate(buf);
 }
 
 static void
@@ -327,7 +339,7 @@ move_com_to_code(lexer_symbol lsym)
 	if (ps.want_blank)
 		buf_add_char(&code, ' ');
 	buf_add_buf(&code, &com);
-	com.len = 0;
+	buf_clear(&com);
 	ps.want_blank = lsym != lsym_rparen && lsym != lsym_rbracket;
 }
 
@@ -433,6 +445,7 @@ read_preprocessing_line(void)
 
 	while (lab.len > 0 && ch_isblank(lab.s[lab.len - 1]))
 		lab.len--;
+	buf_terminate(&lab);
 }
 
 static void
@@ -805,7 +818,7 @@ process_colon_label(void)
 {
 	buf_add_buf(&lab, &code);
 	buf_add_char(&lab, ':');
-	code.len = 0;
+	buf_clear(&code);
 
 	if (ps.seen_case)
 		out.line_kind = lk_case_or_default;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.185 src/usr.bin/indent/indent.h:1.186
--- src/usr.bin/indent/indent.h:1.185	Sat Jun 10 07:42:41 2023
+++ src/usr.bin/indent/indent.h	Sat Jun 10 12:59:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.185 2023/06/10 07:42:41 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.186 2023/06/10 12:59:31 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -141,7 +141,7 @@ typedef enum parser_symbol {
 	psym_while_expr,	/* 'while' '(' expr ')' */
 } parser_symbol;
 
-/* A range of characters, not null-terminated. */
+/* A range of characters, only null-terminated in debug mode. */
 struct buffer {
 	char *s;
 	size_t len;
@@ -522,3 +522,16 @@ next_tab(int ind)
 {
 	return ind - ind % opt.tabsize + opt.tabsize;
 }
+
+#ifdef debug
+void buf_terminate(struct buffer *);
+#else
+#define buf_terminate(buf) debug_noop()
+#endif
+
+static inline void
+buf_clear(struct buffer *buf)
+{
+	buf->len = 0;
+	buf_terminate(buf);
+}

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.214 src/usr.bin/indent/io.c:1.215
--- src/usr.bin/indent/io.c:1.214	Sat Jun 10 11:01:58 2023
+++ src/usr.bin/indent/io.c	Sat Jun 10 12:59:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.214 2023/06/10 11:01:58 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.215 2023/06/10 12:59:31 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.214 2023/06/10 11:01:58 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.215 2023/06/10 12:59:31 rillig Exp $");
 
 #include 
 
@@ -61,7 +61,7 @@ static int paren_indent;
 static void
 inp_read_next_line(FILE *f)
 {
-	inp.len = 0;
+	buf_clear(&inp);
 
 	for (;;) {
 		int ch = getc(f);
@@ -79,6 +79,7 @@ inp_read_next_line(FILE *f)
 		if (ch == '\n')
 			break;
 	}
+	buf_terminate(&inp);
 	inp_p = inp.s;
 }
 
@@ -86,7 +87,7 @@ void
 inp_read_line(void)
 {
 	if (indent_enabled == indent_on)
-		out.indent_off_text.len = 0;
+		buf_clear(&out.indent_off_text);
 	buf_add_chars(&out.indent_off_text, inp.s, inp.len);
 	inp_read_next_line(input);
 }
@@ -316,6 +317,7 @@ output_line_comment(void)
 
 	while (com.s + com.len > p && ch_isspace(com.s[com.len - 1]))
 		com.len--;
+	buf_terminate(&com);
 
 	write_indent(target_ind);
 	write_range(p, com.len - (size_t)(p - com.s));
@@ -377,12 +379,12 @@ output_line(void)
 	else if (indent_enabled == indent_last_off_line) {
 		indent_enabled = indent_on;

CVS commit: src/external/bsd/libarchive/dist/libarchive

2023-06-10 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jun 10 12:46:32 UTC 2023

Modified Files:
src/external/bsd/libarchive/dist/libarchive: archive_read_disk_posix.c

Log Message:
libarchive: fail if name_max is 0

Add error handling to the USE_READDIR_R code paths that set name_max
from struct statfs or statvfs; if the determined name_max == 0
then return an error.

Avoids a crash in tree_dir_next_posix() when the calculation of
dirent_size from name_max is too small for the memory allocated
for struct dirent.

Submitted to upstream in pull request
https://github.com/libarchive/libarchive/pull/1903

Should fix PR bin/56080


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/bsd/libarchive/dist/libarchive/archive_read_disk_posix.c

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

Modified files:

Index: src/external/bsd/libarchive/dist/libarchive/archive_read_disk_posix.c
diff -u src/external/bsd/libarchive/dist/libarchive/archive_read_disk_posix.c:1.2 src/external/bsd/libarchive/dist/libarchive/archive_read_disk_posix.c:1.3
--- src/external/bsd/libarchive/dist/libarchive/archive_read_disk_posix.c:1.2	Mon Mar 29 15:31:46 2021
+++ src/external/bsd/libarchive/dist/libarchive/archive_read_disk_posix.c	Sat Jun 10 12:46:32 2023
@@ -1653,6 +1653,11 @@ setup_current_filesystem(struct archive_
 	else
 		t->current_filesystem->name_max = nm;
 #endif
+	if (t->current_filesystem->name_max == 0) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		"Cannot determine name_max");
+		return (ARCHIVE_FAILED);
+	}
 #endif /* USE_READDIR_R */
 	return (ARCHIVE_OK);
 }
@@ -1726,6 +1731,11 @@ setup_current_filesystem(struct archive_
 
 	/* Set maximum filename length. */
 	t->current_filesystem->name_max = sfs.f_namemax;
+	if (t->current_filesystem->name_max == 0) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		"Cannot determine name_max");
+		return (ARCHIVE_FAILED);
+	}
 	return (ARCHIVE_OK);
 }
 
@@ -1858,6 +1868,11 @@ setup_current_filesystem(struct archive_
 #if defined(USE_READDIR_R)
 	/* Set maximum filename length. */
 	t->current_filesystem->name_max = sfs.f_namelen;
+	if (t->current_filesystem->name_max == 0) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		"Cannot determine name_max");
+		return (ARCHIVE_FAILED);
+	}
 #endif
 	return (ARCHIVE_OK);
 }
@@ -1939,6 +1954,11 @@ setup_current_filesystem(struct archive_
 #if defined(USE_READDIR_R)
 	/* Set maximum filename length. */
 	t->current_filesystem->name_max = sfs.f_namemax;
+	if (t->current_filesystem->name_max == 0) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		"Cannot determine name_max");
+		return (ARCHIVE_FAILED);
+	}
 #endif
 	return (ARCHIVE_OK);
 }
@@ -1993,6 +2013,11 @@ setup_current_filesystem(struct archive_
 	else
 		t->current_filesystem->name_max = nm;
 #  endif /* _PC_NAME_MAX */
+	if (t->current_filesystem->name_max == 0) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		"Cannot determine name_max");
+		return (ARCHIVE_FAILED);
+	}
 #endif /* USE_READDIR_R */
 	return (ARCHIVE_OK);
 }



CVS commit: src/external/bsd/libarchive/dist/libarchive

2023-06-10 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jun 10 12:46:32 UTC 2023

Modified Files:
src/external/bsd/libarchive/dist/libarchive: archive_read_disk_posix.c

Log Message:
libarchive: fail if name_max is 0

Add error handling to the USE_READDIR_R code paths that set name_max
from struct statfs or statvfs; if the determined name_max == 0
then return an error.

Avoids a crash in tree_dir_next_posix() when the calculation of
dirent_size from name_max is too small for the memory allocated
for struct dirent.

Submitted to upstream in pull request
https://github.com/libarchive/libarchive/pull/1903

Should fix PR bin/56080


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/bsd/libarchive/dist/libarchive/archive_read_disk_posix.c

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



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 11:01:58 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c io.c

Log Message:
indent: distinguish blank lines from newline characters


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.213 -r1.214 src/usr.bin/indent/io.c

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

Modified files:

Index: src/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.47 src/usr.bin/indent/debug.c:1.48
--- src/usr.bin/indent/debug.c:1.47	Sat Jun 10 09:31:41 2023
+++ src/usr.bin/indent/debug.c	Sat Jun 10 11:01:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.47 2023/06/10 09:31:41 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.48 2023/06/10 11:01:58 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.47 2023/06/10 09:31:41 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.48 2023/06/10 11:01:58 rillig Exp $");
 
 #include 
 #include 
@@ -144,7 +144,7 @@ static struct {
 	struct parser_state prev_ps;
 	bool ps_first;
 	const char *heading;
-	unsigned wrote_newlines;
+	unsigned wrote_newlines;
 } state = {
 	.ps_first = true,
 	.wrote_newlines = 1,
@@ -227,7 +227,7 @@ debug_buffers(void)
 	debug_print_buf("label", &lab);
 	debug_print_buf("code", &code);
 	debug_print_buf("comment", &com);
-	debug_println("");
+	debug_blank_line();
 }
 
 static void
@@ -287,7 +287,7 @@ debug_ps_paren(void)
 	}
 	if (ps.nparen == 0)
 		debug_printf(" none");
-	debug_println("");
+	debug_blank_line();
 }
 
 static bool
@@ -313,7 +313,7 @@ debug_ps_di_stack(void)
 		debug_printf(" %d", ps.di_stack[i]);
 	if (ps.decl_level == 0)
 		debug_printf(" none");
-	debug_println("");
+	debug_blank_line();
 }
 
 #define debug_ps_bool(name) \
@@ -395,6 +395,6 @@ debug_parse_stack(const char *situation)
 	for (int i = 0; i <= psyms->top; ++i)
 		debug_printf(" %d %s",
 		psyms->ind_level[i], psym_name[psyms->sym[i]]);
-	debug_println("");
+	debug_blank_line();
 }
 #endif

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.213 src/usr.bin/indent/io.c:1.214
--- src/usr.bin/indent/io.c:1.213	Sat Jun 10 08:17:04 2023
+++ src/usr.bin/indent/io.c	Sat Jun 10 11:01:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.213 2023/06/10 08:17:04 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.214 2023/06/10 11:01:58 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.213 2023/06/10 08:17:04 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.214 2023/06/10 11:01:58 rillig Exp $");
 
 #include 
 
@@ -50,10 +50,11 @@ const char *inp_p;
 struct output_state out;
 enum indent_enabled indent_enabled;
 static int out_ind;		/* width of the line that is being written */
-static unsigned wrote_newlines = 2;	/* 0 in the middle of a line, 1 after a
-	 * single '\n', > 1 means there were (n
-	 * - 1) blank lines above */
-static unsigned buffered_blank_lines;
+static unsigned newlines = 2;	/* the total of written and buffered newlines;
+ * 0 in the middle of a line, 1 after a single
+ * finished line, anything > 1 are trailing
+ * blank lines */
+static unsigned buffered_newlines;	/* not yet written */
 static int paren_indent;
 
 
@@ -108,37 +109,37 @@ inp_next(void)
 
 
 static void
-write_newline(void)
+buffer_newline(void)
 {
-	buffered_blank_lines++;
-	wrote_newlines++;
+	buffered_newlines++;
+	newlines++;
 	out_ind = 0;
 }
 
 static void
-write_buffered_blank_lines(void)
+write_buffered_newlines(void)
 {
-	for (; buffered_blank_lines > 0; buffered_blank_lines--) {
+	for (; buffered_newlines > 0; buffered_newlines--) {
 		fputc('\n', output);
-		debug_println("output_newline");
+		debug_println("write_newline");
 	}
 }
 
 static void
 write_range(const char *s, size_t len)
 {
-	write_buffered_blank_lines();
+	write_buffered_newlines();
 	fwrite(s, 1, len, output);
-	debug_vis_range("output_range \"", s, len, "\"\n");
+	debug_vis_range("write_range \"", s, len, "\"\n");
 	for (size_t i = 0; i < len; i++)
-		wrote_newlines = s[i] == '\n' ? wrote_newlines + 1 : 0;
+		newlines = s[i] == '\n' ? newlines + 1 : 0;
 	out_ind = ind_add(out_ind, s, len);
 }
 
 static void
 write_indent(int new_ind)
 {
-	write_buffered_blank_lines();
+	write_buffered_newlines();
 
 	int ind = out_ind;
 
@@ -148,16 +149,16 @@ write_indent(int new_ind)
 			ind = ind - ind % opt.tabsize + n * opt.tabsize;
 			while (n-- > 0)
 fputc('\t', output);
-			wrote_newlines = 0;
+			newlines = 0;
 		}
 	}
 
 	for (; ind < new_ind; ind++) {
 		fputc(' ', output);
-		wrote_newlines = 0;
+		newlines = 0;
 	}
 
-	debug_println("output_indent %d", ind);
+	debug_println("write_indent %d", ind);
 	out_ind = ind;
 }
 
@@ -191,10 +192,10 @@ static bool
 is_blank_line_optional(void)
 {
 	if (out.prev_line_kind == lk_stmt_head)
-		return wrote_newlin

CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 11:01:58 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c io.c

Log Message:
indent: distinguish blank lines from newline characters


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.213 -r1.214 src/usr.bin/indent/io.c

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



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 09:31:42 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c

Log Message:
indent: clean up debug output

In diff mode, don't print a diff of the very first parser state, instead
print its full state.

Don't print headings for empty sections of the parser state.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/indent/debug.c

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

Modified files:

Index: src/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.46 src/usr.bin/indent/debug.c:1.47
--- src/usr.bin/indent/debug.c:1.46	Sat Jun 10 07:42:41 2023
+++ src/usr.bin/indent/debug.c	Sat Jun 10 09:31:41 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.46 2023/06/10 07:42:41 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.47 2023/06/10 09:31:41 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,19 +30,24 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.46 2023/06/10 07:42:41 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.47 2023/06/10 09:31:41 rillig Exp $");
 
 #include 
+#include 
 
 #include "indent.h"
 
 #ifdef debug
 
-/*-
- * false	show only the changes to the parser state
- * true		show unchanged parts of the parser state as well
- */
-static bool debug_full_parser_state = true;
+static struct {
+	/*-
+	 * false	show only the changes to the parser state
+	 * true		show unchanged parts of the parser state as well
+	 */
+	bool full_parser_state;
+} config = {
+	.full_parser_state = false,
+};
 
 const char *const lsym_name[] = {
 	"eof",
@@ -135,8 +140,15 @@ static const char *const extra_expr_inde
 	"last",
 };
 
-static unsigned wrote_newlines = 1;
-
+static struct {
+	struct parser_state prev_ps;
+	bool ps_first;
+	const char *heading;
+	unsigned wrote_newlines;
+} state = {
+	.ps_first = true,
+	.wrote_newlines = 1,
+};
 
 void
 debug_printf(const char *fmt, ...)
@@ -144,10 +156,14 @@ debug_printf(const char *fmt, ...)
 	FILE *f = output == stdout ? stderr : stdout;
 	va_list ap;
 
+	if (state.heading != NULL) {
+		fprintf(f, "%s\n", state.heading);
+		state.heading = NULL;
+	}
 	va_start(ap, fmt);
 	vfprintf(f, fmt, ap);
 	va_end(ap);
-	wrote_newlines = 0;
+	state.wrote_newlines = 0;
 }
 
 void
@@ -156,17 +172,22 @@ debug_println(const char *fmt, ...)
 	FILE *f = output == stdout ? stderr : stdout;
 	va_list ap;
 
+	if (state.heading != NULL) {
+		fprintf(f, "%s\n", state.heading);
+		state.heading = NULL;
+		state.wrote_newlines = 1;
+	}
 	va_start(ap, fmt);
 	vfprintf(f, fmt, ap);
 	va_end(ap);
 	fprintf(f, "\n");
-	wrote_newlines = fmt[0] == '\0' ? wrote_newlines + 1 : 1;
+	state.wrote_newlines = fmt[0] == '\0' ? state.wrote_newlines + 1 : 1;
 }
 
 void
 debug_blank_line(void)
 {
-	while (wrote_newlines < 2)
+	while (state.wrote_newlines < 2)
 		debug_println("");
 }
 
@@ -209,31 +230,41 @@ debug_buffers(void)
 	debug_println("");
 }
 
-#define debug_ps_bool(name) \
-	if (ps.name != prev_ps.name) \
-	debug_println("[%c]  ps." #name, \
-		" -+x"[(prev_ps.name ? 1 : 0) + (ps.name ? 2 : 0)]); \
-	else if (debug_full_parser_state) \
-	debug_println("[%c]  ps." #name, ps.name ? 'x' : ' ')
-#define debug_ps_int(name) \
-	if (ps.name != prev_ps.name) \
-	debug_println(" %3d -> %3d  ps." #name, prev_ps.name, ps.name); \
-	else if (debug_full_parser_state) \
-	debug_println("%3d  ps." #name, ps.name)
-#define debug_ps_enum(name, names) \
-	if (ps.name != prev_ps.name) \
-	debug_println(" %3s -> %3s  ps." #name, \
-		(names)[prev_ps.name], (names)[ps.name]); \
-	else if (debug_full_parser_state) \
-	debug_println(" %10s  ps." #name, (names)[ps.name])
+static void
+write_ps_bool(const char *name, bool prev, bool curr)
+{
+	if (curr != prev) {
+		char diff = " -+x"[(prev ? 1 : 0) + (curr ? 2 : 0)];
+		debug_println("[%c]  ps.%s", diff, name);
+	} else if (config.full_parser_state || state.ps_first)
+		debug_println("[%c]  ps.%s", curr ? 'x' : ' ', name);
+}
+
+static void
+write_ps_int(const char *name, int prev, int curr)
+{
+	if (curr != prev)
+		debug_println(" %3d -> %3d  ps.%s", prev, curr, name);
+	else if (config.full_parser_state || state.ps_first)
+		debug_println("%3d  ps.%s", curr, name);
+}
+
+static void
+write_ps_enum(const char *name, const char *prev, const char *curr)
+{
+	if (strcmp(prev, curr) != 0)
+		debug_println(" %3s -> %3s  ps.%s", prev, curr, name);
+	else if (config.full_parser_state || state.ps_first)
+		debug_println(" %10s  ps.%s", curr, name);
+}
 
 static bool
-ps_paren_has_changed(const struct parser_state *prev_ps)
+ps_paren_has_changed(void)
 {
-	if (prev_ps->nparen != ps.nparen)
+	if (state.prev_ps.nparen != ps.nparen)
 		return true;
 
-	const paren_level_props *prev = prev_ps->paren, *curr = ps.paren;
+	const paren_level_props *prev = state.prev_ps.paren, *curr = ps.paren;
 	for (int i = 0; i < ps.nparen

CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 09:31:42 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c

Log Message:
indent: clean up debug output

In diff mode, don't print a diff of the very first parser state, instead
print its full state.

Don't print headings for empty sections of the parser state.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/indent/debug.c

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



CVS commit: src/sys/arch/riscv/riscv

2023-06-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jun 10 09:18:50 UTC 2023

Modified Files:
src/sys/arch/riscv/riscv: spl.S

Log Message:
Remove magic numbers. NFCI.

Copyright maintenance while I'm here.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/riscv/riscv/spl.S

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



CVS commit: src/sys/arch/riscv/riscv

2023-06-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jun 10 09:18:50 UTC 2023

Modified Files:
src/sys/arch/riscv/riscv: spl.S

Log Message:
Remove magic numbers. NFCI.

Copyright maintenance while I'm here.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/riscv/riscv/spl.S

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

Modified files:

Index: src/sys/arch/riscv/riscv/spl.S
diff -u src/sys/arch/riscv/riscv/spl.S:1.6 src/sys/arch/riscv/riscv/spl.S:1.7
--- src/sys/arch/riscv/riscv/spl.S:1.6	Sun May  7 12:41:49 2023
+++ src/sys/arch/riscv/riscv/spl.S	Sat Jun 10 09:18:50 2023
@@ -1,11 +1,11 @@
-/* $NetBSD: spl.S,v 1.6 2023/05/07 12:41:49 skrll Exp $ */
+/* $NetBSD: spl.S,v 1.7 2023/06/10 09:18:50 skrll Exp $ */
 
 /*-
- * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * Copyright (c) 2014,2023 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Matt Thomas of 3am Software Foundry.
+ * by Matt Thomas of 3am Software Foundry, and Nick Hudson.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,7 +32,9 @@
 #include 
 #include "assym.h"
 
-__RCSID("$NetBSD: spl.S,v 1.6 2023/05/07 12:41:49 skrll Exp $")
+__RCSID("$NetBSD: spl.S,v 1.7 2023/06/10 09:18:50 skrll Exp $")
+
+#define SZINT	(1 << INT_SCALESHIFT)
 
 	.data
 	.globl	_C_LABEL(ipl_sie_map)
@@ -55,8 +57,7 @@ ENTRY_NP(splx)
 	INT_L	t0, CI_CPL(a3)		// get current IPL
 	bge	a0, t0, 2f
 
-
-	sll	t2, a0, 2		// INT_SCALESHIFT
+	sll	t2, a0, INT_SCALESHIFT
 	PTR_LA	a1, _C_LABEL(ipl_sie_map)
 	add	a1, a1, t2
 	INT_L	a1, 0(a1)
@@ -124,51 +125,51 @@ END(spl0)
 
 ENTRY_NP(splsoftclock)
 	li	t1, IPL_SOFTCLOCK
-	INT_L	t0, _C_LABEL(ipl_sie_map) + 4 * IPL_SOFTCLOCK
+	INT_L	t0, _C_LABEL(ipl_sie_map) + SZINT * IPL_SOFTCLOCK
 	j	_splraise
 END(splsoftclock)
 
 ENTRY_NP(splsoftbio)
 	li	t1, IPL_SOFTBIO
-	INT_L	t0, _C_LABEL(ipl_sie_map) + 4 * IPL_SOFTBIO
+	INT_L	t0, _C_LABEL(ipl_sie_map) + SZINT * IPL_SOFTBIO
 	j	_splraise
 END(splsoftbio)
 
 ENTRY_NP(splsoftnet)
 	li	t1, IPL_SOFTNET
-	INT_L	t0, _C_LABEL(ipl_sie_map) + 4 * IPL_SOFTNET
+	INT_L	t0, _C_LABEL(ipl_sie_map) + SZINT * IPL_SOFTNET
 	j	_splraise
 END(splsoftnet)
 
 ENTRY_NP(splsoftserial)
 	li	t1, IPL_SOFTSERIAL
-	INT_L	t0, _C_LABEL(ipl_sie_map) + 4 * IPL_SOFTSERIAL
+	INT_L	t0, _C_LABEL(ipl_sie_map) + SZINT * IPL_SOFTSERIAL
 	j	_splraise
 END(splsoftserial)
 
 ENTRY_NP(splvm)
 	li	t1, IPL_VM
-	INT_L	t0, _C_LABEL(ipl_sie_map) + 4 * IPL_VM
+	INT_L	t0, _C_LABEL(ipl_sie_map) + SZINT * IPL_VM
 	j	_splraise
 END(splvm)
 
 ENTRY_NP(splsched)
 	li	t1, IPL_SCHED
-	INT_L	t0, _C_LABEL(ipl_sie_map) + 4 * IPL_SCHED
+	INT_L	t0, _C_LABEL(ipl_sie_map) + SZINT * IPL_SCHED
 	j	_splraise
 END(splsched)
 
 #if 0
 ENTRY_NP(splddb)
 	li	t1, IPL_DDB
-	INT_L	t0, _C_LABEL(ipl_sie_map) + 4 * IPL_DDB
+	INT_L	t0, _C_LABEL(ipl_sie_map) + SZINT * IPL_DDB
 	j	_splraise
 END(splddb)
 #endif
 
 ENTRY_NP(splhigh)
 	li	t1, IPL_HIGH
-	INT_L	t0, _C_LABEL(ipl_sie_map) + 4 * IPL_HIGH
+	INT_L	t0, _C_LABEL(ipl_sie_map) + SZINT * IPL_HIGH
 	j	_splraise
 END(splhigh)
 
@@ -177,7 +178,7 @@ END(splhigh)
 ENTRY_NP(splraise)
 	// a0 = new higher IPL
 	mv	t1, a0
-	sll	t2, a0, 2		// INT_SCALESHIFT
+	sll	t2, a0, INT_SCALESHIFT
 	PTR_LA	a1, _C_LABEL(ipl_sie_map)
 	add	a1, a1, t2
 	INT_L	t0, 0(a1)



CVS commit: src

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 08:17:04 UTC 2023

Modified Files:
src/tests/usr.bin/indent: fmt_expr.c lsym_lparen_or_lbracket.c opt_ci.c
opt_lpl.c
src/usr.bin/indent: indent.c io.c

Log Message:
indent: fix indentation of continuation lines in initializers


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/fmt_expr.c
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/opt_ci.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/opt_lpl.c
cvs rdiff -u -r1.351 -r1.352 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.212 -r1.213 src/usr.bin/indent/io.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/fmt_expr.c
diff -u src/tests/usr.bin/indent/fmt_expr.c:1.6 src/tests/usr.bin/indent/fmt_expr.c:1.7
--- src/tests/usr.bin/indent/fmt_expr.c:1.6	Fri Jun  9 11:22:31 2023
+++ src/tests/usr.bin/indent/fmt_expr.c	Sat Jun 10 08:17:04 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: fmt_expr.c,v 1.6 2023/06/09 11:22:31 rillig Exp $ */
+/* $NetBSD: fmt_expr.c,v 1.7 2023/06/10 08:17:04 rillig Exp $ */
 
 /*
  * Tests for all kinds of expressions that are not directly related to unary
@@ -18,15 +18,6 @@
 	println((const char[3]){'-', c, '\0'});
 	x = ((struct point){0, 0}).x;
 
-	// XXX: GCC statement expressions are not supported yet.
-	int		var =
-	(
-	 {
-	 1
-	 }
-	)
-		   ;
-
 	for (ln = gnodes->first; ln != NULL; ln = ln->next)
 // $ FIXME: No space after the cast.
 		*(GNode **) Vector_Push(&vec) = ln->datum;
@@ -34,3 +25,36 @@
 //indent end
 
 //indent run-equals-input
+
+
+/*
+ * GCC statement expressions are not supported yet.
+ */
+//indent input
+{
+	int var = ({1});
+	int var = ({
+		1
+	});
+	int var = ({
+		int decl = 1;
+		stmt;
+	});
+}
+//indent end
+
+//indent run -di0
+error: Standard Input:7: Unbalanced parentheses
+warning: Standard Input:9: Extra ')'
+{
+	int var = ({1});
+	int var = ({
+		   1
+		   });
+	int var = ({
+		   int decl = 1;
+		stmt;
+	});
+}
+exit 1
+//indent end

Index: src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c
diff -u src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.15 src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.16
--- src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.15	Thu Jun  8 20:55:22 2023
+++ src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c	Sat Jun 10 08:17:04 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.15 2023/06/08 20:55:22 rillig Exp $ */
+/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.16 2023/06/10 08:17:04 rillig Exp $ */
 
 /*
  * Tests for the token lsym_lparen_or_lbracket, which represents a '(' or '['
@@ -289,7 +289,7 @@ cover_want_blank_before_lparen(void)
 {
 	/* ps.prev_lsym can never be 'newline'. */
 	int newline =
-	(3);
+		(3);
 
 	int lparen_or_lbracket = a[(3)];
 	int rparen_or_rbracket = a[3](5);

Index: src/tests/usr.bin/indent/opt_ci.c
diff -u src/tests/usr.bin/indent/opt_ci.c:1.10 src/tests/usr.bin/indent/opt_ci.c:1.11
--- src/tests/usr.bin/indent/opt_ci.c:1.10	Fri Jun  9 06:36:58 2023
+++ src/tests/usr.bin/indent/opt_ci.c	Sat Jun 10 08:17:04 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_ci.c,v 1.10 2023/06/09 06:36:58 rillig Exp $ */
+/* $NetBSD: opt_ci.c,v 1.11 2023/06/10 08:17:04 rillig Exp $ */
 
 /*
  * Tests for the option '-ci', which controls the indentation of continuation
@@ -238,10 +238,4 @@ function(void)
 }
 //indent end
 
-//indent run -ldi0 -ci4
-{
-	size_t last_word_len = com.len
-/* $ FIXME: The '-' must be indented by 4 spaces. */
-	- (size_t)(last_blank + 1);
-}
-//indent end
+//indent run-equals-input -ldi0 -ci4

Index: src/tests/usr.bin/indent/opt_lpl.c
diff -u src/tests/usr.bin/indent/opt_lpl.c:1.7 src/tests/usr.bin/indent/opt_lpl.c:1.8
--- src/tests/usr.bin/indent/opt_lpl.c:1.7	Sun Apr 24 09:04:12 2022
+++ src/tests/usr.bin/indent/opt_lpl.c	Sat Jun 10 08:17:04 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_lpl.c,v 1.7 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: opt_lpl.c,v 1.8 2023/06/10 08:17:04 rillig Exp $ */
 
 /*
  * Tests for the options '-lpl' and '-nlpl'.
@@ -46,13 +46,11 @@ example(void)
 	int		sum1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21;
 	int		sum2 = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21);
 
-/* $ XXX: There should be at least _some_ indentation for the */
-/* $ continuation lines. */
 	int		sum3 = 1 + 2 + 3 + 4 + 5 +
-	6 + 7 + 8 + 9 + 10 +
-	11 + 12 + 13 + 14 + 15 +
-	16 + 17 + 18 + 19 + 20 +
-	21;
+		6 + 7 + 8 + 9 + 10 +
+		11 + 12 + 13 + 14 + 15 +
+		16 + 17 + 18 + 19 + 20 +
+		21;
 	int		sum4 = (1 + 2 + 3 + 4 + 5 +
 6 + 7 + 8 + 9 + 10 +
 11 + 12 + 13 + 14 + 15 +

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.351 src/usr.bin/indent/indent.c:1.352
--- src/usr.bin/indent/i

CVS commit: src

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 08:17:04 UTC 2023

Modified Files:
src/tests/usr.bin/indent: fmt_expr.c lsym_lparen_or_lbracket.c opt_ci.c
opt_lpl.c
src/usr.bin/indent: indent.c io.c

Log Message:
indent: fix indentation of continuation lines in initializers


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/fmt_expr.c
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/opt_ci.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/opt_lpl.c
cvs rdiff -u -r1.351 -r1.352 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.212 -r1.213 src/usr.bin/indent/io.c

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



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 07:53:00 UTC 2023

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: extract output of an indented line to separate function


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/usr.bin/indent/io.c

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

Modified files:

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.211 src/usr.bin/indent/io.c:1.212
--- src/usr.bin/indent/io.c:1.211	Sat Jun 10 07:48:55 2023
+++ src/usr.bin/indent/io.c	Sat Jun 10 07:53:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.211 2023/06/10 07:48:55 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.212 2023/06/10 07:53:00 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.211 2023/06/10 07:48:55 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.212 2023/06/10 07:53:00 rillig Exp $");
 
 #include 
 
@@ -322,6 +322,42 @@ output_line_comment(void)
 	ps.comment_delta = ps.n_comment_delta;
 }
 
+static void
+output_line_indented(void)
+{
+	if (lab.len == 0 && code.len == 0 && com.len == 0)
+		out.line_kind = lk_blank;
+
+	if (want_blank_line() && wrote_newlines < 2
+	&& out.line_kind != lk_blank)
+		write_newline();
+
+	/* This kludge aligns function definitions correctly. */
+	if (ps.ind_level == 0)
+		ps.in_stmt_cont = false;
+
+	if (opt.blank_line_after_decl && ps.declaration == decl_end
+	&& ps.psyms.top > 1) {
+		ps.declaration = decl_no;
+		ps.blank_line_after_decl = true;
+	}
+
+	if (opt.swallow_optional_blanklines
+	&& out.line_kind == lk_blank
+	&& is_blank_line_optional())
+		return;
+
+	if (lab.len > 0)
+		output_line_label();
+	if (code.len > 0)
+		output_line_code();
+	if (com.len > 0)
+		output_line_comment();
+
+	write_newline();
+	out.prev_line_kind = out.line_kind;
+}
+
 /*
  * Write a line of formatted source to the output file. The line consists of
  * the label, the code and the comment.
@@ -333,47 +369,14 @@ output_line(void)
 	debug_printf("%s", __func__);
 	debug_buffers();
 
-	if (indent_enabled == indent_on) {
-		if (lab.len == 0 && code.len == 0 && com.len == 0)
-			out.line_kind = lk_blank;
-
-		if (want_blank_line() && wrote_newlines < 2
-		&& out.line_kind != lk_blank)
-			write_newline();
-
-		/* This kludge aligns function definitions correctly. */
-		if (ps.ind_level == 0)
-			ps.in_stmt_cont = false;
-
-		if (opt.blank_line_after_decl && ps.declaration == decl_end
-		&& ps.psyms.top > 1) {
-			ps.declaration = decl_no;
-			ps.blank_line_after_decl = true;
-		}
-
-		if (opt.swallow_optional_blanklines
-		&& out.line_kind == lk_blank
-		&& is_blank_line_optional())
-			goto prepare_next_line;
-
-		if (lab.len > 0)
-			output_line_label();
-		if (code.len > 0)
-			output_line_code();
-		if (com.len > 0)
-			output_line_comment();
-
-		write_newline();
-		out.prev_line_kind = out.line_kind;
-	}
-
-	if (indent_enabled == indent_last_off_line) {
+	if (indent_enabled == indent_on)
+		output_line_indented();
+	else if (indent_enabled == indent_last_off_line) {
 		indent_enabled = indent_on;
 		write_range(out.indent_off_text.s, out.indent_off_text.len);
 		out.indent_off_text.len = 0;
 	}
 
-prepare_next_line:
 	lab.len = 0;
 	code.len = 0;
 	com.len = 0;



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 07:53:00 UTC 2023

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: extract output of an indented line to separate function


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/usr.bin/indent/io.c

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



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 07:48:55 UTC 2023

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: clean up function names and order in output


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/usr.bin/indent/io.c

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



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 07:48:55 UTC 2023

Modified Files:
src/usr.bin/indent: io.c

Log Message:
indent: clean up function names and order in output


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/usr.bin/indent/io.c

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

Modified files:

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.210 src/usr.bin/indent/io.c:1.211
--- src/usr.bin/indent/io.c:1.210	Sat Jun 10 07:42:41 2023
+++ src/usr.bin/indent/io.c	Sat Jun 10 07:48:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.210 2023/06/10 07:42:41 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.211 2023/06/10 07:48:55 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.210 2023/06/10 07:42:41 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.211 2023/06/10 07:48:55 rillig Exp $");
 
 #include 
 
@@ -108,7 +108,7 @@ inp_next(void)
 
 
 static void
-output_newline(void)
+write_newline(void)
 {
 	buffered_blank_lines++;
 	wrote_newlines++;
@@ -125,7 +125,7 @@ write_buffered_blank_lines(void)
 }
 
 static void
-output_range(const char *s, size_t len)
+write_range(const char *s, size_t len)
 {
 	write_buffered_blank_lines();
 	fwrite(s, 1, len, output);
@@ -136,7 +136,7 @@ output_range(const char *s, size_t len)
 }
 
 static void
-output_indent(int new_ind)
+write_indent(int new_ind)
 {
 	write_buffered_blank_lines();
 
@@ -161,22 +161,6 @@ output_indent(int new_ind)
 	out_ind = ind;
 }
 
-void
-output_finish(void)
-{
-	if (lab.len > 0 || code.len > 0 || com.len > 0)
-		output_line();
-	if (indent_enabled == indent_on) {
-		if (buffered_blank_lines > 1)
-			buffered_blank_lines = 1;
-		write_buffered_blank_lines();
-	} else {
-		indent_enabled = indent_last_off_line;
-		output_line();
-	}
-	fflush(output);
-}
-
 static bool
 want_blank_line(void)
 {
@@ -236,8 +220,8 @@ compute_label_indent(void)
 static void
 output_line_label(void)
 {
-	output_indent(compute_label_indent());
-	output_range(lab.s, lab.len);
+	write_indent(compute_label_indent());
+	write_range(lab.s, lab.len);
 }
 
 static int
@@ -300,9 +284,9 @@ output_line_code(void)
 	}
 
 	if (lab.len > 0 && target_ind <= out_ind)
-		output_range(" ", 1);
-	output_indent(target_ind);
-	output_range(code.s, code.len);
+		write_range(" ", 1);
+	write_indent(target_ind);
+	write_range(code.s, code.len);
 }
 
 static void
@@ -327,13 +311,13 @@ output_line_comment(void)
 	}
 
 	if (out_ind > target_ind)
-		output_newline();
+		write_newline();
 
 	while (com.s + com.len > p && ch_isspace(com.s[com.len - 1]))
 		com.len--;
 
-	output_indent(target_ind);
-	output_range(p, com.len - (size_t)(p - com.s));
+	write_indent(target_ind);
+	write_range(p, com.len - (size_t)(p - com.s));
 
 	ps.comment_delta = ps.n_comment_delta;
 }
@@ -355,7 +339,7 @@ output_line(void)
 
 		if (want_blank_line() && wrote_newlines < 2
 		&& out.line_kind != lk_blank)
-			output_newline();
+			write_newline();
 
 		/* This kludge aligns function definitions correctly. */
 		if (ps.ind_level == 0)
@@ -379,13 +363,13 @@ output_line(void)
 		if (com.len > 0)
 			output_line_comment();
 
-		output_newline();
+		write_newline();
 		out.prev_line_kind = out.line_kind;
 	}
 
 	if (indent_enabled == indent_last_off_line) {
 		indent_enabled = indent_on;
-		output_range(out.indent_off_text.s, out.indent_off_text.len);
+		write_range(out.indent_off_text.s, out.indent_off_text.len);
 		out.indent_off_text.len = 0;
 	}
 
@@ -416,3 +400,19 @@ prepare_next_line:
 
 	out.line_kind = lk_other;
 }
+
+void
+output_finish(void)
+{
+	if (lab.len > 0 || code.len > 0 || com.len > 0)
+		output_line();
+	if (indent_enabled == indent_on) {
+		if (buffered_blank_lines > 1)
+			buffered_blank_lines = 1;
+		write_buffered_blank_lines();
+	} else {
+		indent_enabled = indent_last_off_line;
+		output_line();
+	}
+	fflush(output);
+}



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 07:42:41 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c indent.c indent.h io.c lexi.c

Log Message:
indent: clean up function and variable names


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.350 -r1.351 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.184 -r1.185 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.209 -r1.210 src/usr.bin/indent/io.c
cvs rdiff -u -r1.221 -r1.222 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.



CVS commit: src/usr.bin/indent

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 07:42:41 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c indent.c indent.h io.c lexi.c

Log Message:
indent: clean up function and variable names


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.350 -r1.351 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.184 -r1.185 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.209 -r1.210 src/usr.bin/indent/io.c
cvs rdiff -u -r1.221 -r1.222 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/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.45 src/usr.bin/indent/debug.c:1.46
--- src/usr.bin/indent/debug.c:1.45	Sat Jun 10 07:05:18 2023
+++ src/usr.bin/indent/debug.c	Sat Jun 10 07:42:41 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.45 2023/06/10 07:05:18 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.46 2023/06/10 07:42:41 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.45 2023/06/10 07:05:18 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.46 2023/06/10 07:42:41 rillig Exp $");
 
 #include 
 
@@ -299,7 +299,7 @@ debug_parser_state(void)
 	debug_ps_bool(in_var_decl);
 	debug_ps_bool(in_init);
 	debug_ps_int(init_level);
-	debug_ps_bool(in_func_def_line);
+	debug_ps_bool(line_has_func_def);
 	debug_ps_bool(in_func_def_params);
 	debug_ps_bool(line_has_decl);
 	debug_ps_enum(lbrace_kind, psym_name);

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.350 src/usr.bin/indent/indent.c:1.351
--- src/usr.bin/indent/indent.c:1.350	Sat Jun 10 06:52:35 2023
+++ src/usr.bin/indent/indent.c	Sat Jun 10 07:42:41 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.350 2023/06/10 06:52:35 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.351 2023/06/10 07:42:41 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.350 2023/06/10 06:52:35 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.351 2023/06/10 07:42:41 rillig Exp $");
 
 #include 
 #include 
@@ -372,7 +372,7 @@ is_function_pointer_declaration(void)
 	return ps.in_decl
 	&& !ps.in_init
 	&& !ps.decl_indent_done
-	&& !ps.in_func_def_line
+	&& !ps.line_has_func_def
 	&& ps.line_start_nparen == 0;
 }
 
@@ -545,7 +545,7 @@ process_lparen(void)
 	|| ps.prev_lsym == lsym_if
 	|| ps.prev_lsym == lsym_switch
 	|| ps.prev_lsym == lsym_while
-	|| ps.in_func_def_line)
+	|| ps.line_has_func_def)
 		cast = cast_no;
 
 	ps.paren[ps.nparen - 1].indent = indent;
@@ -779,21 +779,15 @@ static void
 process_question(void)
 {
 	ps.quest_level++;
-	if (code.len == 0) {
-		ps.in_stmt_cont = true;
-		ps.in_stmt_or_decl = true;
-		ps.in_decl = false;
-	}
+	if (code.len == 0)
+		ps.in_stmt_cont = true;	// XXX: should be unnecessary.
 }
 
 static void
 process_colon_question(void)
 {
-	if (code.len == 0) {
-		ps.in_stmt_cont = true;
-		ps.in_stmt_or_decl = true;
-		ps.in_decl = false;
-	}
+	if (code.len == 0)
+		ps.in_stmt_cont = true;	// XXX: should be unnecessary.
 }
 
 static void
@@ -802,7 +796,7 @@ process_comma(void)
 	ps.want_blank = code.len > 0;	/* only put blank after comma if comma
 	 * does not start the line */
 
-	if (ps.in_decl && !ps.in_func_def_line && !ps.in_init &&
+	if (ps.in_decl && !ps.line_has_func_def && !ps.in_init &&
 	!ps.decl_indent_done && ps.line_start_nparen == 0) {
 		/* indent leading commas and not the actual identifiers */
 		indent_declarator(ps.decl_ind - 1, ps.tabs_to_var);
@@ -891,7 +885,7 @@ process_semicolon(void)
 }
 
 static void
-process_type(void)
+process_type_outside_parentheses(void)
 {
 	parse(psym_decl);	/* let the parser worry about indentation */
 
@@ -918,7 +912,7 @@ process_type(void)
 }
 
 static void
-process_ident(lexer_symbol lsym)
+process_word(lexer_symbol lsym)
 {
 	if (ps.in_decl) {
 		if (lsym == lsym_funcname) {
@@ -940,8 +934,8 @@ process_ident(lexer_symbol lsym)
 
 	} else if (ps.spaced_expr_psym != psym_0 && ps.nparen == 0) {
 		ps.force_nl = true;
-		ps.next_unary = true;
 		ps.in_stmt_or_decl = false;
+		ps.next_unary = true;
 		parse(ps.spaced_expr_psym);
 		ps.spaced_expr_psym = psym_0;
 	}
@@ -1014,7 +1008,7 @@ process_lsym(lexer_symbol lsym)
 			goto copy_token;
 		/* FALLTHROUGH */
 	case lsym_type_outside_parentheses:
-		process_type();
+		process_type_outside_parentheses();
 		goto copy_token;
 
 	case lsym_type_in_parentheses:
@@ -1023,7 +1017,7 @@ process_lsym(lexer_symbol lsym)
 	case lsym_word:
 	case lsym_funcname:
 	case lsym_return:
-		process_ident(lsym);
+		process_word(lsym);
 copy_token:
 		if (ps.want_blank)
 			buf_add_char(&code, ' ');

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.184 src/usr.bin/indent/indent.h:1.185
--- src/usr.bin/indent/indent.h:1.184	Sat Jun 10 06

CVS commit: src/sys/arch/aarch64/aarch64

2023-06-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jun 10 07:33:32 UTC 2023

Modified Files:
src/sys/arch/aarch64/aarch64: cpufunc.c

Log Message:
KASSERT(kpreempt_disabled()) before accessing curcpu() to reflect why
preemption needs to be disabled more clearly.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/aarch64/aarch64/cpufunc.c

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpufunc.c
diff -u src/sys/arch/aarch64/aarch64/cpufunc.c:1.34 src/sys/arch/aarch64/aarch64/cpufunc.c:1.35
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.34	Sat Feb 25 00:40:22 2023
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Sat Jun 10 07:33:32 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.34 2023/02/25 00:40:22 riastradh Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.35 2023/06/10 07:33:32 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -30,7 +30,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.34 2023/02/25 00:40:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.35 2023/06/10 07:33:32 skrll Exp $");
 
 #include 
 #include 
@@ -365,12 +365,12 @@ ln_dcache_inv_all(int level, struct aarc
 void
 aarch64_dcache_wbinv_all(void)
 {
+	KASSERT(kpreempt_disabled());
+
 	struct cpu_info * const ci = curcpu();
 	struct aarch64_cache_info * const cinfo = ci->ci_cacheinfo;
 	int level;
 
-	KASSERT(kpreempt_disabled());
-
 	for (level = 0; level < MAX_CACHE_LEVEL; level++) {
 		if (cinfo[level].cacheable == CACHE_CACHEABLE_NONE)
 			break;
@@ -384,12 +384,12 @@ aarch64_dcache_wbinv_all(void)
 void
 aarch64_dcache_inv_all(void)
 {
+	KASSERT(kpreempt_disabled());
+
 	struct cpu_info * const ci = curcpu();
 	struct aarch64_cache_info * const cinfo = ci->ci_cacheinfo;
 	int level;
 
-	KASSERT(kpreempt_disabled());
-
 	for (level = 0; level < MAX_CACHE_LEVEL; level++) {
 		if (cinfo[level].cacheable == CACHE_CACHEABLE_NONE)
 			break;
@@ -403,12 +403,12 @@ aarch64_dcache_inv_all(void)
 void
 aarch64_dcache_wb_all(void)
 {
+	KASSERT(kpreempt_disabled());
+
 	struct cpu_info * const ci = curcpu();
 	struct aarch64_cache_info * const cinfo = ci->ci_cacheinfo;
 	int level;
 
-	KASSERT(kpreempt_disabled());
-
 	for (level = 0; level < MAX_CACHE_LEVEL; level++) {
 		if (cinfo[level].cacheable == CACHE_CACHEABLE_NONE)
 			break;



CVS commit: src/sys/arch/aarch64/aarch64

2023-06-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jun 10 07:33:32 UTC 2023

Modified Files:
src/sys/arch/aarch64/aarch64: cpufunc.c

Log Message:
KASSERT(kpreempt_disabled()) before accessing curcpu() to reflect why
preemption needs to be disabled more clearly.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/aarch64/aarch64/cpufunc.c

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



CVS commit: src/sys/arch/evbmips/evbmips

2023-06-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jun 10 07:30:57 UTC 2023

Modified Files:
src/sys/arch/evbmips/evbmips: interrupt.c

Log Message:
Trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/evbmips/evbmips/interrupt.c

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

Modified files:

Index: src/sys/arch/evbmips/evbmips/interrupt.c
diff -u src/sys/arch/evbmips/evbmips/interrupt.c:1.24 src/sys/arch/evbmips/evbmips/interrupt.c:1.25
--- src/sys/arch/evbmips/evbmips/interrupt.c:1.24	Fri Aug 26 15:45:47 2016
+++ src/sys/arch/evbmips/evbmips/interrupt.c	Sat Jun 10 07:30:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: interrupt.c,v 1.24 2016/08/26 15:45:47 skrll Exp $	*/
+/*	$NetBSD: interrupt.c,v 1.25 2023/06/10 07:30:57 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.24 2016/08/26 15:45:47 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.25 2023/06/10 07:30:57 skrll Exp $");
 
 #include 
 #include 
@@ -84,7 +84,7 @@ cpu_intr(int ppl, vaddr_t pc, uint32_t s
 			KASSERTMSG(ipl == IPL_SCHED,
 			"%s: ipl (%d) != IPL_SCHED (%d)",
 			 __func__, ipl, IPL_SCHED);
-			/* call the common MIPS3 clock interrupt handler */ 
+			/* call the common MIPS3 clock interrupt handler */
 			mips3_clockintr(&cf);
 			pending ^= MIPS_INT_MASK_5;
 		}



CVS commit: src/sys/arch/evbmips/evbmips

2023-06-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jun 10 07:30:57 UTC 2023

Modified Files:
src/sys/arch/evbmips/evbmips: interrupt.c

Log Message:
Trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/evbmips/evbmips/interrupt.c

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



CVS commit: src

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 07:05:18 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_case_label.c
src/usr.bin/indent: debug.c

Log Message:
indent: explain right-aligned code


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/lsym_case_label.c
cvs rdiff -u -r1.44 -r1.45 src/usr.bin/indent/debug.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/lsym_case_label.c
diff -u src/tests/usr.bin/indent/lsym_case_label.c:1.9 src/tests/usr.bin/indent/lsym_case_label.c:1.10
--- src/tests/usr.bin/indent/lsym_case_label.c:1.9	Sat Jun 10 06:52:35 2023
+++ src/tests/usr.bin/indent/lsym_case_label.c	Sat Jun 10 07:05:18 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_case_label.c,v 1.9 2023/06/10 06:52:35 rillig Exp $ */
+/* $NetBSD: lsym_case_label.c,v 1.10 2023/06/10 07:05:18 rillig Exp $ */
 
 /*
  * Tests for the tokens lsym_case and lsym_default, which represent the
@@ -92,10 +92,12 @@ const char *type_name = _Generic(
 // $ XXX: It's strange to align the arguments at the parenthesis even though
 // $ XXX: the first argument is already on a separate line.
  ' ',
+// $ The indentation is so large that the strings would spill over the right
+// $ margin.  To prevent that, the code is right-aligned.  Since the base
+// $ indentation of this declaration is 0, the code might even start at the
+// $ beginning of the line.
  int: "character constants have type 'int'",
-// $ FIXME: The indentation is not sensible in any way.
 			   char: "character constants have type 'char'",
-// $ FIXME: The indentation is not sensible in any way.
 			 default: "character constants have some other type"
 );
 //indent end

Index: src/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.44 src/usr.bin/indent/debug.c:1.45
--- src/usr.bin/indent/debug.c:1.44	Sat Jun 10 06:38:20 2023
+++ src/usr.bin/indent/debug.c	Sat Jun 10 07:05:18 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.44 2023/06/10 06:38:20 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.45 2023/06/10 07:05:18 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.44 2023/06/10 06:38:20 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.45 2023/06/10 07:05:18 rillig Exp $");
 
 #include 
 
@@ -62,7 +62,7 @@ const char *const lsym_name[] = {
 	"postfix_op",
 	"binary_op",
 	"question",
-	"'?:' colon",
+	"question_colon",
 	"comma",
 	"typedef",
 	"modifier",
@@ -71,8 +71,8 @@ const char *const lsym_name[] = {
 	"type_in_parentheses",
 	"word",
 	"funcname",
-	"label colon",
-	"other colon",
+	"label_colon",
+	"other_colon",
 	"semicolon",
 	"case",
 	"default",



CVS commit: src

2023-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 10 07:05:18 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_case_label.c
src/usr.bin/indent: debug.c

Log Message:
indent: explain right-aligned code


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/lsym_case_label.c
cvs rdiff -u -r1.44 -r1.45 src/usr.bin/indent/debug.c

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



CVS commit: src/sys/arch/riscv/riscv

2023-06-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jun 10 07:02:26 UTC 2023

Modified Files:
src/sys/arch/riscv/riscv: pmap_machdep.c

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/riscv/riscv/pmap_machdep.c

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

Modified files:

Index: src/sys/arch/riscv/riscv/pmap_machdep.c
diff -u src/sys/arch/riscv/riscv/pmap_machdep.c:1.16 src/sys/arch/riscv/riscv/pmap_machdep.c:1.17
--- src/sys/arch/riscv/riscv/pmap_machdep.c:1.16	Sun May  7 12:41:49 2023
+++ src/sys/arch/riscv/riscv/pmap_machdep.c	Sat Jun 10 07:02:26 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap_machdep.c,v 1.16 2023/05/07 12:41:49 skrll Exp $ */
+/* $NetBSD: pmap_machdep.c,v 1.17 2023/06/10 07:02:26 skrll Exp $ */
 
 /*
  * Copyright (c) 2014, 2019, 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #define	__PMAP_PRIVATE
 
 #include 
-__RCSID("$NetBSD: pmap_machdep.c,v 1.16 2023/05/07 12:41:49 skrll Exp $");
+__RCSID("$NetBSD: pmap_machdep.c,v 1.17 2023/06/10 07:02:26 skrll Exp $");
 
 #include 
 #include 
@@ -170,7 +170,7 @@ pmap_md_xtab_activate(struct pmap *pmap,
 //	struct cpu_info * const ci = curcpu();
 	struct pmap_asid_info * const pai = PMAP_PAI(pmap, cpu_tlb_info(ci));
 
-	 uint64_t satp =
+	uint64_t satp =
 #ifdef _LP64
 	__SHIFTIN(SATP_MODE_SV39, SATP_MODE) |
 #else



CVS commit: src/sys/arch/riscv/riscv

2023-06-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jun 10 07:02:26 UTC 2023

Modified Files:
src/sys/arch/riscv/riscv: pmap_machdep.c

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/riscv/riscv/pmap_machdep.c

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