diff options
| author | rillig <rillig@NetBSD.org> | 2023-05-13 09:40:47 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2023-05-13 09:40:47 +0000 |
| commit | 5d196dd2c1dccc7e96cbc8a8cf5bcb8ddef0d687 (patch) | |
| tree | 90ff4a0a4ae0a7fc479a7b76700b3e5707096bb5 | |
| parent | 3371bebe9b1fba14d3533c4f863bbd4dfdddaa64 (diff) | |
indent: clean up a condition, add comments
No functional change.
| -rw-r--r-- | tests/usr.bin/indent/label.c | 3 | ||||
| -rw-r--r-- | usr.bin/indent/indent.c | 9 | ||||
| -rw-r--r-- | usr.bin/indent/indent.h | 11 |
3 files changed, 12 insertions, 11 deletions
diff --git a/tests/usr.bin/indent/label.c b/tests/usr.bin/indent/label.c index d9574c58000..48a1466d482 100644 --- a/tests/usr.bin/indent/label.c +++ b/tests/usr.bin/indent/label.c @@ -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 */ diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c index 5a1c46c9b7c..b504355ee1d 100644 --- a/usr.bin/indent/indent.c +++ b/usr.bin/indent/indent.c @@ -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.17 (Berkeley) 6/7/93"; #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); } diff --git a/usr.bin/indent/indent.h b/usr.bin/indent/indent.h index 32fc959c7fd..920e8284c0d 100644 --- a/usr.bin/indent/indent.h +++ b/usr.bin/indent/indent.h @@ -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; |
