indent: rename variables, clean up comments
No binary change.
This commit is contained in:
parent
a28f6dc620
commit
d38f57a8f4
|
@ -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 <sys/cdefs.h>
|
||||
__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),
|
||||
|
|
|
@ -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 <sys/cdefs.h>
|
||||
__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 <sys/param.h>
|
||||
#include <err.h>
|
||||
|
@ -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)
|
||||
|
|
|
@ -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_in_same_line;
|
||||
bool function_brace_split; /* split function declaration and brace
|
||||
* onto separate lines */
|
||||
bool format_col1_comments; /* If comments which start in column 1
|
||||
|
@ -230,12 +229,11 @@ extern struct options {
|
|||
* lined up to the open paren */
|
||||
bool proc_calls_space; /* whether function calls look like: foo (bar)
|
||||
* rather than foo(bar) */
|
||||
bool procnames_start_line; /* whether the names of procedures
|
||||
* being defined get placed in column 1
|
||||
* (i.e. a newline is placed between
|
||||
* the type of the procedure and its
|
||||
* name) */
|
||||
bool space_after_cast; /* "b = (int) a" vs "b = (int)a" */
|
||||
bool procnames_start_line; /* whether the names of functions being
|
||||
* defined get placed in column 1 (i.e.
|
||||
* a newline is placed between the type
|
||||
* of the function and its name) */
|
||||
bool space_after_cast; /* "b = (int) a" vs. "b = (int)a" */
|
||||
bool star_comment_cont; /* whether comment continuation lines should
|
||||
* have stars at the beginning of each line */
|
||||
bool swallow_optional_blanklines;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: parse.c,v 1.65 2023/06/04 17:54:11 rillig Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.66 2023/06/05 07:35:05 rillig Exp $ */
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-4-Clause
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: parse.c,v 1.65 2023/06/04 17:54:11 rillig Exp $");
|
||||
__RCSID("$NetBSD: parse.c,v 1.66 2023/06/05 07:35:05 rillig Exp $");
|
||||
|
||||
#include <err.h>
|
||||
|
||||
|
@ -105,12 +105,13 @@ parse(parser_symbol psym)
|
|||
ps.break_after_comma = true;
|
||||
ps_push_follow(psym_decl);
|
||||
|
||||
if (opt.ljust_decl)
|
||||
if (opt.left_justify_decl)
|
||||
ps.ind_level_follow = ps.ind_level = decl_level();
|
||||
break;
|
||||
|
||||
case psym_if_expr:
|
||||
if (ps.s_sym[ps.tos] == psym_if_expr_stmt_else && opt.else_if)
|
||||
if (ps.s_sym[ps.tos] == psym_if_expr_stmt_else
|
||||
&& opt.else_if_in_same_line)
|
||||
ps.ind_level_follow = ps.s_ind_level[ps.tos--];
|
||||
/* FALLTHROUGH */
|
||||
case psym_do:
|
||||
|
|
Loading…
Reference in New Issue