CVS commit: src

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 07:23:03 UTC 2023

Modified Files:
src/tests/usr.bin/indent: t_misc.sh
src/usr.bin/indent: indent.c io.c

Log Message:
indent: clean up handling of whitespace

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/tests/usr.bin/indent/t_misc.sh
cvs rdiff -u -r1.327 -r1.328 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.194 -r1.195 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

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 07:23:03 UTC 2023

Modified Files:
src/tests/usr.bin/indent: t_misc.sh
src/usr.bin/indent: indent.c io.c

Log Message:
indent: clean up handling of whitespace

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/tests/usr.bin/indent/t_misc.sh
cvs rdiff -u -r1.327 -r1.328 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.194 -r1.195 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/t_misc.sh
diff -u src/tests/usr.bin/indent/t_misc.sh:1.25 src/tests/usr.bin/indent/t_misc.sh:1.26
--- src/tests/usr.bin/indent/t_misc.sh:1.25	Mon May 15 17:38:56 2023
+++ src/tests/usr.bin/indent/t_misc.sh	Mon Jun  5 07:23:03 2023
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_misc.sh,v 1.25 2023/05/15 17:38:56 rillig Exp $
+# $NetBSD: t_misc.sh,v 1.26 2023/06/05 07:23:03 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -405,6 +405,16 @@ opt_v_break_line_body()
 	"$indent" -v code.c -st
 }
 
+
+atf_test_case 'trailing_whitespace_in_preprocessing_line'
+trailing_whitespace_in_preprocessing_line_body()
+{
+	printf '#if trailing && space \n#endif\n' > code.c
+
+	atf_check -o 'inline:#if trailing && space\n#endif\n' \
+	"$indent" code.c -st
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case 'in_place'
@@ -421,4 +431,5 @@ atf_init_test_cases()
 	atf_add_test_case 'several_profiles'
 	atf_add_test_case 'command_line_vs_profile'
 	atf_add_test_case 'in_place_parse_error'
+	atf_add_test_case 'trailing_whitespace_in_preprocessing_line'
 }

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.327 src/usr.bin/indent/indent.c:1.328
--- src/usr.bin/indent/indent.c:1.327	Sun Jun  4 20:51:19 2023
+++ src/usr.bin/indent/indent.c	Mon Jun  5 07:23:03 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.327 2023/06/04 20:51:19 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.328 2023/06/05 07:23:03 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.327 2023/06/04 20:51:19 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.328 2023/06/05 07:23:03 rillig Exp $");
 
 #include 
 #include 
@@ -1001,9 +1001,6 @@ read_preprocessing_line(void)
 
 	buf_add_char(&lab, '#');
 
-	while (ch_isblank(inp_p[0]))
-		buf_add_char(&lab, *inp_p++);
-
 	while (inp_p[0] != '\n' || (state == COMM && !had_eof)) {
 		buf_add_char(&lab, inp_next());
 		switch (lab.s[lab.len - 1]) {

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.194 src/usr.bin/indent/io.c:1.195
--- src/usr.bin/indent/io.c:1.194	Mon Jun  5 06:43:14 2023
+++ src/usr.bin/indent/io.c	Mon Jun  5 07:23:03 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.194 2023/06/05 06:43:14 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.195 2023/06/05 07:23:03 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.194 2023/06/05 06:43:14 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.195 2023/06/05 07:23:03 rillig Exp $");
 
 #include 
 
@@ -179,10 +179,6 @@ is_blank_line_optional(void)
 static void
 output_line_label(void)
 {
-
-	while (lab.len > 0 && ch_isblank(lab.s[lab.len - 1]))
-		lab.len--;
-
 	output_indent(compute_label_indent());
 	output_range(lab.s, lab.len);
 }
@@ -202,10 +198,9 @@ output_line_code(void)
 		}
 	}
 
-	int label_end_ind = out_ind;
-	output_indent(target_ind);
-	if (label_end_ind > 0 && out_ind == label_end_ind)
+	if (lab.len > 0 && target_ind <= out_ind)
 		output_range(" ", 1);
+	output_indent(target_ind);
 	output_range(code.s, code.len);
 }
 



CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 07:35:05 UTC 2023

Modified Files:
src/usr.bin/indent: args.c indent.c indent.h parse.c

Log Message:
indent: rename variables, clean up comments

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/indent/args.c
cvs rdiff -u -r1.328 -r1.329 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.171 -r1.172 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.65 -r1.66 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/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 07:35:05 UTC 2023

Modified Files:
src/usr.bin/indent: args.c indent.c indent.h parse.c

Log Message:
indent: rename variables, clean up comments

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/indent/args.c
cvs rdiff -u -r1.328 -r1.329 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.171 -r1.172 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.65 -r1.66 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/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.80 src/usr.bin/indent/args.c:1.81
--- src/usr.bin/indent/args.c:1.80	Thu May 18 06:01:39 2023
+++ src/usr.bin/indent/args.c	Mon Jun  5 07:35:05 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.80 2023/05/18 06:01:39 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.81 2023/06/05 07:35:05 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: args.c,v 1.80 2023/05/18 06:01:39 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.81 2023/06/05 07:35:05 rillig Exp $");
 
 /* Read options from profile files and from the command line. */
 
