Module Name: src
Committed By: rillig
Date: Fri Jun 16 11:27:49 UTC 2023
Modified Files:
src/usr.bin/indent: debug.c indent.h io.c pr_comment.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.198 -r1.199 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.225 -r1.226 src/usr.bin/indent/io.c
cvs rdiff -u -r1.165 -r1.166 src/usr.bin/indent/pr_comment.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/debug.c
diff -u src/usr.bin/indent/debug.c:1.62 src/usr.bin/indent/debug.c:1.63
--- src/usr.bin/indent/debug.c:1.62 Thu Jun 15 10:59:06 2023
+++ src/usr.bin/indent/debug.c Fri Jun 16 11:27:49 2023
@@ -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 <sys/cdefs.h>
-__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 <stdarg.h>
#include <string.h>
@@ -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);
Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.198 src/usr.bin/indent/indent.h:1.199
--- src/usr.bin/indent/indent.h:1.198 Thu Jun 15 10:59:06 2023
+++ src/usr.bin/indent/indent.h Fri Jun 16 11:27:49 2023
@@ -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 */
Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.225 src/usr.bin/indent/io.c:1.226
--- src/usr.bin/indent/io.c:1.225 Thu Jun 15 11:27:36 2023
+++ src/usr.bin/indent/io.c Fri Jun 16 11:27:49 2023
@@ -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 <sys/cdefs.h>
-__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 <stdio.h>
@@ -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++)
Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.165 src/usr.bin/indent/pr_comment.c:1.166
--- src/usr.bin/indent/pr_comment.c:1.165 Wed Jun 14 14:11:28 2023
+++ src/usr.bin/indent/pr_comment.c Fri Jun 16 11:27:49 2023
@@ -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 <sys/cdefs.h>
-__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 <string.h>
@@ -142,7 +142,7 @@ analyze_comment(bool *p_may_wrap, bool *
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 '/' */