From 37a177106ac5b4b8c1ae16cac199560bbb9d1282 Mon Sep 17 00:00:00 2001 From: rillig Date: Fri, 16 Jun 2023 11:27:49 +0000 Subject: [PATCH] indent: rename a field of the parser state The previous name 'comment_in_first_line' was misleading, as it could mean that there was a comment in the first line of the file. No functional change. --- usr.bin/indent/debug.c | 6 +++--- usr.bin/indent/indent.h | 6 +++--- usr.bin/indent/io.c | 8 ++++---- usr.bin/indent/pr_comment.c | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/usr.bin/indent/debug.c b/usr.bin/indent/debug.c index 9ae26dbcf871..2ee4f8c6cc11 100644 --- a/usr.bin/indent/debug.c +++ b/usr.bin/indent/debug.c @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.62 2023/06/15 10:59:06 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.63 2023/06/16 11:27:49 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.62 2023/06/15 10:59:06 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.63 2023/06/16 11:27:49 rillig Exp $"); #include #include @@ -363,7 +363,7 @@ debug_parser_state(void) state.heading = "indentation of comments"; debug_ps_int(comment_ind); debug_ps_int(comment_shift); - debug_ps_bool(comment_in_first_line); + debug_ps_bool(comment_cont); state.heading = "vertical spacing"; debug_ps_bool(break_after_comma); diff --git a/usr.bin/indent/indent.h b/usr.bin/indent/indent.h index 6f8731973c8a..5c6662eec42d 100644 --- a/usr.bin/indent/indent.h +++ b/usr.bin/indent/indent.h @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.198 2023/06/15 10:59:06 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.199 2023/06/16 11:27:49 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -383,10 +383,10 @@ extern struct parser_state { /* Indentation of comments */ - int comment_ind; /* indentation of the current comment */ + int comment_ind; /* total indentation of the current comment */ int comment_shift; /* all but the first line of a boxed comment * are shifted this much to the right */ - bool comment_in_first_line; + bool comment_cont; /* after the first line of a comment */ /* Vertical spacing */ diff --git a/usr.bin/indent/io.c b/usr.bin/indent/io.c index 49de54edfd11..c5e7c1050c77 100644 --- a/usr.bin/indent/io.c +++ b/usr.bin/indent/io.c @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.225 2023/06/15 11:27:36 rillig Exp $ */ +/* $NetBSD: io.c,v 1.226 2023/06/16 11:27:49 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: io.c,v 1.225 2023/06/15 11:27:36 rillig Exp $"); +__RCSID("$NetBSD: io.c,v 1.226 2023/06/16 11:27:49 rillig Exp $"); #include @@ -300,9 +300,9 @@ output_comment(void) int target_ind = ps.comment_ind; const char *p; - if (!ps.comment_in_first_line) + if (ps.comment_cont) target_ind += ps.comment_shift; - ps.comment_in_first_line = false; + ps.comment_cont = true; /* consider the original indentation in case this is a box comment */ for (p = com.s; *p == '\t'; p++) diff --git a/usr.bin/indent/pr_comment.c b/usr.bin/indent/pr_comment.c index c51347f9088b..866c9b86fd74 100644 --- a/usr.bin/indent/pr_comment.c +++ b/usr.bin/indent/pr_comment.c @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.165 2023/06/14 14:11:28 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.166 2023/06/16 11:27:49 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: pr_comment.c,v 1.165 2023/06/14 14:11:28 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.166 2023/06/16 11:27:49 rillig Exp $"); #include @@ -142,7 +142,7 @@ analyze_comment(bool *p_may_wrap, bool *p_delim, int *p_line_length) static void copy_comment_start(bool may_wrap, bool *delim, int line_length) { - ps.comment_in_first_line = true; + ps.comment_cont = false; com_add_char('/'); com_add_char(token.s[token.len - 1]); /* either '*' or '/' */