Module Name: src
Committed By: rillig
Date: Sat May 13 09:40:47 UTC 2023
Modified Files:
src/tests/usr.bin/indent: label.c
src/usr.bin/indent: indent.c indent.h
Log Message:
indent: clean up a condition, add comments
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/label.c
cvs rdiff -u -r1.257 -r1.258 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.123 -r1.124 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/label.c
diff -u src/tests/usr.bin/indent/label.c:1.5 src/tests/usr.bin/indent/label.c:1.6
--- src/tests/usr.bin/indent/label.c:1.5 Thu May 11 09:28:53 2023
+++ src/tests/usr.bin/indent/label.c Sat May 13 09:40:47 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: label.c,v 1.5 2023/05/11 09:28:53 rillig Exp $ */
+/* $NetBSD: label.c,v 1.6 2023/05/13 09:40:47 rillig Exp $ */
/* See FreeBSD r303489 */
@@ -21,6 +21,7 @@ void
t(void)
{
switch (1)
+/* $ TODO: Move the '{' up to the ')'. */
{
case 1: /* test */
case 2: /* test */
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.257 src/usr.bin/indent/indent.c:1.258
--- src/usr.bin/indent/indent.c:1.257 Sat May 13 08:33:39 2023
+++ src/usr.bin/indent/indent.c Sat May 13 09:40:47 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.257 2023/05/13 08:33:39 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.258 2023/05/13 09:40:47 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c 5.1
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.257 2023/05/13 08:33:39 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.258 2023/05/13 09:40:47 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -485,9 +485,8 @@ process_lparen_or_lbracket(void)
debug_println("paren_indents[%d] is now %d",
ps.nparen - 1, ps.paren[ps.nparen - 1].indent);
- if (ps.spaced_expr_psym != psym_0
- && ps.nparen == 1 && opt.extra_expr_indent
- && ps.paren[0].indent < 2 * opt.indent_size) {
+ if (opt.extra_expr_indent && ps.spaced_expr_psym != psym_0
+ && ps.nparen == 1 && ps.paren[0].indent < 2 * opt.indent_size) {
ps.paren[0].indent = (short)(2 * opt.indent_size);
debug_println("paren_indents[0] is now %d", ps.paren[0].indent);
}
Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.123 src/usr.bin/indent/indent.h:1.124
--- src/usr.bin/indent/indent.h:1.123 Sat May 13 09:27:49 2023
+++ src/usr.bin/indent/indent.h Sat May 13 09:40:47 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.123 2023/05/13 09:27:49 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.124 2023/05/13 09:40:47 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -120,7 +120,7 @@ typedef enum parser_symbol {
psym_if_expr, /* 'if' '(' expr ')' */
psym_if_expr_stmt, /* 'if' '(' expr ')' stmt */
psym_if_expr_stmt_else, /* 'if' '(' expr ')' stmt 'else' */
- psym_else, /* 'else' */
+ psym_else, /* 'else'; not stored on the stack */
psym_switch_expr, /* 'switch' '(' expr ')' */
psym_do, /* 'do' */
psym_do_stmt, /* 'do' stmt */
@@ -184,8 +184,8 @@ extern struct options {
* 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
+ * 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
* the code that follows */
bool else_if; /* whether else-if pairs should be handled
@@ -254,7 +254,8 @@ extern struct parser_state {
* 1 of the unformatted input */
bool next_col_1;
bool next_unary; /* whether the following operator should be
- * unary */
+ * unary; is used in declarations for '*', as
+ * well as in expressions */
bool is_function_definition;