indent: format its own code
This commit is contained in:
parent
0fcafc89fc
commit
545ff05aaa
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: indent.c,v 1.341 2023/06/08 21:18:54 rillig Exp $ */
|
/* $NetBSD: indent.c,v 1.342 2023/06/09 07:20:30 rillig Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-4-Clause
|
* SPDX-License-Identifier: BSD-4-Clause
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: indent.c,v 1.341 2023/06/08 21:18:54 rillig Exp $");
|
__RCSID("$NetBSD: indent.c,v 1.342 2023/06/09 07:20:30 rillig Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
@ -569,7 +569,7 @@ process_unary_op(void)
|
||||||
indent_declarator(ind, ps.tabs_to_var);
|
indent_declarator(ind, ps.tabs_to_var);
|
||||||
ps.want_blank = false;
|
ps.want_blank = false;
|
||||||
} else if ((token.s[0] == '+' || token.s[0] == '-')
|
} else if ((token.s[0] == '+' || token.s[0] == '-')
|
||||||
&& code.len > 0 && code.s[code.len - 1] == token.s[0])
|
&& code.len > 0 && code.s[code.len - 1] == token.s[0])
|
||||||
ps.want_blank = true;
|
ps.want_blank = true;
|
||||||
|
|
||||||
if (ps.want_blank)
|
if (ps.want_blank)
|
||||||
|
@ -682,7 +682,7 @@ process_lbrace(void)
|
||||||
if (ps.prev_lsym == lsym_rparen
|
if (ps.prev_lsym == lsym_rparen
|
||||||
&& ps.psyms.top >= 2
|
&& ps.psyms.top >= 2
|
||||||
&& !(psym == psym_for_exprs || psym == psym_if_expr
|
&& !(psym == psym_for_exprs || psym == psym_if_expr
|
||||||
|| psym == psym_switch_expr || psym == psym_while_expr)) {
|
|| psym == psym_switch_expr || psym == psym_while_expr)) {
|
||||||
ps.block_init = true;
|
ps.block_init = true;
|
||||||
ps.init_or_struct = true;
|
ps.init_or_struct = true;
|
||||||
}
|
}
|
||||||
|
@ -901,8 +901,8 @@ process_comma(void)
|
||||||
ps.block_init = false;
|
ps.block_init = false;
|
||||||
int typical_varname_length = 8;
|
int typical_varname_length = 8;
|
||||||
if (ps.break_after_comma && (opt.break_after_comma ||
|
if (ps.break_after_comma && (opt.break_after_comma ||
|
||||||
ind_add(compute_code_indent(), code.s, code.len)
|
ind_add(compute_code_indent(), code.s, code.len)
|
||||||
>= opt.max_line_length - typical_varname_length))
|
>= opt.max_line_length - typical_varname_length))
|
||||||
ps.force_nl = true;
|
ps.force_nl = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: io.c,v 1.205 2023/06/09 06:36:57 rillig Exp $ */
|
/* $NetBSD: io.c,v 1.206 2023/06/09 07:20:30 rillig Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-4-Clause
|
* SPDX-License-Identifier: BSD-4-Clause
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: io.c,v 1.205 2023/06/09 06:36:57 rillig Exp $");
|
__RCSID("$NetBSD: io.c,v 1.206 2023/06/09 07:20:30 rillig Exp $");
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ prepare_next_line:
|
||||||
if (ps.extra_expr_indent == eei_last)
|
if (ps.extra_expr_indent == eei_last)
|
||||||
ps.extra_expr_indent = eei_no;
|
ps.extra_expr_indent = eei_no;
|
||||||
if (!(ps.psyms.sym[ps.psyms.top] == psym_if_expr_stmt_else
|
if (!(ps.psyms.sym[ps.psyms.top] == psym_if_expr_stmt_else
|
||||||
&& ps.nparen > 0))
|
&& ps.nparen > 0))
|
||||||
ps.ind_level = ps.ind_level_follow;
|
ps.ind_level = ps.ind_level_follow;
|
||||||
ps.line_start_nparen = ps.nparen;
|
ps.line_start_nparen = ps.nparen;
|
||||||
ps.want_blank = false;
|
ps.want_blank = false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: lexi.c,v 1.217 2023/06/08 21:18:54 rillig Exp $ */
|
/* $NetBSD: lexi.c,v 1.218 2023/06/09 07:20:30 rillig Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-4-Clause
|
* SPDX-License-Identifier: BSD-4-Clause
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: lexi.c,v 1.217 2023/06/08 21:18:54 rillig Exp $");
|
__RCSID("$NetBSD: lexi.c,v 1.218 2023/06/09 07:20:30 rillig Exp $");
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -689,7 +689,7 @@ register_typename(const char *name)
|
||||||
if (typenames.len >= typenames.cap) {
|
if (typenames.len >= typenames.cap) {
|
||||||
typenames.cap = 16 + 2 * typenames.cap;
|
typenames.cap = 16 + 2 * typenames.cap;
|
||||||
typenames.items = nonnull(realloc(typenames.items,
|
typenames.items = nonnull(realloc(typenames.items,
|
||||||
sizeof(typenames.items[0]) * typenames.cap));
|
sizeof(typenames.items[0]) * typenames.cap));
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos = bsearch_typenames(name);
|
int pos = bsearch_typenames(name);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: parse.c,v 1.69 2023/06/07 15:46:12 rillig Exp $ */
|
/* $NetBSD: parse.c,v 1.70 2023/06/09 07:20:30 rillig Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-4-Clause
|
* SPDX-License-Identifier: BSD-4-Clause
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: parse.c,v 1.69 2023/06/07 15:46:12 rillig Exp $");
|
__RCSID("$NetBSD: parse.c,v 1.70 2023/06/09 07:20:30 rillig Exp $");
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ parse(parser_symbol psym)
|
||||||
case psym_rbrace:
|
case psym_rbrace:
|
||||||
/* stack should have <lbrace> <stmt> or <lbrace> <stmt_list> */
|
/* stack should have <lbrace> <stmt> or <lbrace> <stmt_list> */
|
||||||
if (!(psyms->top > 0
|
if (!(psyms->top > 0
|
||||||
&& is_lbrace(psyms->sym[psyms->top - 1]))) {
|
&& is_lbrace(psyms->sym[psyms->top - 1]))) {
|
||||||
diag(1, "Statement nesting error");
|
diag(1, "Statement nesting error");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: pr_comment.c,v 1.157 2023/06/09 07:18:52 rillig Exp $ */
|
/* $NetBSD: pr_comment.c,v 1.158 2023/06/09 07:20:30 rillig Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-4-Clause
|
* SPDX-License-Identifier: BSD-4-Clause
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: pr_comment.c,v 1.157 2023/06/09 07:18:52 rillig Exp $");
|
__RCSID("$NetBSD: pr_comment.c,v 1.158 2023/06/09 07:20:30 rillig Exp $");
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -198,9 +198,8 @@ copy_comment_wrap_text(int line_length, ssize_t *last_blank)
|
||||||
output_line();
|
output_line();
|
||||||
com_add_delim();
|
com_add_delim();
|
||||||
|
|
||||||
/* Assume that output_line and com_add_delim don't
|
/* Assume that output_line and com_add_delim don't invalidate the
|
||||||
* invalidate the "unused" part of the buffer beyond
|
* "unused" part of the buffer beyond com.s + com.len. */
|
||||||
* com.s + com.len. */
|
|
||||||
memmove(com.s + com.len, last_word_s, last_word_len);
|
memmove(com.s + com.len, last_word_s, last_word_len);
|
||||||
com.len += last_word_len;
|
com.len += last_word_len;
|
||||||
*last_blank = -1;
|
*last_blank = -1;
|
||||||
|
|
Loading…
Reference in New Issue