@@ -91,9 +91,9 @@ static const struct pro {
 	bool_options("cs", space_after_cast),
 	int_option("d", unindent_displace, -999, 999),
 	int_option("di", decl_indent, 0, 999),
-	bool_options("dj", ljust_decl),
+	bool_options("dj", left_justify_decl),
 	bool_options("eei", extra_expr_indent),
-	bool_options("ei", else_if),
+	bool_options("ei", else_if_in_same_line),
 	bool_options("fbs", function_brace_split),
 	bool_options("fc1", format_col1_comments),
 	bool_options("fcb", format_block_comments),

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.328 src/usr.bin/indent/indent.c:1.329
--- src/usr.bin/indent/indent.c:1.328	Mon Jun  5 07:23:03 2023
+++ src/usr.bin/indent/indent.c	Mon Jun  5 07:35:05 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.328 2023/06/05 07:23:03 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.329 2023/06/05 07:35:05 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.328 2023/06/05 07:23:03 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.329 2023/06/05 07:35:05 rillig Exp $");
 
 #include 
 #include 
@@ -57,7 +57,7 @@ struct options opt = {
 	.cuddle_else = true,
 	.comment_column = 33,
 	.decl_indent = 16,
-	.else_if = true,
+	.else_if_in_same_line = true,
 	.function_brace_split = true,
 	.format_col1_comments = true,
 	.format_block_comments = true,
@@ -287,7 +287,7 @@ parse_command_line(int argc, char **argv
 	if (opt.local_decl_indent < 0)
 		opt.local_decl_indent = opt.decl_indent;
 	if (opt.decl_comment_column <= 0)
-		opt.decl_comment_column = opt.ljust_decl
+		opt.decl_comment_column = opt.left_justify_decl
 		? (opt.comment_column <= 10 ? 2 : opt.comment_column - 8)
 		: opt.comment_column;
 	if (opt.continuation_indent == 0)
@@ -500,9 +500,7 @@ process_lparen(void)
 		ps.extra_expr_indent = eei_yes;
 
 	if (ps.init_or_struct && ps.tos <= 2) {
-		/* this is a kluge to make sure that declarations will be
-		 * aligned right if proc decl has an explicit type on it, i.e.
-		 * "int a(x) {..." */
+		/* A kludge to correctly align function definitions. */
 		parse(psym_stmt);
 		ps.init_or_struct = false;
 	}
@@ -1241,7 +1239,7 @@ indent(void)
 			return process_eof();
 
 		if (lsym == lsym_if && ps.prev_lsym == lsym_else
-		&& opt.else_if)
+		&& opt.else_if_in_same_line)
 			ps.force_nl = false;
 
 		if (lsym == lsym_newline || lsym == lsym_preprocessing)

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.171 src/usr.bin/indent/indent.h:1.172
--- src/usr.bin/indent/indent.h:1.171	Sun Jun  4 20:51:19 2023
+++ src/usr.bin/indent/indent.h	Mon Jun  5 07:35:05 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.171 2023/06/04 20:51:19 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.172 2023/06/05 07:35:05 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -201,17 +201,16 @@ extern struct options {
 	int comment_column;	/* the column in which comments to the right of
  * code should start */
 	int decl_indent;	/* indentation of identifier in declaration */
-	bool ljust_decl;	/* true if declarations should be left
- * justified */
+	bool left_justify_decl;
 	int unindent_displace;	/* comments not to the right of code will be
  * placed this many indentation levels to the
  * left of code */
 	bool extra_expr_indent;	/* whether continuation lines from the
  * expression part of "if (e)", "while (e)",
  * "for (e; e; e)" should be indented an extra
- * tab stop so that they don't conflict with
+ * tab stop so that they are not confused with
  * the code that follows */
-	bool else_if;		/* whether else-if pairs use the same line */
+	bool else_if_

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

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 08:10:25 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_do.c psym_do.c

Log Message:
tests/indent: add tests for 'do-while' loops


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/lsym_do.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/psym_do.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_do.c
diff -u src/tests/usr.bin/indent/lsym_do.c:1.7 src/tests/usr.bin/indent/lsym_do.c:1.8
--- src/tests/usr.bin/indent/lsym_do.c:1.7	Mon May 22 23:01:27 2023
+++ src/tests/usr.bin/indent/lsym_do.c	Mon Jun  5 08:10:25 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_do.c,v 1.7 2023/05/22 23:01:27 rillig Exp $ */
+/* $NetBSD: lsym_do.c,v 1.8 2023/06/05 08:10:25 rillig Exp $ */
 
 /*
  * Tests for the token lsym_do, which represents the keyword 'do' that starts
@@ -110,3 +110,48 @@ variants(void)
 		} while (0);
 }
 //indent end
+
+
+/* Ensure that the 'do' starts a line. */
+//indent input
+{
+	/* */ do {} while (false);
+
+	word do {} while (false);
+
+	label: do {} while (false);
+}
+//indent end
+
+//indent run
+{
+// $ FIXME: Trailing whitespace.
+	/* */ 
+	do {
+	} while (false);
+
+	word
+	do {
+	} while		(false);
+
+label:	do {
+	} while (false);
+}
+//indent end
+
+//indent run -sob
+{
+// $ FIXME: Trailing whitespace.
+	/* */ 
+	do {
+	} while (false);
+// $ FIXME: This blank line is not optional and must be preserved.
+	word
+	do {
+// $ FIXME: The expression is indented too far to the right.
+	} while		(false);
+// $ FIXME: This blank line is not optional and must be preserved.
+label:	do {
+	} while (false);
+}
+//indent end

Index: src/tests/usr.bin/indent/psym_do.c
diff -u src/tests/usr.bin/indent/psym_do.c:1.4 src/tests/usr.bin/indent/psym_do.c:1.5
--- src/tests/usr.bin/indent/psym_do.c:1.4	Sun Apr 24 10:36:37 2022
+++ src/tests/usr.bin/indent/psym_do.c	Mon Jun  5 08:10:25 2023
@@ -1,8 +1,12 @@
-/* $NetBSD: psym_do.c,v 1.4 2022/04/24 10:36:37 rillig Exp $ */
+/* $NetBSD: psym_do.c,v 1.5 2023/06/05 08:10:25 rillig Exp $ */
 
 /*
  * Tests for the parser symbol psym_do, which represents the state after
  * reading the token 'do', now waiting for the statement of the loop body.
+ *
+ * See also:
+ *	lsym_do.c
+ *	psym_do_stmt.c
  */
 
 //indent input



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

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 08:10:25 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_do.c psym_do.c

Log Message:
tests/indent: add tests for 'do-while' loops


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/lsym_do.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/psym_do.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-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 08:22:01 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_comment.c lsym_do.c t_errors.sh
src/usr.bin/indent: indent.c

Log Message:
indent: fix trailing whitespace after comment


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/lsym_comment.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/lsym_do.c
cvs rdiff -u -r1.32 -r1.33 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.329 -r1.330 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-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 08:22:01 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_comment.c lsym_do.c t_errors.sh
src/usr.bin/indent: indent.c

Log Message:
indent: fix trailing whitespace after comment


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/lsym_comment.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/lsym_do.c
cvs rdiff -u -r1.32 -r1.33 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.329 -r1.330 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_comment.c
diff -u src/tests/usr.bin/indent/lsym_comment.c:1.15 src/tests/usr.bin/indent/lsym_comment.c:1.16
--- src/tests/usr.bin/indent/lsym_comment.c:1.15	Sun May 21 10:18:44 2023
+++ src/tests/usr.bin/indent/lsym_comment.c	Mon Jun  5 08:22:00 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_comment.c,v 1.15 2023/05/21 10:18:44 rillig Exp $ */
+/* $NetBSD: lsym_comment.c,v 1.16 2023/06/05 08:22:00 rillig Exp $ */
 
 /*
  * Tests for the token lsym_comment, which starts a comment.
@@ -734,11 +734,10 @@ while(cond)/*comment*/;
 void
 loop(void)
 {
-	while (cond) /* comment */ ;
+	while (cond) /* comment */;
 
 	while (cond)
-/* $ XXX: The space after the comment looks unintentional. */
-		/* comment */ ;
+		/* comment */;
 }
 //indent end
 
@@ -937,7 +936,7 @@ f(void)
 		/*
 		 * 12 1234 123 123456 1234 1234567 123
 		 * 1234.
-		 */ ;
+		 */;
 }
 //indent end
 
@@ -947,7 +946,7 @@ int
 f(void)
 {
 	if (0)
-		/* 12 1234 123 123456 1234 1234567 123 1234.  */ ;
+		/* 12 1234 123 123456 1234 1234567 123 1234.  */;
 }
 //indent end
 

Index: src/tests/usr.bin/indent/lsym_do.c
diff -u src/tests/usr.bin/indent/lsym_do.c:1.8 src/tests/usr.bin/indent/lsym_do.c:1.9
--- src/tests/usr.bin/indent/lsym_do.c:1.8	Mon Jun  5 08:10:25 2023
+++ src/tests/usr.bin/indent/lsym_do.c	Mon Jun  5 08:22:00 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_do.c,v 1.8 2023/06/05 08:10:25 rillig Exp $ */
+/* $NetBSD: lsym_do.c,v 1.9 2023/06/05 08:22:00 rillig Exp $ */
 
 /*
  * Tests for the token lsym_do, which represents the keyword 'do' that starts
@@ -125,8 +125,7 @@ variants(void)
 
 //indent run
 {
-// $ FIXME: Trailing whitespace.
-	/* */ 
+	/* */
 	do {
 	} while (false);
 
@@ -141,8 +140,7 @@ label:	do {
 
 //indent run -sob
 {
-// $ FIXME: Trailing whitespace.
-	/* */ 
+	/* */
 	do {
 	} while (false);
 // $ FIXME: This blank line is not optional and must be preserved.

Index: src/tests/usr.bin/indent/t_errors.sh
diff -u src/tests/usr.bin/indent/t_errors.sh:1.32 src/tests/usr.bin/indent/t_errors.sh:1.33
--- src/tests/usr.bin/indent/t_errors.sh:1.32	Sun Jun  4 22:20:04 2023
+++ src/tests/usr.bin/indent/t_errors.sh	Mon Jun  5 08:22:00 2023
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_errors.sh,v 1.32 2023/06/04 22:20:04 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.33 2023/06/05 08:22:00 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -468,7 +468,7 @@ crash_comment_after_controlling_expressi
 	cat <<\EOF > code.exp
 {
 	if (expr
-		) /* c */ ;
+		) /* c */;
 }
 EOF
 
@@ -499,7 +499,7 @@ f(void)
 	if (0)
 		/*
 		 * 0123456789012345678901
-		 */ ;
+		 */;
 }
 EOF
 

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.329 src/usr.bin/indent/indent.c:1.330
--- src/usr.bin/indent/indent.c:1.329	Mon Jun  5 07:35:05 2023
+++ src/usr.bin/indent/indent.c	Mon Jun  5 08:22:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.329 2023/06/05 07:35:05 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.330 2023/06/05 08:22:00 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.329 2023/06/05 07:35:05 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.330 2023/06/05 08:22:00 rillig Exp $");
 
 #include 
 #include 
@@ -423,10 +423,8 @@ move_com_to_code(lexer_symbol lsym)
 	if (ps.want_blank)
 		buf_add_char(&code, ' ');
 	buf_add_buf(&code, &com);
-	if (lsym != lsym_rparen && lsym != lsym_rbracket)
-		buf_add_char(&code, ' ');
 	com.len = 0;
-	ps.want_blank = false;
+	ps.want_blank = lsym != lsym_rparen && lsym != lsym_rbracket;
 }
 
 static void



CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 09:10:31 UTC 2023

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

Log Message:
indent: make heuristics for '*' pointer types simpler

Previously, a '}' token did not reset the state machine, but it should.


To generate a diff of this commit:
cvs rdiff -u -r1.330 -r1.331 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/indent.c
diff -u src/usr.bin/indent/indent.c:1.330 src/usr.bin/indent/indent.c:1.331
--- src/usr.bin/indent/indent.c:1.330	Mon Jun  5 08:22:00 2023
+++ src/usr.bin/indent/indent.c	Mon Jun  5 09:10:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.330 2023/06/05 08:22:00 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.331 2023/06/05 09:10:31 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.330 2023/06/05 08:22:00 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.331 2023/06/05 09:10:31 rillig Exp $");
 
 #include 
 #include 
@@ -336,38 +336,20 @@ code_add_decl_indent(int decl_ind, bool 
 static void
 update_ps_decl_ptr(lexer_symbol lsym)
 {
-	switch (ps.decl_ptr) {
-	case dp_start:
-		if (lsym == lsym_modifier)
-			ps.decl_ptr = dp_start;
-		else if (lsym == lsym_type_outside_parentheses)
-			ps.decl_ptr = dp_word;
-		else if (lsym == lsym_word)
-			ps.decl_ptr = dp_word;
-		else
-			ps.decl_ptr = dp_other;
-		break;
-	case dp_word:
-		if (lsym == lsym_unary_op && token.s[0] == '*')
-			ps.decl_ptr = dp_word_asterisk;
-		else
-			ps.decl_ptr = dp_other;
-		break;
-	case dp_word_asterisk:
-		if (lsym == lsym_unary_op && token.s[0] == '*')
-			ps.decl_ptr = dp_word_asterisk;
-		else
-			ps.decl_ptr = dp_other;
-		break;
-	case dp_other:
-		if (lsym == lsym_semicolon || lsym == lsym_rbrace)
-			ps.decl_ptr = dp_start;
-		if (lsym == lsym_lparen && ps.prev_lsym != lsym_sizeof)
-			ps.decl_ptr = dp_start;
-		if (lsym == lsym_comma && ps.in_decl)
-			ps.decl_ptr = dp_start;
-		break;
-	}
+	if (lsym == lsym_semicolon
+	|| lsym == lsym_lbrace
+	|| lsym == lsym_rbrace
+	|| (lsym == lsym_lparen && ps.prev_lsym != lsym_sizeof)
+	|| (lsym == lsym_comma && ps.in_decl)
+	|| lsym == lsym_modifier)
+		ps.decl_ptr = dp_start;
+	else if (ps.decl_ptr == dp_start && lsym == lsym_word)
+		ps.decl_ptr = dp_word;
+	else if ((ps.decl_ptr == dp_word || ps.decl_ptr == dp_word_asterisk)
+	&& (lsym == lsym_unary_op && token.s[0] == '*'))
+		ps.decl_ptr = dp_word_asterisk;
+	else
+		ps.decl_ptr = dp_other;
 }
 
 static void



CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 09:10:31 UTC 2023

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

Log Message:
indent: make heuristics for '*' pointer types simpler

Previously, a '}' token did not reset the state machine, but it should.


To generate a diff of this commit:
cvs rdiff -u -r1.330 -r1.331 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-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 09:41:40 UTC 2023

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

Log Message:
indent: fix formatting of 'do' statements


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/lsym_do.c
cvs rdiff -u -r1.331 -r1.332 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.195 -r1.196 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

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 09:41:40 UTC 2023

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

Log Message:
indent: fix formatting of 'do' statements


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/lsym_do.c
cvs rdiff -u -r1.331 -r1.332 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.195 -r1.196 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/lsym_do.c
diff -u src/tests/usr.bin/indent/lsym_do.c:1.9 src/tests/usr.bin/indent/lsym_do.c:1.10
--- src/tests/usr.bin/indent/lsym_do.c:1.9	Mon Jun  5 08:22:00 2023
+++ src/tests/usr.bin/indent/lsym_do.c	Mon Jun  5 09:41:40 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_do.c,v 1.9 2023/06/05 08:22:00 rillig Exp $ */
+/* $NetBSD: lsym_do.c,v 1.10 2023/06/05 09:41:40 rillig Exp $ */
 
 /*
  * Tests for the token lsym_do, which represents the keyword 'do' that starts
@@ -131,25 +131,11 @@ variants(void)
 
 	word
 	do {
-	} while		(false);
-
-label:	do {
 	} while (false);
-}
-//indent end
 
-//indent run -sob
-{
-	/* */
-	do {
-	} while (false);
-// $ FIXME: This blank line is not optional and must be preserved.
-	word
-	do {
-// $ FIXME: The expression is indented too far to the right.
-	} while		(false);
-// $ FIXME: This blank line is not optional and must be preserved.
 label:	do {
 	} while (false);
 }
 //indent end
+
+//indent run-equals-prev-output -sob

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.331 src/usr.bin/indent/indent.c:1.332
--- src/usr.bin/indent/indent.c:1.331	Mon Jun  5 09:10:31 2023
+++ src/usr.bin/indent/indent.c	Mon Jun  5 09:41:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.331 2023/06/05 09:10:31 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.332 2023/06/05 09:41:40 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.331 2023/06/05 09:10:31 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.332 2023/06/05 09:41:40 rillig Exp $");
 
 #include 
 #include 
@@ -846,6 +846,7 @@ static void
 process_do(void)
 {
 	ps.in_stmt_or_decl = false;
+	ps.in_decl = false;
 
 	if (code.len > 0) {	/* make sure this starts a line */
 		if (opt.verbose)

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.195 src/usr.bin/indent/io.c:1.196
--- src/usr.bin/indent/io.c:1.195	Mon Jun  5 07:23:03 2023
+++ src/usr.bin/indent/io.c	Mon Jun  5 09:41:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.195 2023/06/05 07:23:03 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.196 2023/06/05 09:41:40 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.195 2023/06/05 07:23:03 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.196 2023/06/05 09:41:40 rillig Exp $");
 
 #include 
 
@@ -169,7 +169,8 @@ want_blank_line(void)
 static bool
 is_blank_line_optional(void)
 {
-	if (out.prev_line_kind == lk_stmt_head)
+	if (out.prev_line_kind == lk_stmt_head
+	&& ps.prev_lsym != lsym_semicolon)
 		return wrote_newlines >= 1;
 	if (ps.tos >= 2)
 		return wrote_newlines >= 2;



CVS commit: src

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 10:12:21 UTC 2023

Modified Files:
src/tests/usr.bin/indent: opt_v.c t_misc.sh
src/usr.bin/indent: args.c indent.1 indent.c indent.h

Log Message:
indent: do not report broken lines, report configuration on stderr


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/opt_v.c
cvs rdiff -u -r1.26 -r1.27 src/tests/usr.bin/indent/t_misc.sh
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/indent/args.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/indent/indent.1
cvs rdiff -u -r1.332 -r1.333 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.172 -r1.173 src/usr.bin/indent/indent.h

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



CVS commit: src

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 10:12:21 UTC 2023

Modified Files:
src/tests/usr.bin/indent: opt_v.c t_misc.sh
src/usr.bin/indent: args.c indent.1 indent.c indent.h

Log Message:
indent: do not report broken lines, report configuration on stderr


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/opt_v.c
cvs rdiff -u -r1.26 -r1.27 src/tests/usr.bin/indent/t_misc.sh
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/indent/args.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/indent/indent.1
cvs rdiff -u -r1.332 -r1.333 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.172 -r1.173 src/usr.bin/indent/indent.h

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_v.c
diff -u src/tests/usr.bin/indent/opt_v.c:1.12 src/tests/usr.bin/indent/opt_v.c:1.13
--- src/tests/usr.bin/indent/opt_v.c:1.12	Fri May 12 10:53:33 2023
+++ src/tests/usr.bin/indent/opt_v.c	Mon Jun  5 10:12:21 2023
@@ -1,18 +1,12 @@
-/* $NetBSD: opt_v.c,v 1.12 2023/05/12 10:53:33 rillig Exp $ */
+/* $NetBSD: opt_v.c,v 1.13 2023/06/05 10:12:21 rillig Exp $ */
 
 /*
  * Tests for the options '-v' and '-nv'.
  *
- * The option '-v' enables verbose mode. It outputs some information about
- * what's going on under the hood, especially when lines are broken.
+ * The option '-v' enables verbose mode.
  *
  * The option '-nv' disables verbose mode. Only errors and warnings are output
- * in this mode, but no progress messages.
- */
-
-/*
- * XXX: It's rather strange that -v writes to stdout, even in filter mode.
- * This output belongs on stderr instead.
+ * in this mode.
  */
 
 //indent input
@@ -25,10 +19,10 @@ example(void)
 	printf("A very long message template with %d arguments: %s, %s, %s", 3, "first", "second", "third");
 }
 
-/* $ The below comment is neither counted nor formatted. */
+// $ Indent does not format comments in preprocessing lines.
 #define macro1 /* prefix */ suffix
 
-/* $ The below comment is formatted and counted. */
+// $ Indent does not format comments in preprocessing lines.
 #define macro2 prefix /* suffix */
 //indent end
 

Index: src/tests/usr.bin/indent/t_misc.sh
diff -u src/tests/usr.bin/indent/t_misc.sh:1.26 src/tests/usr.bin/indent/t_misc.sh:1.27
--- src/tests/usr.bin/indent/t_misc.sh:1.26	Mon Jun  5 07:23:03 2023
+++ src/tests/usr.bin/indent/t_misc.sh	Mon Jun  5 10:12:21 2023
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_misc.sh,v 1.26 2023/06/05 07:23:03 rillig Exp $
+# $NetBSD: t_misc.sh,v 1.27 2023/06/05 10:12:21 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -81,7 +81,7 @@ verbose_profile_body()
 	cat <<-\EOF > after.c.exp
 		int		decl;
 	EOF
-	cat <<-\EOF > stdout.exp
+	cat <<-\EOF > stderr.exp
 		profile: -fc1
 		profile: -bacc
 		profile: -v
@@ -96,7 +96,7 @@ verbose_profile_body()
 	# is listed because when running ATF, $HOME equals $PWD.
 
 	atf_check \
-	-o 'file:stdout.exp' \
+	-e 'file:stderr.exp' \
 	"$indent" -v before.c after.c
 	atf_check \
 	 -o 'file:after.c.exp' \
@@ -401,7 +401,7 @@ opt_v_break_line_body()
 {
 	printf '%s\n' 'int *function(void)' '{}' > code.c
 
-	atf_check -o 'ignore' -e 'inline:warning: code.c:2: Line broken\n' \
+	atf_check -o 'ignore' \
 	"$indent" -v code.c -st
 }
 

Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.81 src/usr.bin/indent/args.c:1.82
--- src/usr.bin/indent/args.c:1.81	Mon Jun  5 07:35:05 2023
+++ src/usr.bin/indent/args.c	Mon Jun  5 10:12:21 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.81 2023/06/05 07:35:05 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.82 2023/06/05 10:12:21 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: args.c,v 1.81 2023/06/05 07:35:05 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.82 2023/06/05 10:12:21 rillig Exp $");
 
 /* Read options from profile files and from the command line. */
 
@@ -290,7 +290,7 @@ load_profile(const char *fname, bool mus
 		if (n > 0) {
 			buf[n] = '\0';
 			if (opt.verbose)
-printf("profile: %s\n", buf);
+fprintf(stderr, "profile: %s\n", buf);
 			set_option(buf, fname);
 		} else if (ch == EOF)
 			break;

Index: src/usr.bin/indent/indent.1
diff -u src/usr.bin/indent/indent.1:1.31 src/usr.bin/indent/indent.1:1.32
--- src/usr.bin/indent/indent.1:1.31	Fri May 12 11:01:11 2023
+++ src/usr.bin/indent/indent.1	Mon Jun  5 10:12:21 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: indent.1,v 1.31 2023/05/12 11:01:11 rillig Exp $
+.\"	$NetBSD: indent.1,v 1.32 2023/06/05 10:12:21 rillig Exp $
 .\"
 .\" Copyright (c) 1980, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"	@(#)indent.1	8.1 (Berkeley) 7/1/93
 .\" $FreeBSD: head/usr.bin/indent/indent.1 334944 2018-06-11 05:35:57Z pstef $
 .\"
-.Dd May 12, 2023
+.Dd June 5, 2023
 .Dt INDENT 1
 .Os
 .Sh NAME

CVS commit: src/etc/rc.d

2023-06-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun  5 11:51:20 UTC 2023

Modified Files:
src/etc/rc.d: sshd

Log Message:
/etc/rc.d/sshd: Stop generating DSA host keys by default.

If you want them you can generate them yourself, but in this day and
age (Monday and 2023, specifically) there's no reason to be using DSA
except for compatibility with ancient legacy software.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/etc/rc.d/sshd

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



CVS commit: src/etc/rc.d

2023-06-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun  5 11:51:20 UTC 2023

Modified Files:
src/etc/rc.d: sshd

Log Message:
/etc/rc.d/sshd: Stop generating DSA host keys by default.

If you want them you can generate them yourself, but in this day and
age (Monday and 2023, specifically) there's no reason to be using DSA
except for compatibility with ancient legacy software.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/etc/rc.d/sshd

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

Modified files:

Index: src/etc/rc.d/sshd
diff -u src/etc/rc.d/sshd:1.33 src/etc/rc.d/sshd:1.34
--- src/etc/rc.d/sshd:1.33	Fri May 26 10:44:59 2023
+++ src/etc/rc.d/sshd	Mon Jun  5 11:51:19 2023
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: sshd,v 1.33 2023/05/26 10:44:59 riastradh Exp $
+# $NetBSD: sshd,v 1.34 2023/06/05 11:51:19 riastradh Exp $
 #
 
 # PROVIDE: sshd
@@ -61,7 +61,6 @@ sshd_keygen()
 		printf "ssh-keygen: " && "${keygen}" -f "${f}" -l
 		new_key_created=true
 	done << _EOF
-dsa	1024	ssh_host_dsa_key
 ecdsa	521	ssh_host_ecdsa_key
 ed25519	-1	ssh_host_ed25519_key
 rsa	0	ssh_host_rsa_key



CVS commit: src/etc/rc.d

2023-06-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun  5 11:59:13 UTC 2023

Modified Files:
src/etc/rc.d: sshd

Log Message:
/etc/rc.d/sshd: Use default curve for ECDSA keygen, not NIST P-521.

The default is NIST P-256, which:

(a) has plenty of cryptanalytic security,
(b) performs better on essentially all platforms (smaller enough that
even the advantage of the Mersenne prime structure of P-521 can't
compete), and
(c) likely gets more scrutiny on implementations than P-521 since it's
more widespread.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/etc/rc.d/sshd

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

Modified files:

Index: src/etc/rc.d/sshd
diff -u src/etc/rc.d/sshd:1.34 src/etc/rc.d/sshd:1.35
--- src/etc/rc.d/sshd:1.34	Mon Jun  5 11:51:19 2023
+++ src/etc/rc.d/sshd	Mon Jun  5 11:59:12 2023
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: sshd,v 1.34 2023/06/05 11:51:19 riastradh Exp $
+# $NetBSD: sshd,v 1.35 2023/06/05 11:59:12 riastradh Exp $
 #
 
 # PROVIDE: sshd
@@ -61,7 +61,7 @@ sshd_keygen()
 		printf "ssh-keygen: " && "${keygen}" -f "${f}" -l
 		new_key_created=true
 	done << _EOF
-ecdsa	521	ssh_host_ecdsa_key
+ecdsa	-1	ssh_host_ecdsa_key
 ed25519	-1	ssh_host_ed25519_key
 rsa	0	ssh_host_rsa_key
 _EOF



CVS commit: src/etc/rc.d

2023-06-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun  5 11:59:13 UTC 2023

Modified Files:
src/etc/rc.d: sshd

Log Message:
/etc/rc.d/sshd: Use default curve for ECDSA keygen, not NIST P-521.

The default is NIST P-256, which:

(a) has plenty of cryptanalytic security,
(b) performs better on essentially all platforms (smaller enough that
even the advantage of the Mersenne prime structure of P-521 can't
compete), and
(c) likely gets more scrutiny on implementations than P-521 since it's
more widespread.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/etc/rc.d/sshd

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



CVS commit: src

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 12:01:34 UTC 2023

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

Log Message:
indent: don't remove blank line after 'if (expr) {'


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/opt_sob.c
cvs rdiff -u -r1.333 -r1.334 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.196 -r1.197 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

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 12:01:34 UTC 2023

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

Log Message:
indent: don't remove blank line after 'if (expr) {'


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/opt_sob.c
cvs rdiff -u -r1.333 -r1.334 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.196 -r1.197 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/opt_sob.c
diff -u src/tests/usr.bin/indent/opt_sob.c:1.9 src/tests/usr.bin/indent/opt_sob.c:1.10
--- src/tests/usr.bin/indent/opt_sob.c:1.9	Fri Jun  2 13:59:33 2023
+++ src/tests/usr.bin/indent/opt_sob.c	Mon Jun  5 12:01:34 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_sob.c,v 1.9 2023/06/02 13:59:33 rillig Exp $ */
+/* $NetBSD: opt_sob.c,v 1.10 2023/06/05 12:01:34 rillig Exp $ */
 
 /*
  * Tests for the options '-sob' and '-nsob'.
@@ -115,8 +115,8 @@ function_with_1_blank_line(void)
 		var--;
 
 	if (var > 0) {
+
 		var--;
-// $ XXX: The following blank line may be considered optional.
 
 	}
 
@@ -137,8 +137,8 @@ function_with_2_blank_lines(void)
 		var--;
 
 	if (var > 0) {
+
 		var--;
-// $ XXX: The following blank line may be considered optional.
 
 	}
 
@@ -148,3 +148,27 @@ function_with_2_blank_lines(void)
 //indent end
 
 //indent run-equals-input -nsob
+
+
+//indent input
+{
+	switch (expr) {
+
+	case 1:
+
+	}
+}
+//indent end
+
+//indent run-equals-input -sob
+
+//indent run -sob -bl
+{
+	switch (expr)
+	{
+
+	case 1:
+
+	}
+}
+//indent end

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.333 src/usr.bin/indent/indent.c:1.334
--- src/usr.bin/indent/indent.c:1.333	Mon Jun  5 10:12:21 2023
+++ src/usr.bin/indent/indent.c	Mon Jun  5 12:01:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.333 2023/06/05 10:12:21 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.334 2023/06/05 12:01:33 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.333 2023/06/05 10:12:21 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.334 2023/06/05 12:01:33 rillig Exp $");
 
 #include 
 #include 
@@ -682,6 +682,8 @@ process_colon_other(void)
 static void
 process_semicolon(void)
 {
+	if (out.line_kind == lk_stmt_head)
+		out.line_kind = lk_other;
 	if (ps.decl_level == 0)
 		ps.init_or_struct = false;
 	ps.seen_case = false;	/* only needs to be reset on error */
@@ -737,6 +739,9 @@ process_lbrace(void)
 		ps.init_or_struct = true;
 	}
 
+	if (out.line_kind == lk_stmt_head)
+		out.line_kind = lk_other;
+
 	ps.in_stmt_or_decl = false;	/* don't indent the {} */
 
 	if (!ps.block_init)

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.196 src/usr.bin/indent/io.c:1.197
--- src/usr.bin/indent/io.c:1.196	Mon Jun  5 09:41:40 2023
+++ src/usr.bin/indent/io.c	Mon Jun  5 12:01:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.196 2023/06/05 09:41:40 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.197 2023/06/05 12:01:33 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.196 2023/06/05 09:41:40 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.197 2023/06/05 12:01:33 rillig Exp $");
 
 #include 
 
@@ -169,8 +169,7 @@ want_blank_line(void)
 static bool
 is_blank_line_optional(void)
 {
-	if (out.prev_line_kind == lk_stmt_head
-	&& ps.prev_lsym != lsym_semicolon)
+	if (out.prev_line_kind == lk_stmt_head)
 		return wrote_newlines >= 1;
 	if (ps.tos >= 2)
 		return wrote_newlines >= 2;



CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 12:05:01 UTC 2023

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

Log Message:
indent: format own source code


To generate a diff of this commit:
cvs rdiff -u -r1.334 -r1.335 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.173 -r1.174 src/usr.bin/indent/indent.h

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-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 12:05:01 UTC 2023

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

Log Message:
indent: format own source code


To generate a diff of this commit:
cvs rdiff -u -r1.334 -r1.335 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.173 -r1.174 src/usr.bin/indent/indent.h

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.334 src/usr.bin/indent/indent.c:1.335
--- src/usr.bin/indent/indent.c:1.334	Mon Jun  5 12:01:33 2023
+++ src/usr.bin/indent/indent.c	Mon Jun  5 12:05:01 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.334 2023/06/05 12:01:33 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.335 2023/06/05 12:05:01 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.334 2023/06/05 12:01:33 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.335 2023/06/05 12:05:01 rillig Exp $");
 
 #include 
 #include 
@@ -413,7 +413,7 @@ process_newline(void)
 	if (ps.prev_lsym == lsym_comma
 	&& ps.nparen == 0 && !ps.block_init
 	&& !opt.break_after_comma && ps.break_after_comma
-	&& lab.len == 0 /* for preprocessing lines */
+	&& lab.len == 0	/* for preprocessing lines */
 	&& com.len == 0)
 		goto stay_in_line;
 	if (ps.s_sym[ps.tos] == psym_switch_expr && opt.brace_same_line) {
@@ -1167,7 +1167,7 @@ process_lsym(lexer_symbol lsym)
 	case lsym_funcname:
 	case lsym_return:
 		process_ident(lsym);
-	copy_token:
+copy_token:
 		if (ps.want_blank)
 			buf_add_char(&code, ' ');
 		buf_add_buf(&code, &token);

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.173 src/usr.bin/indent/indent.h:1.174
--- src/usr.bin/indent/indent.h:1.173	Mon Jun  5 10:12:21 2023
+++ src/usr.bin/indent/indent.h	Mon Jun  5 12:05:01 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.173 2023/06/05 10:12:21 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.174 2023/06/05 12:05:01 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -89,7 +89,7 @@ typedef enum lexer_symbol {
 	lsym_colon_other,	/* bit-fields, generic-association (C11),
  * enum-type-specifier (C23),
  * attribute-prefixed-token (C23),
- * pp-prefixed-parameter (C23 6.10)*/
+ * pp-prefixed-parameter (C23 6.10) */
 	lsym_comma,
 	lsym_semicolon,
 	lsym_typedef,
@@ -320,8 +320,8 @@ extern struct parser_state {
  * processing of braces is then slightly
  * different */
 	bool in_func_def_params;
-	bool seen_case;		/* whether there was a 'case' or 'default',
- * to properly space the following ':' */
+	bool seen_case;		/* whether there was a 'case' or 'default', to
+ * properly space the following ':' */
 	parser_symbol spaced_expr_psym;	/* the parser symbol to be shifted
 	 * after the parenthesized expression
 	 * from a 'for', 'if', 'switch' or
@@ -374,13 +374,13 @@ extern struct parser_state {
  * remaining lines of the statement,
  * initializer or declaration */
 	enum {
-	dp_start,		/* the beginning of a declaration */
-	dp_word,		/* seen a type name */
-	dp_word_asterisk,	/* seen a type name and some '*' */
-	dp_other,
-	} decl_ptr;		/* detects declarations like 'typename *x',
- * to prevent the '*' from being interpreted as
- * a binary operator */
+		dp_start,	/* the beginning of a declaration */
+		dp_word,	/* seen a type name */
+		dp_word_asterisk,	/* seen a type name and some '*' */
+		dp_other,
+	} decl_ptr;		/* detects declarations like 'typename *x', to
+ * prevent the '*' from being interpreted as a
+ * binary operator */
 	paren_level_props paren[20];
 
 	/* Horizontal spacing for comments */



CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 12:06:51 UTC 2023

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

Log Message:
indent: clean up comments


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 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.197 src/usr.bin/indent/io.c:1.198
--- src/usr.bin/indent/io.c:1.197	Mon Jun  5 12:01:33 2023
+++ src/usr.bin/indent/io.c	Mon Jun  5 12:06:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.197 2023/06/05 12:01:33 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.198 2023/06/05 12:06:51 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.197 2023/06/05 12:01:33 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.198 2023/06/05 12:06:51 rillig Exp $");
 
 #include 
 
@@ -240,8 +240,6 @@ output_line_comment(void)
 /*
  * Write a line of formatted source to the output file. The line consists of
  * the label, the code and the comment.
- *
- * Comments are written directly, bypassing this function.
  */
 void
 output_line(void)
@@ -260,9 +258,9 @@ output_line(void)
 		&& out.line_kind != lk_blank)
 			output_newline();
 
+		/* This kludge aligns function definitions correctly. */
 		if (ps.ind_level == 0)
-			ps.in_stmt_cont = false;	/* this is a class A
-			 * kludge */
+			ps.in_stmt_cont = false;
 
 		if (opt.blank_line_after_decl && ps.declaration == decl_end
 		&& ps.tos > 1) {



CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 12:06:51 UTC 2023

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

Log Message:
indent: clean up comments


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 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/sys/arch/amd64/conf

2023-06-05 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jun  5 13:59:55 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: NOCOMPAT

Log Message:
Un-comment the ident line


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/conf/NOCOMPAT

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



CVS commit: src/sys/arch/amd64/conf

2023-06-05 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jun  5 13:59:55 UTC 2023

Modified Files:
src/sys/arch/amd64/conf: NOCOMPAT

Log Message:
Un-comment the ident line


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/conf/NOCOMPAT

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/amd64/conf/NOCOMPAT
diff -u src/sys/arch/amd64/conf/NOCOMPAT:1.6 src/sys/arch/amd64/conf/NOCOMPAT:1.7
--- src/sys/arch/amd64/conf/NOCOMPAT:1.6	Wed Jan 20 21:38:44 2021
+++ src/sys/arch/amd64/conf/NOCOMPAT	Mon Jun  5 13:59:54 2023
@@ -1,6 +1,6 @@
 include "arch/amd64/conf/GENERIC"
 
-#ident		"NOCOMPAT-$Revision: 1.6 $"
+ident		"NOCOMPAT-$Revision: 1.7 $"
 
 no options 	SYSVMSG		# System V-like message queues
 no options 	SYSVSEM		# System V-like semaphores



CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 14:22:26 UTC 2023

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

Log Message:
indent: sync debug output with parser state


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.174 -r1.175 src/usr.bin/indent/indent.h

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-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 14:22:26 UTC 2023

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

Log Message:
indent: sync debug output with parser state


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.174 -r1.175 src/usr.bin/indent/indent.h

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.34 src/usr.bin/indent/debug.c:1.35
--- src/usr.bin/indent/debug.c:1.34	Sun Jun  4 20:51:19 2023
+++ src/usr.bin/indent/debug.c	Mon Jun  5 14:22:26 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.34 2023/06/04 20:51:19 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.35 2023/06/05 14:22:26 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.34 2023/06/04 20:51:19 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.35 2023/06/05 14:22:26 rillig Exp $");
 
 #include 
 
@@ -129,6 +129,12 @@ const char *const line_kind_name[] = {
 	"case/default",
 };
 
+static const char *const extra_expr_indent_name[] = {
+	"no",
+	"yes",
+	"last",
+};
+
 static const char *const decl_ptr_name[] = {
 	"start",
 	"word",
@@ -290,51 +296,58 @@ debug_parser_state(void)
 	static struct parser_state prev_ps;
 
 	debug_blank_line();
-	debug_println("   ps.prev_lsym = %s",
-	lsym_name[ps.prev_lsym]);
-	debug_ps_bool(curr_col_1);
-	debug_ps_bool(next_col_1);
-	debug_ps_bool(next_unary);
-	debug_ps_bool(is_function_definition);
-	debug_ps_bool(want_blank);
-	debug_ps_bool(break_after_comma);
-	debug_ps_bool(force_nl);
-	debug_ps_int(line_start_nparen);
-	debug_ps_int(nparen);
-	debug_ps_paren(&prev_ps);
-
-	debug_ps_int(comment_delta);
-	debug_ps_int(n_comment_delta);
-	debug_ps_int(com_ind);
+	debug_println("   ps.prev_lsym = %s", lsym_name[ps.prev_lsym]);
 
+	debug_println("token classification");
+	debug_ps_int(quest_level);
+	debug_ps_bool(is_function_definition);
 	debug_ps_bool(block_init);
 	debug_ps_int(block_init_level);
 	debug_ps_bool(init_or_struct);
+	debug_ps_bool(decl_on_line);
+	debug_ps_bool(in_stmt_or_decl);
+	debug_ps_bool(in_decl);
+	debug_ps_bool(in_func_def_params);
+	debug_ps_bool(seen_case);
+	debug_ps_enum(spaced_expr_psym, psym_name);
+	debug_ps_enum(lbrace_kind, psym_name);
 
+	debug_println("indentation of statements and declarations");
 	debug_ps_int(ind_level);
 	debug_ps_int(ind_level_follow);
-
+	debug_ps_bool(in_stmt_cont);
 	debug_ps_int(decl_level);
 	debug_ps_di_stack(&prev_ps);
-	debug_ps_bool(decl_on_line);
-	debug_ps_bool(in_decl);
-	debug_ps_enum(declaration, declaration_name);
-	debug_ps_bool(blank_line_after_decl);
-	debug_ps_bool(in_func_def_params);
-	debug_ps_enum(lbrace_kind, psym_name);
-	debug_ps_enum(decl_ptr, decl_ptr_name);
 	debug_ps_bool(decl_indent_done);
 	debug_ps_int(decl_ind);
 	debug_ps_bool(tabs_to_var);
+	debug_ps_enum(extra_expr_indent, extra_expr_indent_name);
 
-	debug_ps_bool(in_stmt_or_decl);
-	debug_ps_bool(in_stmt_cont);
-	debug_ps_bool(seen_case);
+	// The parser symbol stack is printed in debug_parse_stack instead.
 
-	// The debug output for the parser symbols is done in 'parse' instead.
+	debug_println("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(nparen);
+	debug_ps_paren(&prev_ps);
+	debug_ps_enum(decl_ptr, decl_ptr_name);
+
+	debug_println("horizontal spacing for comments");
+	debug_ps_int(comment_delta);
+	debug_ps_int(n_comment_delta);
+	debug_ps_int(com_ind);
+
+	debug_println("vertical spacing");
+	debug_ps_bool(break_after_comma);
+	debug_ps_bool(force_nl);
+	debug_ps_enum(declaration, declaration_name);
+	debug_ps_bool(blank_line_after_decl);
+
+	debug_println("comments");
+	debug_ps_bool(curr_col_1);
+	debug_ps_bool(next_col_1);
 
-	debug_ps_enum(spaced_expr_psym, psym_name);
-	debug_ps_int(quest_level);
 	debug_blank_line();
 
 	prev_ps = ps;
@@ -345,7 +358,7 @@ debug_parse_stack(const char *situation)
 {
 	printf("parse stack %s:", situation);
 	for (int i = 0; i <= ps.tos; ++i)
-		printf(" %s %d", psym_name[ps.s_sym[i]], ps.s_ind_level[i]);
+		printf(" %d %s", ps.s_ind_level[i], psym_name[ps.s_sym[i]]);
 	printf("\n");
 }
 #endif

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.174 src/usr.bin/indent/indent.h:1.175
--- src/usr.bin/indent/indent.h:1.174	Mon Jun  5 12:05:01 2023
+++ src/usr.bin/indent/indent.h	Mon Jun  5 14:22:26 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.174 2023/06/05 12:05:01 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.175 2023/06/05 14:22:26 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -373,6 +373,7 @@ extern struct parser_state {
  * are currently open; used to indent the
  * remaining lines of the statement,
  * initi

CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 14:40:14 UTC 2023

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

Log Message:
indent: improve layout of debug output


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 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/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 14:40:14 UTC 2023

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

Log Message:
indent: improve layout of debug output


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 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.35 src/usr.bin/indent/debug.c:1.36
--- src/usr.bin/indent/debug.c:1.35	Mon Jun  5 14:22:26 2023
+++ src/usr.bin/indent/debug.c	Mon Jun  5 14:40:13 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.35 2023/06/05 14:22:26 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.36 2023/06/05 14:40:13 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.35 2023/06/05 14:22:26 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.36 2023/06/05 14:40:13 rillig Exp $");
 
 #include 
 
@@ -87,11 +87,11 @@ const char *const lsym_name[] = {
 
 const char *const psym_name[] = {
 	"-",
-	"lbrace_block",
-	"lbrace_struct",
-	"lbrace_union",
-	"lbrace_enum",
-	"rbrace",
+	"{block",
+	"{struct",
+	"{union",
+	"{enum",
+	"}",
 	"decl",
 	"stmt",
 	"stmt_list",
@@ -217,21 +217,21 @@ debug_buffers(void)
 
 #define debug_ps_bool(name) \
 	if (ps.name != prev_ps.name) \
-	debug_println("[%c] -> [%c] ps." #name, \
-		prev_ps.name ? 'x' : ' ', ps.name ? 'x' : ' '); \
+	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' : ' ')
+	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); \
+	debug_println(" %3d -> %3d  ps." #name, prev_ps.name, ps.name); \
 	else if (debug_full_parser_state) \
-	debug_println("   %3d ps." #name, ps.name)
+	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, \
+	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])
+	debug_println(" %10s  ps." #name, (names)[ps.name])
 
 static bool
 ps_paren_has_changed(const struct parser_state *prev_ps)
@@ -253,7 +253,7 @@ debug_ps_paren(const struct parser_state
 	if (!debug_full_parser_state && !ps_paren_has_changed(prev_ps))
 		return;
 
-	debug_printf("   ps.paren:");
+	debug_printf(" ps.paren:");
 	for (int i = 0; i < ps.nparen; i++) {
 		debug_printf(" %s%d",
 		paren_level_cast_name[ps.paren[i].cast],
@@ -282,7 +282,7 @@ debug_ps_di_stack(const struct parser_st
 	if (!debug_full_parser_state && !changed)
 		return;
 
-	debug_printf("%s ps.di_stack:", changed ? "->" : "  ");
+	debug_printf(" %s  ps.di_stack:", changed ? "->" : "  ");
 	for (int i = 0; i < ps.decl_level; i++)
 		debug_printf(" %d", ps.di_stack[i]);
 	if (ps.decl_level == 0)
@@ -296,7 +296,8 @@ debug_parser_state(void)
 	static struct parser_state prev_ps;
 
 	debug_blank_line();
-	debug_println("   ps.prev_lsym = %s", lsym_name[ps.prev_lsym]);
+	debug_println(" ps.prev_lsym = %s",
+	lsym_name[ps.prev_lsym]);
 
 	debug_println("token classification");
 	debug_ps_int(quest_level);



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

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 15:02:54 UTC 2023

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

Log Message:
tests/indent: add test for left-justifying declarations


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/opt_dj.c

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



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

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 15:02:54 UTC 2023

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

Log Message:
tests/indent: add test for left-justifying declarations


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/opt_dj.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.48 src/tests/usr.bin/indent/fmt_decl.c:1.49
--- src/tests/usr.bin/indent/fmt_decl.c:1.48	Fri Jun  2 14:34:14 2023
+++ src/tests/usr.bin/indent/fmt_decl.c	Mon Jun  5 15:02:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmt_decl.c,v 1.48 2023/06/02 14:34:14 rillig Exp $	*/
+/*	$NetBSD: fmt_decl.c,v 1.49 2023/06/05 15:02:54 rillig Exp $	*/
 
 /*
  * Tests for declarations of global variables, external functions, and local
@@ -974,3 +974,21 @@ void
 {
 }
 //indent end
+
+
+//indent input
+struct a {
+	struct b {
+		struct c {
+			struct d1 {
+int e;
+			} d1;
+			struct d2 {
+int e;
+			} d2;
+		} c;
+	} b;
+};
+//indent end
+
+//indent run-equals-input -di0

Index: src/tests/usr.bin/indent/opt_dj.c
diff -u src/tests/usr.bin/indent/opt_dj.c:1.7 src/tests/usr.bin/indent/opt_dj.c:1.8
--- src/tests/usr.bin/indent/opt_dj.c:1.7	Sun Apr 24 09:04:12 2022
+++ src/tests/usr.bin/indent/opt_dj.c	Mon Jun  5 15:02:54 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_dj.c,v 1.7 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: opt_dj.c,v 1.8 2023/06/05 15:02:54 rillig Exp $ */
 
 /*
  * Tests for the options '-dj' and '-ndj'.
@@ -76,3 +76,77 @@ dbl_plus3(a, b, c)
 	return a + b + c;
 }
 //indent end
+
+
+//indent input
+struct a {
+	struct b {
+		struct c {
+			struct d1 {
+int e;
+			} d1;
+			struct d2 {
+int e;
+			} d2;
+		} c;
+	} b;
+};
+//indent end
+
+//indent run -d0
+struct a {
+	struct b {
+		struct c {
+			struct d1 {
+int		e;
+			}		d1;
+			struct d2 {
+int		e;
+			}		d2;
+		}		c;
+	}		b;
+};
+//indent end
+
+//indent run-equals-input -di0
+
+//indent run-equals-prev-output -dj
+
+
+//indent input
+{
+	{
+		struct a {
+			struct b {
+struct c {
+	struct d1 {
+		int e;
+	} d1;
+	struct d2 {
+		int e;
+	} d2;
+} c;
+			} b;
+		};
+	}
+}
+//indent end
+
+//indent run -dj
+{
+	{
+struct a {
+	struct b {
+		struct c {
+			struct d1 {
+int		e;
+			}		d1;
+			struct d2 {
+int		e;
+			}		d2;
+		}		c;
+	}		b;
+};
+	}
+}
+//indent end



CVS commit: src/sys/dev/audio

2023-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Jun  5 16:26:05 UTC 2023

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
We cannot handle input with precision != stride yet.
Drain input buffer for unhandled input.


To generate a diff of this commit:
cvs rdiff -u -r1.143 -r1.144 src/sys/dev/audio/audio.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/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.143 src/sys/dev/audio/audio.c:1.144
--- src/sys/dev/audio/audio.c:1.143	Sun Apr 23 08:53:08 2023
+++ src/sys/dev/audio/audio.c	Mon Jun  5 16:26:05 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.143 2023/04/23 08:53:08 mlelstv Exp $	*/
+/*	$NetBSD: audio.c,v 1.144 2023/06/05 16:26:05 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -181,7 +181,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.143 2023/04/23 08:53:08 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.144 2023/06/05 16:26:05 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -6095,7 +6095,8 @@ audio_rmixer_process(struct audio_softc 
 		codecarg.srcfmt = &mixer->hwbuf.fmt;
 		codecarg.dstfmt = &mixer->mixfmt;
 		codec = NULL;
-		if (audio_format2_is_linear(codecarg.srcfmt)) {
+		if (audio_format2_is_linear(codecarg.srcfmt) &&
+		codecarg.srcfmt->stride == codecarg.srcfmt->precision) {
 			switch (codecarg.srcfmt->stride) {
 			case 8:
 codec = audio_linear8_to_internal;
@@ -6115,6 +6116,8 @@ audio_rmixer_process(struct audio_softc 
 		}
 		if (codec == NULL) {
 			TRACE(4, "unsupported hw format");
+			/* drain hwbuf */
+			auring_take(&mixer->hwbuf, count);
 			return;
 		}
 



CVS commit: src/sys/dev/audio

2023-06-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Jun  5 16:26:05 UTC 2023

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
We cannot handle input with precision != stride yet.
Drain input buffer for unhandled input.


To generate a diff of this commit:
cvs rdiff -u -r1.143 -r1.144 src/sys/dev/audio/audio.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/ia64/stand/ia64/efi

2023-06-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun  5 18:16:07 UTC 2023

Modified Files:
src/sys/arch/ia64/stand/ia64/efi: start.S

Log Message:
Fix previous comment fix, which broke a comment.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/ia64/stand/ia64/efi/start.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/ia64/stand/ia64/efi/start.S
diff -u src/sys/arch/ia64/stand/ia64/efi/start.S:1.3 src/sys/arch/ia64/stand/ia64/efi/start.S:1.4
--- src/sys/arch/ia64/stand/ia64/efi/start.S:1.3	Sat Jun  3 20:41:45 2023
+++ src/sys/arch/ia64/stand/ia64/efi/start.S	Mon Jun  5 18:16:07 2023
@@ -1,4 +1,4 @@
-*	$NetBSD: start.S,v 1.3 2023/06/03 20:41:45 andvar Exp $	*/
+/*	$NetBSD: start.S,v 1.4 2023/06/05 18:16:07 martin Exp $	*/
 	
 /*-
  * Copyright (c) 2001 Doug Rabson



CVS commit: src/sys/arch/ia64/stand/ia64/efi

2023-06-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun  5 18:16:07 UTC 2023

Modified Files:
src/sys/arch/ia64/stand/ia64/efi: start.S

Log Message:
Fix previous comment fix, which broke a comment.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/ia64/stand/ia64/efi/start.S

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-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 20:56:18 UTC 2023

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

Log Message:
indent: in 'if (expr)', the parentheses do not form a cast expression

No functional change.  When stepping through the code in debug mode, it
was just too confusing that indent would log an 'unknown cast' in this
situation.


To generate a diff of this commit:
cvs rdiff -u -r1.335 -r1.336 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-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun  5 20:56:18 UTC 2023

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

Log Message:
indent: in 'if (expr)', the parentheses do not form a cast expression

No functional change.  When stepping through the code in debug mode, it
was just too confusing that indent would log an 'unknown cast' in this
situation.


To generate a diff of this commit:
cvs rdiff -u -r1.335 -r1.336 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/indent.c
diff -u src/usr.bin/indent/indent.c:1.335 src/usr.bin/indent/indent.c:1.336
--- src/usr.bin/indent/indent.c:1.335	Mon Jun  5 12:05:01 2023
+++ src/usr.bin/indent/indent.c	Mon Jun  5 20:56:18 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.335 2023/06/05 12:05:01 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.336 2023/06/05 20:56:18 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.335 2023/06/05 12:05:01 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.336 2023/06/05 20:56:18 rillig Exp $");
 
 #include 
 #include 
@@ -489,7 +489,12 @@ process_lparen(void)
 		indent = 2 * opt.indent_size;
 
 	enum paren_level_cast cast = cast_unknown;
-	if (ps.prev_lsym == lsym_offsetof || ps.prev_lsym == lsym_sizeof
+	if (ps.prev_lsym == lsym_offsetof
+	|| ps.prev_lsym == lsym_sizeof
+	|| ps.prev_lsym == lsym_for
+	|| ps.prev_lsym == lsym_if
+	|| ps.prev_lsym == lsym_switch
+	|| ps.prev_lsym == lsym_while
 	|| ps.is_function_definition)
 		cast = cast_no;
 



CVS commit: src/share/man/man5

2023-06-05 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Mon Jun  5 22:35:20 UTC 2023

Modified Files:
src/share/man/man5: mk.conf.5

Log Message:
mk.conf(5): editorial

MKDTB and MKPIE are .YorN.
MKX11=yes wants MKINET6=yes.
MKLINKLIB deserves a dash list (like bsd.README).

Expand per bsd.README: MKSTATICPIC, MKUNPRIVED,
MKX11, MKZFS, USE_LIBCSANITIZER, USE_SSP

Change the width of the variable lists to 14n (from 15n)
so that when the lists are rendered and then left aligned,
the column is 16 characters (aka 2 tabs) which makes
copypasta to bsd.README easier.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/share/man/man5/mk.conf.5

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



CVS commit: src/share/man/man5

2023-06-05 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Mon Jun  5 22:35:20 UTC 2023

Modified Files:
src/share/man/man5: mk.conf.5

Log Message:
mk.conf(5): editorial

MKDTB and MKPIE are .YorN.
MKX11=yes wants MKINET6=yes.
MKLINKLIB deserves a dash list (like bsd.README).

Expand per bsd.README: MKSTATICPIC, MKUNPRIVED,
MKX11, MKZFS, USE_LIBCSANITIZER, USE_SSP

Change the width of the variable lists to 14n (from 15n)
so that when the lists are rendered and then left aligned,
the column is 16 characters (aka 2 tabs) which makes
copypasta to bsd.README easier.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/share/man/man5/mk.conf.5

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

Modified files:

Index: src/share/man/man5/mk.conf.5
diff -u src/share/man/man5/mk.conf.5:1.100 src/share/man/man5/mk.conf.5:1.101
--- src/share/man/man5/mk.conf.5:1.100	Sun Jun  4 20:04:52 2023
+++ src/share/man/man5/mk.conf.5	Mon Jun  5 22:35:20 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mk.conf.5,v 1.100 2023/06/04 20:04:52 lukem Exp $
+.\"	$NetBSD: mk.conf.5,v 1.101 2023/06/05 22:35:20 lukem Exp $
 .\"
 .\"  Copyright (c) 1999-2023 The NetBSD Foundation, Inc.
 .\"  All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd June 4, 2023
+.Dd June 5, 2023
 .Dt MK.CONF 5
 .Os
 .\" turn off hyphenation
@@ -92,7 +92,7 @@ or
 .Dq no .
 ..
 .
-.Bl -tag -width 15n
+.Bl -tag -width 14n
 .
 .\" These entries are sorted alphabetically.
 .
@@ -644,6 +644,7 @@ will be installed.
 .DFLTy
 .
 .It Sy MKDTB
+.YorN
 Indicates whether the devicetree blobs will be built and installed.
 .DFLTy
 on
@@ -843,6 +844,13 @@ Has no effect on most platforms.
 .YorN
 Indicates whether INET6 (IPv6) infrastructure
 (libraries and support programs) will be built and installed.
+.Pp
+.Em Note :
+.Sy MKINET6
+must not be set to
+.Dq no
+if
+.Sy MKX11!=no .
 .DFLTy
 .
 .It Sy MKINFO
@@ -954,22 +962,32 @@ Indicates if libstdc++ will be built and
 .YorN
 Indicates whether all of the shared library infrastructure
 will be built and installed.
+.Pp
 If
 .Dq no ,
 prevents:
+.Bl -dash -compact
+.It
 installation of the
 .Sy *.a
-libraries,
+libraries
+.It
 installation of the
 .Sy *_pic.a
-libraries on PIC systems,
+libraries on PIC systems
+.It
 building of
 .Sy *.a
-libraries on PIC systems,
-or
+libraries on PIC systems
+.It
 installation of
 .Sy .so
-symlinks on ELF systems.
+symlinks on ELF systems
+.El
+.Pp
+I.e, only install the shared library (and the
+.Pa .so.major
+symlink on ELF).
 .NODEF NOLINKLIB
 .Pp
 If
@@ -1244,6 +1262,7 @@ on
 on other platforms.
 .
 .It Sy MKPIE
+.YorN
 Indicates whether Position Independent Executables (PIE)
 will be built and installed.
 .NODEF NOPIE
@@ -1448,6 +1467,8 @@ will be built and installed.
 .YorN
 Indicates whether support for static PIE binaries
 will be built and installed.
+These binaries use a special support in crt0.o for
+resolving relative relocations and require linker support.
 .DFLTy
 on
 .Sy i386
@@ -1528,6 +1549,8 @@ The contents of
 .Pa METALOG
 is used during the generation of the distribution tar files to ensure
 that the appropriate file ownership is stored.
+This allows a non-root
+.Sq "make install" .
 .DFLTn
 .
 .It Sy MKUPDATE
@@ -1541,7 +1564,14 @@ phase if the destination files are up-to
 .It Sy MKX11
 .YorN
 Indicates whether X11 will be built and installed from
-.Sy X11SRCDIR .
+.Sy X11SRCDIR ,
+and whether the X sets will be created.
+.Pp
+.Em Note :
+If
+.Dq yes ,
+requires
+.Sy MKINET6=yes .
 .DFLTn
 .
 .It Sy MKX11FONTS
@@ -1549,6 +1579,7 @@ Indicates whether X11 will be built and 
 If
 .Dq no ,
 do not build and install the X fonts.
+The xfont set is still created but will be empty.
 .Pp
 Only used if
 .Sy MKX11=yes .
@@ -1616,6 +1647,9 @@ Indicates whether the YP (NIS) infrastru
 .YorN
 Indicates whether the ZFS kernel module and the utilities and
 libraries used to manage the ZFS system are to be built and installed.
+.Pp
+.Em Note :
+ZFS requires 64-bit atomic operations .
 .DFLTy
 on
 .Sy aarch64 ,
@@ -1823,9 +1857,17 @@ Supported values:
 .Bl -tag -width undefined
 .It undefined
 Enables the micro-UBSan in the user mode (uUBSan)
-undefined behaviour sanitizer, with
+undefined behaviour sanitizer.
+The code is shared with the kernel mode variation (kUBSan).
+The runtime runtime differs from the UBSan available in
+.Sy MKSANITIZER .
+The runtime is stripped down from C++ features,
+and is invoked with
 .Li -fsanitize=no-vptr
 as that sanitizer is not supported.
+The runtime configuration is restricted to the
+.Ev LIBC_UBSAN
+environment variable, that is designed to be safe for hardening.
 .El
 .Pp
 The value of
@@ -1912,7 +1954,8 @@ This is mutually exclusive to
 Indicates whether GCC stack-smashing protection (SSP) support,
 which detects stack overflows and aborts the program,
 is enabled.
-This im

CVS commit: src

2023-06-05 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Mon Jun  5 22:36:17 UTC 2023

Modified Files:
src: BUILDING
src/doc: BUILDING.mdoc

Log Message:
BUILDING: editorial

MKX11=yes wants MKINET6=yes

Change the width of the variable lists to 14n (from 15n)
so that when the lists are rendered and then left aligned,
the column is 16 characters (aka 2 tabs) which makes
copypasta to bsd.README easier.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/BUILDING
cvs rdiff -u -r1.140 -r1.141 src/doc/BUILDING.mdoc

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



CVS commit: src

2023-06-05 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Mon Jun  5 22:36:17 UTC 2023

Modified Files:
src: BUILDING
src/doc: BUILDING.mdoc

Log Message:
BUILDING: editorial

MKX11=yes wants MKINET6=yes

Change the width of the variable lists to 14n (from 15n)
so that when the lists are rendered and then left aligned,
the column is 16 characters (aka 2 tabs) which makes
copypasta to bsd.README easier.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/BUILDING
cvs rdiff -u -r1.140 -r1.141 src/doc/BUILDING.mdoc

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

Modified files:

Index: src/BUILDING
diff -u src/BUILDING:1.151 src/BUILDING:1.152
--- src/BUILDING:1.151	Sun Jun  4 20:08:21 2023
+++ src/BUILDING	Mon Jun  5 22:36:17 2023
@@ -93,93 +93,92 @@ CONFIGURATION
Environment variables
  Several environment variables control the behaviour of NetBSD builds.
 
- HOST_CC  Path name to C compiler used to create the toolchain.
+ HOST_CC Path name to C compiler used to create the toolchain.
 
- HOST_CFLAGS  Flags passed to the host C compiler.
+ HOST_CFLAGS Flags passed to the host C compiler.
 
- HOST_CXX Path name to C++ compiler used to create the toolchain.
+ HOST_CXXPath name to C++ compiler used to create the toolchain.
 
- HOST_CXXFLAGSFlags passed to the host C++ compiler.
+ HOST_CXXFLAGS   Flags passed to the host C++ compiler.
 
- HOST_SH  Path name to a shell available on the host system and
-  suitable for use during the build.  The NetBSD build
-  system requires a modern Bourne-like shell with POSIX-
-  compliant features, and also requires support for the
-  "local" keyword to declare local variables in shell
-  functions (which is a widely-implemented but non-
-  standardised feature).
-
-  Depending on the host system, a suitable shell may be
-  /bin/sh, /usr/xpg4/bin/sh, /bin/ksh (provided it is a
-  variant of ksh that supports the "local" keyword, such
-  as ksh88, but not ksh93), or /usr/local/bin/bash.
-
-  Most parts of the build require HOST_SH to be an
-  absolute path; however, build.sh allows it to be a
-  simple command name, which will be converted to an
-  absolute path by searching the PATH.
+ HOST_SH Path name to a shell available on the host system and
+ suitable for use during the build.  The NetBSD build
+ system requires a modern Bourne-like shell with POSIX-
+ compliant features, and also requires support for the
+ "local" keyword to declare local variables in shell
+ functions (which is a widely-implemented but non-
+ standardised feature).
+
+ Depending on the host system, a suitable shell may be
+ /bin/sh, /usr/xpg4/bin/sh, /bin/ksh (provided it is a
+ variant of ksh that supports the "local" keyword, such as
+ ksh88, but not ksh93), or /usr/local/bin/bash.
+
+ Most parts of the build require HOST_SH to be an absolute
+ path; however, build.sh allows it to be a simple command
+ name, which will be converted to an absolute path by
+ searching the PATH.
 
  INSTALLBOOT_UBOOT_PATHS
-  A colon-separated list of search paths used by
-  installboot(8) to find U-Boot packages.
+ A colon-separated list of search paths used by
+ installboot(8) to find U-Boot packages.
 
- MACHINE  Machine type, e.g., "macppc".
+ MACHINE Machine type, e.g., "macppc".
 
- MACHINE_ARCH Machine architecture, e.g., "powerpc".
+ MACHINE_ARCHMachine architecture, e.g., "powerpc".
 
- MAKE Path name to invoke make(1) as.
+ MAKEPath name to invoke make(1) as.
 
- MAKECONF The name of the make(1) configuration file.  See "make"
-  variables and mk.conf(5).
+ MAKECONFThe name of the make(1) configuration file.  See "make"
+ variables and mk.conf(5).
 
-  Note: Only settable in the process environment.
+ Note: Only settable in the process environment.
 
-  Default: "/etc/mk.conf"
+ Default: "/etc/mk.conf"
 
- MAKEFLAGSFlags to invoke make(1) with.
+ MAKEFLAGS   Flags to invoke make(1) with.
 
-  Note: build.sh ignores the valu

CVS commit: src/share/mk

2023-06-05 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Mon Jun  5 22:36:59 UTC 2023

Modified Files:
src/share/mk: bsd.README

Log Message:
bsd.README: update to reality, sync from mk.conf(5)

Sync user variables from mk.conf(5), sorted.
(Arguably this could just refer to mk.conf(5)
or share/man/man5/mk.conf.5 and remove the copypasta.)

Document NOxxx overrides in own subsection.

Unexpand tabs, tweak after.


To generate a diff of this commit:
cvs rdiff -u -r1.443 -r1.444 src/share/mk/bsd.README

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



CVS commit: src/share/mk

2023-06-05 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Mon Jun  5 22:36:59 UTC 2023

Modified Files:
src/share/mk: bsd.README

Log Message:
bsd.README: update to reality, sync from mk.conf(5)

Sync user variables from mk.conf(5), sorted.
(Arguably this could just refer to mk.conf(5)
or share/man/man5/mk.conf.5 and remove the copypasta.)

Document NOxxx overrides in own subsection.

Unexpand tabs, tweak after.


To generate a diff of this commit:
cvs rdiff -u -r1.443 -r1.444 src/share/mk/bsd.README

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

Modified files:

Index: src/share/mk/bsd.README
diff -u src/share/mk/bsd.README:1.443 src/share/mk/bsd.README:1.444
--- src/share/mk/bsd.README:1.443	Wed May 24 10:07:16 2023
+++ src/share/mk/bsd.README	Mon Jun  5 22:36:58 2023
@@ -1,11 +1,14 @@
-#	$NetBSD: bsd.README,v 1.443 2023/05/24 10:07:16 lukem Exp $
+#	$NetBSD: bsd.README,v 1.444 2023/06/05 22:36:58 lukem Exp $
 #	@(#)bsd.README	8.2 (Berkeley) 4/2/94
 
 This is the README file for the make "include" files for the NetBSD
 source tree.  The files are installed in /usr/share/mk, and are,
 by convention, named with the suffix ".mk".
 
-Note, this file is not intended to replace reading through the .mk
+Other sources of relevant documentation are BUILDING in the top
+level of the NetBSD source tree, and the mk.conf(5) man page.
+
+Note: this file is not intended to replace reading through the .mk
 files for anything tricky.
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -66,32 +69,35 @@ and are tested with  ${VAR} == "no"  and
 
 The basic rule for the variable naming scheme is as follows:
 
-HOST_xxx	A command that runs on the host machine regardless of
+HOST_	A command that runs on the host machine regardless of
 		whether or not the system is being cross compiled, or
 		flags for such a command.
 
-MKxxx		Can be set to "no" to disable functionality, or
-		"yes" to enable it.
+MK	Can be set to "no" to disable feature ,
+		or "yes" to enable feature .
 		Usually defaults to "yes", although some variables
 		default to "no".
 		Due to make(1) implementation issues, if a temporary
 		command-line override of a mk.conf(5) or 
 		setting is required whilst still honoring a particular
-		Makefile's setting of MKxxx, use
-			env MKxxx=value make
+		Makefile's setting of MK, use
+			env MK=value make
 		instead of
-			make MKxxx=value
+			make MK=value
 
-NOxxx		If defined, disables a feature.
+NO	If defined, disables feature , overriding
+		a user's MK=yes configuration.
 		Not intended for users.
 		This is to allow Makefiles to disable functionality
 		that they don't support (such as missing man pages).
-		NOxxx variables must be defined before 
-		is included.
+		NO variables must be defined before 
+		is included, which generally means define before
+		any <*.mk> is included.
+		See "Variables for a Makefile".
 
-TOOL_xxx	A tool that is provided as part of the USETOOLS
+TOOL_	A tool that is provided as part of the USETOOLS
 		framework.  When not using the USETOOLS framework,
-		TOOL_xxx variables should refer to tools that are
+		TOOL_ variables should refer to tools that are
 		already installed on the host system.
 
 The following variables control how things are made/installed that
@@ -99,530 +105,1094 @@ are not set by default. These should not
 the user to define in MAKECONF (see , below, or mk.conf(5))
 or on the make(1) command line:
 
-BUILD 		If defined, 'make install' checks that the targets in the
-		source directories are up-to-date and remakes them if they
-are out of date, instead of blindly trying to install
-out of date or non-existent targets.
+BUILD		If defined, 'make install' checks that the targets in the
+		source directories are up-to-date and re-makes them if
+		they are out of date, instead of blindly trying to
+		install out of date or non-existent targets.
+
+		Default: Unset.
+
+BUILDID		Identifier for the build.  If set, this should be a short
+		string that is suitable for use as part of a file or
+		directory name.  The identifier will be appended to
+		object directory names, and can be consulted in the
+		make(1) configuration file in order to set additional
+		build parameters, such as compiler flags.  It will also
+		be used as part of the kernel version string, which can
+		be shown by "uname -v".
+
+		Default: Unset.
+
+BUILDINFO	Optional multi-line string containing information about
+		the build.  This will appear in DESTDIR/etc/release, and
+		it will be stored in the buildinfo variable in any
+		kernels that are built.  When such kernels are booted,
+		the sysctl(7) kern.buildinfo variable will report this
+		value.  The string may contain backslash escape
+		sequences, such as "\\" (representing a backslash
+		character) and "\n" (representing a newline).
+
+		Default: Unset.
+
+BUILDSEED	g++(1) uses random numbers when compiling C++

CVS commit: src

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 04:37:27 UTC 2023

Modified Files:
src/tests/usr.bin/indent: opt_cli.c psym_switch_expr.c
src/usr.bin/indent: indent.c indent.h io.c parse.c

Log Message:
indent: compute indentation of 'case' labels on-demand

One less moving part to keep track of.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/opt_cli.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/psym_switch_expr.c
cvs rdiff -u -r1.336 -r1.337 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.175 -r1.176 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.198 -r1.199 src/usr.bin/indent/io.c
cvs rdiff -u -r1.66 -r1.67 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

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 04:37:27 UTC 2023

Modified Files:
src/tests/usr.bin/indent: opt_cli.c psym_switch_expr.c
src/usr.bin/indent: indent.c indent.h io.c parse.c

Log Message:
indent: compute indentation of 'case' labels on-demand

One less moving part to keep track of.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/opt_cli.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/psym_switch_expr.c
cvs rdiff -u -r1.336 -r1.337 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.175 -r1.176 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.198 -r1.199 src/usr.bin/indent/io.c
cvs rdiff -u -r1.66 -r1.67 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.5 src/tests/usr.bin/indent/opt_cli.c:1.6
--- src/tests/usr.bin/indent/opt_cli.c:1.5	Sun Apr 24 09:04:12 2022
+++ src/tests/usr.bin/indent/opt_cli.c	Tue Jun  6 04:37:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_cli.c,v 1.5 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: opt_cli.c,v 1.6 2023/06/06 04:37:27 rillig Exp $ */
 
 /*
  * Tests for the option '-cli' ("case label indentation"), which sets the
@@ -72,3 +72,28 @@ classify(int n)
 	}
 }
 //indent end
+
+//indent run -cli3.25
+void
+classify(int n)
+{
+	switch (n) {
+  case 0:
+	print("zero");
+	break;
+  case 1:
+	print("one");
+	break;
+  case 2:
+  case 3:
+	print("prime");
+	break;
+  case 4:
+	print("square");
+	break;
+  default:
+	print("large");
+	break;
+	}
+}
+//indent end

Index: src/tests/usr.bin/indent/psym_switch_expr.c
diff -u src/tests/usr.bin/indent/psym_switch_expr.c:1.4 src/tests/usr.bin/indent/psym_switch_expr.c:1.5
--- src/tests/usr.bin/indent/psym_switch_expr.c:1.4	Sun Apr 24 09:04:12 2022
+++ src/tests/usr.bin/indent/psym_switch_expr.c	Tue Jun  6 04:37:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: psym_switch_expr.c,v 1.4 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: psym_switch_expr.c,v 1.5 2023/06/06 04:37:27 rillig Exp $ */
 
 /*
  * Tests for the parser symbol psym_switch_expr, which represents the keyword
@@ -6,10 +6,6 @@
  * statement (usually a block) containing the 'case' labels.
  */
 
-//indent input
-// TODO: add input
-//indent end
-
 //indent run-equals-input
 
 
@@ -43,3 +39,17 @@ function(void)
 		}
 }
 //indent end
+
+//indent run -cli-0.375
+void
+function(void)
+{
+	switch (expr)
+		if (cond) {
+ case 1:
+			return;
+ case 2:
+			break;
+		}
+}
+//indent end

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.336 src/usr.bin/indent/indent.c:1.337
--- src/usr.bin/indent/indent.c:1.336	Mon Jun  5 20:56:18 2023
+++ src/usr.bin/indent/indent.c	Tue Jun  6 04:37:26 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.336 2023/06/05 20:56:18 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.337 2023/06/06 04:37:26 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.336 2023/06/05 20:56:18 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.337 2023/06/06 04:37:26 rillig Exp $");
 
 #include 
 #include 
@@ -81,7 +81,6 @@ struct buffer code;
 struct buffer com;
 
 bool found_err;
-float case_ind;
 bool had_eof;
 int line_no = 1;
 enum indent_enabled indent_enabled;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.175 src/usr.bin/indent/indent.h:1.176
--- src/usr.bin/indent/indent.h:1.175	Mon Jun  5 14:22:26 2023
+++ src/usr.bin/indent/indent.h	Tue Jun  6 04:37:26 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.175 2023/06/05 14:22:26 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.176 2023/06/06 04:37:26 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -247,8 +247,6 @@ extern struct options {
 } opt;
 
 extern bool found_err;
-extern float case_ind;		/* indentation level to be used for a "case n:"
- */
 extern bool had_eof;		/* whether input is exhausted */
 extern int line_no;		/* the current line number. */
 extern enum indent_enabled {
@@ -355,7 +353,6 @@ extern struct parser_state {
 	int tos;		/* pointer to top of stack */
 	parser_symbol s_sym[STACKSIZE];
 	int s_ind_level[STACKSIZE];
-	float s_case_ind_level[STACKSIZE];
 
 	/* Spacing inside a statement or declaration */
 

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.198 src/usr.bin/indent/io.c:1.199
--- src/usr.bin/indent/io.c:1.198	Mon Jun  5 12:06:51 2023
+++ src/usr.bin/indent/io.c	Tue Jun  6 04:37:26 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.198 2023/06/05 12:06:51 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.199 2023/06/06 04:37:26 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.198 2023/06/05 12:06:51 rillig Exp $");
+__RCSID(

CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 05:11:11 UTC 2023

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

Log Message:
indent: sort functions in call order

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.199 -r1.200 src/usr.bin/indent/io.c
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.67 -r1.68 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/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.36 src/usr.bin/indent/debug.c:1.37
--- src/usr.bin/indent/debug.c:1.36	Mon Jun  5 14:40:13 2023
+++ src/usr.bin/indent/debug.c	Tue Jun  6 05:11:11 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.36 2023/06/05 14:40:13 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.37 2023/06/06 05:11:11 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.36 2023/06/05 14:40:13 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.37 2023/06/06 05:11:11 rillig Exp $");
 
 #include 
 
@@ -144,6 +144,7 @@ static const char *const decl_ptr_name[]
 
 static unsigned wrote_newlines = 1;
 
+
 void
 debug_printf(const char *fmt, ...)
 {

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.199 src/usr.bin/indent/io.c:1.200
--- src/usr.bin/indent/io.c:1.199	Tue Jun  6 04:37:26 2023
+++ src/usr.bin/indent/io.c	Tue Jun  6 05:11:11 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.199 2023/06/06 04:37:26 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.200 2023/06/06 05:11:11 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.199 2023/06/06 04:37:26 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.200 2023/06/06 05:11:11 rillig Exp $");
 
 #include 
 
@@ -55,22 +55,6 @@ static unsigned wrote_newlines = 2;	/* 0
 static int paren_indent;
 
 
-void
-inp_skip(void)
-{
-	inp_p++;
-	if ((size_t)(inp_p - inp.s) >= inp.len)
-		inp_read_line();
-}
-
-char
-inp_next(void)
-{
-	char ch = inp_p[0];
-	inp_skip();
-	return ch;
-}
-
 static void
 inp_read_next_line(FILE *f)
 {
@@ -95,6 +79,32 @@ inp_read_next_line(FILE *f)
 	inp_p = inp.s;
 }
 
+void
+inp_read_line(void)
+{
+	if (indent_enabled == indent_on)
+		out.indent_off_text.len = 0;
+	buf_add_chars(&out.indent_off_text, inp.s, inp.len);
+	inp_read_next_line(input);
+}
+
+void
+inp_skip(void)
+{
+	inp_p++;
+	if ((size_t)(inp_p - inp.s) >= inp.len)
+		inp_read_line();
+}
+
+char
+inp_next(void)
+{
+	char ch = inp_p[0];
+	inp_skip();
+	return ch;
+}
+
+
 static void
 output_newline(void)
 {
@@ -176,6 +186,26 @@ is_blank_line_optional(void)
 	return wrote_newlines >= 3;
 }
 
+static int
+compute_case_label_indent(void)
+{
+	int i = ps.tos;
+	while (i > 0 && ps.s_sym[i] != psym_switch_expr)
+		i--;
+	float case_ind = (float)ps.s_ind_level[i] + opt.case_indent;
+	return (int)(case_ind * (float)opt.indent_size);
+}
+
+int
+compute_label_indent(void)
+{
+	if (out.line_kind == lk_case_or_default)
+		return compute_case_label_indent();
+	if (lab.s[0] == '#')
+		return 0;
+	return opt.indent_size * (ps.ind_level - 2);
+}
+
 static void
 output_line_label(void)
 {
@@ -183,6 +213,53 @@ output_line_label(void)
 	output_range(lab.s, lab.len);
 }
 
+static int
+compute_code_indent_lineup(int base_ind)
+{
+	int ind = paren_indent;
+	int overflow = ind_add(ind, code.s, code.len) - opt.max_line_length;
+	if (overflow < 0)
+		return ind;
+
+	if (ind_add(base_ind, code.s, code.len) < opt.max_line_length) {
+		ind -= overflow + 2;
+		if (ind > base_ind)
+			return ind;
+		return base_ind;
+	}
+
+	return ind;
+}
+
+int
+compute_code_indent(void)
+{
+	int base_ind = ps.ind_level * opt.indent_size;
+
+	if (ps.line_start_nparen == 0) {
+		if (ps.tos >= 1 && ps.s_sym[ps.tos - 1] == psym_lbrace_enum)
+			return base_ind;
+		if (ps.in_stmt_cont)
+			return base_ind + opt.continuation_indent;
+		return base_ind;
+	}
+
+	if (opt.lineup_to_parens) {
+		if (opt.lineup_to_parens_always)
+			return paren_indent;
+		return compute_code_indent_lineup(base_ind);
+	}
+
+	if (ps.extra_expr_indent != eei_no)
+		return base_ind + 2 * opt.continuation_indent;
+
+	if (2 * opt.continuation_indent == opt.indent_size)
+		return base_ind + opt.continuation_indent;
+	else
+		return base_ind +
+		opt.continuation_indent * ps.line_start_nparen;
+}
+
 static void
 output_line_code(void)
 {
@@ -314,79 +391,3 @@ dont_write_line:
 	ps.want_blank = false;
 	out.line_kind = lk_other;
 }
-
-static int
-compute_code_indent_lineup(int base_ind)
-{
-	int ind = paren_indent;
-	int overflow = ind_add(ind, code.s, code.len) - opt.max_line_length;
-	if (overflow < 0)
-		return ind;
-
-	if (ind_add(base_ind, code.s, code.len) < opt.max_line_length) {
-		ind -= overflow + 2;
-		if (ind > base_ind)
-			return ind;
-		return base_ind;
-	}
-
-

CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 05:11:11 UTC 2023

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

Log Message:
indent: sort functions in call order

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.199 -r1.200 src/usr.bin/indent/io.c
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.67 -r1.68 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/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 05:27:56 UTC 2023

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

Log Message:
indent: condense code for writing tabs

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 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-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 05:27:56 UTC 2023

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

Log Message:
indent: condense code for writing tabs

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 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.200 src/usr.bin/indent/io.c:1.201
--- src/usr.bin/indent/io.c:1.200	Tue Jun  6 05:11:11 2023
+++ src/usr.bin/indent/io.c	Tue Jun  6 05:27:56 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.200 2023/06/06 05:11:11 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.201 2023/06/06 05:27:56 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.200 2023/06/06 05:11:11 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.201 2023/06/06 05:27:56 rillig Exp $");
 
 #include 
 
@@ -130,13 +130,11 @@ output_indent(int new_ind)
 	int ind = out_ind;
 
 	if (opt.use_tabs) {
-		int tabsize = opt.tabsize;
-		int n = new_ind / tabsize - ind / tabsize;
-		if (n > 0)
-			ind -= ind % tabsize;
-		for (int i = 0; i < n; i++) {
-			fputc('\t', output);
-			ind += tabsize;
+		int n = new_ind / opt.tabsize - ind / opt.tabsize;
+		if (n > 0) {
+			ind = ind - ind % opt.tabsize + n * opt.tabsize;
+			while (n-- > 0)
+fputc('\t', output);
 			wrote_newlines = 0;
 		}
 	}



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

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 05:39:49 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_comment.c

Log Message:
tests/indent: comments with trailing whitespace may fit in a single line


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/indent/lsym_comment.c

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



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

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 05:39:49 UTC 2023

Modified Files:
src/tests/usr.bin/indent: lsym_comment.c

Log Message:
tests/indent: comments with trailing whitespace may fit in a single line


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/indent/lsym_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.16 src/tests/usr.bin/indent/lsym_comment.c:1.17
--- src/tests/usr.bin/indent/lsym_comment.c:1.16	Mon Jun  5 08:22:00 2023
+++ src/tests/usr.bin/indent/lsym_comment.c	Tue Jun  6 05:39:49 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_comment.c,v 1.16 2023/06/05 08:22:00 rillig Exp $ */
+/* $NetBSD: lsym_comment.c,v 1.17 2023/06/06 05:39:49 rillig Exp $ */
 
 /*
  * Tests for the token lsym_comment, which starts a comment.
@@ -371,6 +371,25 @@ tab1+++	tab2---	tab3+++	tab4---	tab5+++	
 
 
 /*
+ * TODO: Trailing whitespace in a comment is ignored when determining whether the
+ * comment fits in a single line.
+ */
+//indent input
+/* 456789 123456789 123456789 12345		*/
+/* 456789 123456789 123456789 123456		*/
+//indent end
+
+//indent run -l38
+/*
+ * 456789 123456789 123456789 12345
+ */
+/*
+ * 456789 123456789 123456789 123456
+ */
+//indent end
+
+
+/*
  * The following comments test line breaking when the comment does not end
  * with a space. Since indent adds a trailing space to a single-line comment,
  * this space has to be taken into account when computing the line length.



CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 06:51:44 UTC 2023

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

Log Message:
indent: split printing of comments into smaller functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 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-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 06:51:44 UTC 2023

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

Log Message:
indent: split printing of comments into smaller functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 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/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.151 src/usr.bin/indent/pr_comment.c:1.152
--- src/usr.bin/indent/pr_comment.c:1.151	Sun Jun  4 20:51:19 2023
+++ src/usr.bin/indent/pr_comment.c	Tue Jun  6 06:51:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.151 2023/06/04 20:51:19 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.152 2023/06/06 06:51:44 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: pr_comment.c,v 1.151 2023/06/04 20:51:19 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.152 2023/06/06 06:51:44 rillig Exp $");
 
 #include 
 
@@ -73,7 +73,8 @@ fits_in_one_line(int com_ind, int max_li
 }
 
 static void
-analyze_comment(bool *p_may_wrap, bool *p_delim, int *p_line_length)
+analyze_comment(bool *p_may_wrap, bool *p_delim,
+int *p_ind, int *p_line_length)
 {
 	bool may_wrap = true;
 	bool delim = opt.comment_delimiter_on_blankline;
@@ -134,6 +135,15 @@ analyze_comment(bool *p_may_wrap, bool *
 inp_p++;
 	}
 
+	*p_may_wrap = may_wrap;
+	*p_delim = delim;
+	*p_ind = ind;
+	*p_line_length = line_length;
+}
+
+static void
+copy_comment_start(bool may_wrap, bool *delim, int ind, int line_length)
+{
 	ps.comment_delta = 0;
 	com_add_char('/');
 	com_add_char(token.s[token.len - 1]);	/* either '*' or '/' */
@@ -141,152 +151,152 @@ analyze_comment(bool *p_may_wrap, bool *
 	if (may_wrap && !ch_isblank(inp_p[0]))
 		com_add_char(' ');
 
-	if (delim && fits_in_one_line(ind, line_length))
-		delim = false;
+	if (*delim && fits_in_one_line(ind, line_length))
+		*delim = false;
 
-	if (delim) {
+	if (*delim) {
 		output_line();
 		com_add_delim();
 	}
-
-	*p_line_length = line_length;
-	*p_delim = delim;
-	*p_may_wrap = may_wrap;
 }
 
-/*
- * Copy characters from 'inp' to 'com'. Try to keep comments from going over
- * the maximum line length. To do that, remember where the last blank, tab, or
- * newline was. When a line is filled, print up to the last blank and continue
- * copying.
- */
 static void
-copy_comment_wrap(int line_length, bool delim)
+copy_comment_wrap_text(int line_length, ssize_t *last_blank)
 {
-	ssize_t last_blank = -1;	/* index of the last blank in 'com' */
-
+	int now_len = ind_add(ps.com_ind, com.s, com.len);
 	for (;;) {
-		switch (inp_p[0]) {
-		case '\n':
-			if (had_eof) {
-diag(1, "Unterminated comment");
-output_line();
-return;
-			}
-
-			last_blank = -1;
-			if (ps.next_col_1) {
-if (com.len == 0) {
-	/* force empty line of output */
-	com_add_char(' ');
-}
-if (com.len > 3) {
-	output_line();
-	com_add_delim();
-}
-output_line();
-com_add_delim();
+		char ch = inp_next();
+		if (ch_isblank(ch))
+			*last_blank = (ssize_t)com.len;
+		com_add_char(ch);
+		now_len++;
+		if (memchr("*\n\r\b\t", inp_p[0], 6) != NULL)
+			break;
+		if (now_len >= line_length && *last_blank != -1)
+			break;
+	}
 
-			} else {
-ps.next_col_1 = true;
-if (!(com.len > 0
-&& ch_isblank(com.s[com.len - 1])))
-	com_add_char(' ');
-last_blank = (int)com.len - 1;
-			}
-			++line_no;
+	ps.next_col_1 = false;
 
-			bool skip_asterisk = true;
-			do {	/* flush any blanks and/or tabs at start of
- * next line */
-inp_skip();
-if (inp_p[0] == '*' && skip_asterisk) {
-	skip_asterisk = false;
-	inp_p++;
-	if (inp_p[0] == '/')
-		goto end_of_comment;
-}
-			} while (ch_isblank(inp_p[0]));
+	if (now_len <= line_length)
+		return;
+	if (ch_isspace(com.s[com.len - 1]))
+		return;
 
-			break;	/* end of case for newline */
+	if (*last_blank == -1) {
+		/* only a single word in this line */
+		output_line();
+		com_add_delim();
+		return;
+	}
 
-		case '*':
-			inp_p++;
-			if (inp_p[0] == '/') {
-		end_of_comment:
-inp_p++;
+	const char *last_word_s = com.s + *last_blank + 1;
+	size_t last_word_len = com.len - (size_t)(*last_blank + 1);
+	com.len = (size_t)*last_blank;
+	output_line();
+	com_add_delim();
+
+	/* Assume that output_line and com_add_delim don't
+	 * invalidate the "unused" part of the buffer beyond
+	 * com.s + com.len. */
+	memmove(com.s + com.len, last_word_s, last_word_len);
+	com.len += last_word_len;
+	*last_blank = -1;
+}
 
-if (delim) {
-	if (com.len > 3)
-		output_line();
-	else
-		com.len = 0;
-	com_add_char(' ');
-} else {
-	size_t len = com.len;
-	while (ch_isblank(com.s[len - 1]))
-		len--;
-	int now_len = ind_add(
-	ps.com_ind, com.s, len);
-	if (n

CVS commit: src/distrib/sets/lists/debug

2023-06-05 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Jun  6 06:51:00 UTC 2023

Modified Files:
src/distrib/sets/lists/debug: mi

Log Message:
Fix MKDEBUGLIB build by adding these installed files to the debug
set list.

XXX
One could argue that these files are not of any use, so why install
them?  I don't have a good argument either way, and this is (for
now) a simple work-around for PR bin/57455   Please feel free to
commit a different fix to avoid installing these files at all.


To generate a diff of this commit:
cvs rdiff -u -r1.401 -r1.402 src/distrib/sets/lists/debug/mi

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



CVS commit: src/distrib/sets/lists/debug

2023-06-05 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Jun  6 06:51:00 UTC 2023

Modified Files:
src/distrib/sets/lists/debug: mi

Log Message:
Fix MKDEBUGLIB build by adding these installed files to the debug
set list.

XXX
One could argue that these files are not of any use, so why install
them?  I don't have a good argument either way, and this is (for
now) a simple work-around for PR bin/57455   Please feel free to
commit a different fix to avoid installing these files at all.


To generate a diff of this commit:
cvs rdiff -u -r1.401 -r1.402 src/distrib/sets/lists/debug/mi

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/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.401 src/distrib/sets/lists/debug/mi:1.402
--- src/distrib/sets/lists/debug/mi:1.401	Fri Jun  2 11:09:39 2023
+++ src/distrib/sets/lists/debug/mi	Tue Jun  6 06:51:00 2023
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.401 2023/06/02 11:09:39 martin Exp $
+# $NetBSD: mi,v 1.402 2023/06/06 06:51:00 pgoyette Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -2529,4 +2529,14 @@
 ./usr/libdata/debug/usr/tests/util/id/h_id.debug			tests-obsolete		obsolete,compattestfile
 ./usr/libdata/debug/usr/tests/util/systrace/h_have_systrace.debug	tests-obsolete		obsolete,compattestfile
 ./usr/tests/lib/libc/tls/libh_tls_dynamic_g.a	comp-c-debuglib		atf,debuglib,compattestfile
+./usr/tests/libexec/ld.elf_so/libh_abuse_dynamic_g.a			tests-libexec-debug	debug,atf,pic,compattestfile
+./usr/tests/libexec/ld.elf_so/libh_abuse_static_g.a			tests-libexec-debug	debug,atf,pic,compattestfile
+./usr/tests/libexec/ld.elf_so/libh_def_dynamic_g.a			tests-libexec-debug	debug,atf,pic,compattestfile
+./usr/tests/libexec/ld.elf_so/libh_def_static_g.a			tests-libexec-debug	debug,atf,pic,compattestfile
+./usr/tests/libexec/ld.elf_so/libh_onlyctor_dynamic_g.a			tests-libexec-debug	debug,atf,pic,compattestfile
+./usr/tests/libexec/ld.elf_so/libh_onlydef_g.atests-libexec-debug	debug,atf,pic,compattestfile
+./usr/tests/libexec/ld.elf_so/libh_onlyuse_dynamic_g.a			tests-libexec-debug	debug,atf,pic,compattestfile
+./usr/tests/libexec/ld.elf_so/libh_onlyuse_static_g.a			tests-libexec-debug	debug,atf,pic,compattestfile
+./usr/tests/libexec/ld.elf_so/libh_use_dynamic_g.a			tests-libexec-debug	debug,atf,pic,compattestfile
+./usr/tests/libexec/ld.elf_so/libh_use_static_g.a			tests-libexec-debug	debug,atf,pic,compattestfile
 ./var/db/obsolete/debugbase-sys-root		debug



CVS commit: src/usr.bin/indent

2023-06-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 06:59:39 UTC 2023

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

Log Message:
indent: simplify handling of comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 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-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun  6 06:59:39 UTC 2023

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

Log Message:
indent: simplify handling of comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 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/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.152 src/usr.bin/indent/pr_comment.c:1.153
--- src/usr.bin/indent/pr_comment.c:1.152	Tue Jun  6 06:51:44 2023
+++ src/usr.bin/indent/pr_comment.c	Tue Jun  6 06:59:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.152 2023/06/06 06:51:44 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.153 2023/06/06 06:59:39 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: pr_comment.c,v 1.152 2023/06/06 06:51:44 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.153 2023/06/06 06:59:39 rillig Exp $");
 
 #include 
 
@@ -226,16 +226,16 @@ copy_comment_wrap_newline(ssize_t *last_
 	++line_no;
 
 	/* flush any blanks and/or tabs at start of next line */
-	bool skip_asterisk = true;
-	do {
-		inp_skip();
-		if (inp_p[0] == '*' && skip_asterisk) {
-			skip_asterisk = false;
+	inp_skip();		/* '\n' */
+	while (ch_isblank(inp_p[0]))
+		inp_p++;
+	if (inp_p[0] == '*' && inp_p[1] == '/')
+		return false;
+	if (inp_p[0] == '*') {
+		inp_p++;
+		while (ch_isblank(inp_p[0]))
 			inp_p++;
-			if (inp_p[0] == '/')
-return false;
-		}
-	} while (ch_isblank(inp_p[0]));
+	}
 
 	return true;
 }
@@ -243,8 +243,6 @@ copy_comment_wrap_newline(ssize_t *last_
 static void
 copy_comment_wrap_finish(int line_length, bool delim)
 {
-	inp_p++;
-
 	if (delim) {
 		if (com.len > 3)
 			output_line();
@@ -260,6 +258,7 @@ copy_comment_wrap_finish(int line_length
 			output_line();
 	}
 
+	inp_p += 2;
 	if (!(com.len > 0 && ch_isblank(com.s[com.len - 1])))
 		com_add_char(' ');
 	com_add_char('*');
@@ -283,10 +282,9 @@ copy_comment_wrap(int line_length, bool 
 goto unterminated_comment;
 			if (!copy_comment_wrap_newline(&last_blank))
 goto end_of_comment;
-		} else if (inp_p[0] == '*' && inp_p[1] == '/') {
-			inp_p++;
+		} else if (inp_p[0] == '*' && inp_p[1] == '/')
 			goto end_of_comment;
-		} else
+		else
 			copy_comment_wrap_text(line_length, &last_blank);
 	}