indent: do not add a blank at the beginning of a line
Most calls to output_line did already reset the variable. There may be some untested edge cases in or after comments, but these should be fine as well.
This commit is contained in:
parent
c49e59f750
commit
ee7d9431ec
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: indent.c,v 1.262 2023/05/13 16:40:18 rillig Exp $ */
|
/* $NetBSD: indent.c,v 1.263 2023/05/13 17:20:41 rillig Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-4-Clause
|
* 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>
|
#include <sys/cdefs.h>
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
__RCSID("$NetBSD: indent.c,v 1.262 2023/05/13 16:40:18 rillig Exp $");
|
__RCSID("$NetBSD: indent.c,v 1.263 2023/05/13 17:20:41 rillig Exp $");
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
|
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
|
||||||
#endif
|
#endif
|
||||||
|
@ -406,7 +406,6 @@ maybe_break_line(lexer_symbol lsym)
|
||||||
if (opt.verbose)
|
if (opt.verbose)
|
||||||
diag(0, "Line broken");
|
diag(0, "Line broken");
|
||||||
output_line();
|
output_line();
|
||||||
ps.want_blank = false;
|
|
||||||
ps.force_nl = false;
|
ps.force_nl = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +437,6 @@ process_newline(void)
|
||||||
goto stay_in_line;
|
goto stay_in_line;
|
||||||
|
|
||||||
output_line();
|
output_line();
|
||||||
ps.want_blank = false;
|
|
||||||
|
|
||||||
stay_in_line:
|
stay_in_line:
|
||||||
++line_no;
|
++line_no;
|
||||||
|
@ -679,16 +677,13 @@ process_lbrace(void)
|
||||||
ps.block_init_level++;
|
ps.block_init_level++;
|
||||||
|
|
||||||
if (code.s != code.e && !ps.block_init) {
|
if (code.s != code.e && !ps.block_init) {
|
||||||
if (!opt.brace_same_line) {
|
if (!opt.brace_same_line)
|
||||||
output_line();
|
output_line();
|
||||||
ps.want_blank = false;
|
else if (ps.in_func_def_params && !ps.init_or_struct) {
|
||||||
} else if (ps.in_func_def_params && !ps.init_or_struct) {
|
|
||||||
ps.ind_level_follow = 0;
|
ps.ind_level_follow = 0;
|
||||||
if (opt.function_brace_split) { /* dump the line prior to the
|
if (opt.function_brace_split)
|
||||||
* brace ... */
|
|
||||||
output_line();
|
output_line();
|
||||||
ps.want_blank = false;
|
else
|
||||||
} else /* add a space between the decl and brace */
|
|
||||||
ps.want_blank = true;
|
ps.want_blank = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -774,7 +769,6 @@ process_do(void)
|
||||||
if (opt.verbose)
|
if (opt.verbose)
|
||||||
diag(0, "Line broken");
|
diag(0, "Line broken");
|
||||||
output_line();
|
output_line();
|
||||||
ps.want_blank = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.force_nl = true;
|
ps.force_nl = true;
|
||||||
|
@ -789,8 +783,7 @@ process_else(void)
|
||||||
if (code.e > code.s && !(opt.cuddle_else && code.e[-1] == '}')) {
|
if (code.e > code.s && !(opt.cuddle_else && code.e[-1] == '}')) {
|
||||||
if (opt.verbose)
|
if (opt.verbose)
|
||||||
diag(0, "Line broken");
|
diag(0, "Line broken");
|
||||||
output_line(); /* make sure this starts a line */
|
output_line();
|
||||||
ps.want_blank = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.force_nl = true;
|
ps.force_nl = true;
|
||||||
|
@ -803,10 +796,8 @@ process_type(void)
|
||||||
parse(psym_decl); /* let the parser worry about indentation */
|
parse(psym_decl); /* let the parser worry about indentation */
|
||||||
|
|
||||||
if (ps.prev_token == lsym_rparen_or_rbracket && ps.tos <= 1) {
|
if (ps.prev_token == lsym_rparen_or_rbracket && ps.tos <= 1) {
|
||||||
if (code.s != code.e) {
|
if (code.s != code.e)
|
||||||
output_line();
|
output_line();
|
||||||
ps.want_blank = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.in_func_def_params && opt.indent_parameters &&
|
if (ps.in_func_def_params && opt.indent_parameters &&
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: io.c,v 1.160 2023/05/13 15:34:22 rillig Exp $ */
|
/* $NetBSD: io.c,v 1.161 2023/05/13 17:20:41 rillig Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-4-Clause
|
* SPDX-License-Identifier: BSD-4-Clause
|
||||||
|
@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93";
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
__RCSID("$NetBSD: io.c,v 1.160 2023/05/13 15:34:22 rillig Exp $");
|
__RCSID("$NetBSD: io.c,v 1.161 2023/05/13 17:20:41 rillig Exp $");
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
|
__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
|
||||||
#endif
|
#endif
|
||||||
|
@ -331,6 +331,8 @@ output_complete_line(char line_terminator)
|
||||||
paren_indent = -1 - ps.paren[ps.nparen - 1].indent;
|
paren_indent = -1 - ps.paren[ps.nparen - 1].indent;
|
||||||
debug_println("paren_indent is now %d", paren_indent);
|
debug_println("paren_indent is now %d", paren_indent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ps.want_blank = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue