Module Name: src Committed By: rillig Date: Thu Nov 25 07:45:32 UTC 2021
Modified Files: src/usr.bin/indent: indent.c indent.h io.c lexi.c Log Message: indent: rename ps.in_stmt to in_stmt_or_decl The previous name didn't match reality. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.230 -r1.231 src/usr.bin/indent/indent.c cvs rdiff -u -r1.99 -r1.100 src/usr.bin/indent/indent.h cvs rdiff -u -r1.130 -r1.131 src/usr.bin/indent/io.c cvs rdiff -u -r1.151 -r1.152 src/usr.bin/indent/lexi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.230 src/usr.bin/indent/indent.c:1.231 --- src/usr.bin/indent/indent.c:1.230 Thu Nov 25 07:41:13 2021 +++ src/usr.bin/indent/indent.c Thu Nov 25 07:45:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.230 2021/11/25 07:41:13 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.231 2021/11/25 07:45:32 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.230 2021/11/25 07:41:13 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.231 2021/11/25 07:45:32 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); #endif @@ -730,7 +730,8 @@ process_rparen_or_rbracket(bool *spaced_ *spaced_expr = false; *force_nl = true; /* must force newline after if */ ps.next_unary = true; - ps.in_stmt = false; /* don't use stmt continuation indentation */ + ps.in_stmt_or_decl = false; /* don't use stmt continuation + * indentation */ parse_stmt_head(hd); } @@ -817,7 +818,7 @@ process_colon(int *quest_level, bool *fo buf_terminate(&lab); buf_reset(&code); - ps.in_stmt = false; + ps.in_stmt_or_decl = false; ps.is_case_label = *seen_case; *force_nl = *seen_case; *seen_case = false; @@ -866,7 +867,7 @@ process_semicolon(bool *seen_case, int * } *code.e++ = ';'; ps.want_blank = true; - ps.in_stmt = ps.p_l_follow > 0; + ps.in_stmt_or_decl = ps.p_l_follow > 0; if (!*spaced_expr) { /* if not if for (;;) */ parse(psym_semicolon); /* let parser know about end of stmt */ @@ -878,7 +879,7 @@ static void process_lbrace(bool *force_nl, bool *spaced_expr, stmt_head hd, int *di_stack, int di_stack_cap, int *decl_ind) { - ps.in_stmt = false; /* don't indent the {} */ + ps.in_stmt_or_decl = false; /* don't indent the {} */ if (!ps.block_init) *force_nl = true; /* force other stuff on same line as '{' onto @@ -969,7 +970,7 @@ process_rbrace(bool *spaced_expr, int *d *code.e++ = '}'; ps.want_blank = true; - ps.in_stmt = false; + ps.in_stmt_or_decl = false; ps.in_stmt_cont = false; if (ps.decl_level > 0) { /* we are in multi-level structure declaration */ @@ -995,7 +996,7 @@ process_rbrace(bool *spaced_expr, int *d static void process_do(bool *force_nl, bool *last_else) { - ps.in_stmt = false; + ps.in_stmt_or_decl = false; if (code.e != code.s) { /* make sure this starts a line */ if (opt.verbose) @@ -1012,7 +1013,7 @@ process_do(bool *force_nl, bool *last_el static void process_else(bool *force_nl, bool *last_else) { - ps.in_stmt = false; + ps.in_stmt_or_decl = false; if (code.e > code.s && !(opt.cuddle_else && code.e[-1] == '}')) { if (opt.verbose) @@ -1085,7 +1086,7 @@ process_ident(lexer_symbol lsym, int dec *spaced_expr = false; *force_nl = true; ps.next_unary = true; - ps.in_stmt = false; + ps.in_stmt_or_decl = false; parse_stmt_head(hd); } } @@ -1298,8 +1299,8 @@ main_loop(void) force_nl = false; else if (lsym != lsym_comment) { maybe_break_line(lsym, &force_nl); - ps.in_stmt = true; /* add an extra level of indentation; turned - * off again by a ';' or '}' */ + ps.in_stmt_or_decl = true; /* add an extra level of indentation; + * turned off again by a ';' or '}' */ if (com.s != com.e) move_com_to_code(); } Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.99 src/usr.bin/indent/indent.h:1.100 --- src/usr.bin/indent/indent.h:1.99 Thu Nov 25 07:41:13 2021 +++ src/usr.bin/indent/indent.h Thu Nov 25 07:45:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.99 2021/11/25 07:41:13 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.100 2021/11/25 07:45:32 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -313,9 +313,8 @@ extern struct parser_state { bool decl_indent_done; /* whether the indentation for a declaration * has been added to the code buffer. */ - bool in_stmt; /* TODO: rename to something appropriate; this - * is set to true in struct declarations as - * well, so 'stmt' isn't accurate */ + bool in_stmt_or_decl; /* whether in a statement or a struct + * declaration or a plain declaration */ bool in_stmt_cont; /* whether the next line should have an extra * indentation level because we are in the * middle of a statement */ Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.130 src/usr.bin/indent/io.c:1.131 --- src/usr.bin/indent/io.c:1.130 Thu Nov 25 07:41:13 2021 +++ src/usr.bin/indent/io.c Thu Nov 25 07:45:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.130 2021/11/25 07:41:13 rillig Exp $ */ +/* $NetBSD: io.c,v 1.131 2021/11/25 07:45:32 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c 8.1 (Be #include <sys/cdefs.h> #if defined(__NetBSD__) -__RCSID("$NetBSD: io.c,v 1.130 2021/11/25 07:41:13 rillig Exp $"); +__RCSID("$NetBSD: io.c,v 1.131 2021/11/25 07:45:32 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $"); #endif @@ -496,7 +496,7 @@ output_line(char line_terminator) } ps.decl_on_line = ps.in_decl; /* for proper comment indentation */ - ps.in_stmt_cont = ps.in_stmt && !ps.in_decl; + ps.in_stmt_cont = ps.in_stmt_or_decl && !ps.in_decl; ps.decl_indent_done = false; *(lab.e = lab.s) = '\0'; /* reset buffers */ Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.151 src/usr.bin/indent/lexi.c:1.152 --- src/usr.bin/indent/lexi.c:1.151 Thu Nov 25 07:41:13 2021 +++ src/usr.bin/indent/lexi.c Thu Nov 25 07:45:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.151 2021/11/25 07:41:13 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.152 2021/11/25 07:45:32 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c 8.1 ( #include <sys/cdefs.h> #if defined(__NetBSD__) -__RCSID("$NetBSD: lexi.c,v 1.151 2021/11/25 07:41:13 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.152 2021/11/25 07:45:32 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $"); #endif @@ -304,7 +304,7 @@ debug_lexi(lexer_symbol lsym) debug_ps_bool(in_parameter_declaration); debug_ps_bool(decl_indent_done); - debug_ps_bool(in_stmt); + debug_ps_bool(in_stmt_or_decl); debug_ps_bool(in_stmt_cont); debug_ps_bool(is_case_label); @@ -396,7 +396,7 @@ lex_char_or_string(void) static bool probably_typename(void) { - if (ps.block_init || ps.in_stmt) + if (ps.block_init || ps.in_stmt_or_decl) return false; if (inp_peek() == '*' && inp_lookahead(1) != '=') goto maybe;