Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/indent indent: fix vertical spacing after declarations



details:   https://anonhg.NetBSD.org/src/rev/7f118440aa2c
branches:  trunk
changeset: 375310:7f118440aa2c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun May 14 16:47:06 2023 +0000

description:
indent: fix vertical spacing after declarations

A comment is not supposed to change the state of the 'blank line after
declaration', but it did.  The initialization of saved_just_saw_decl was
wrong though since it tried to capture the previous value after it had
already been overwritten.

diffstat:

 tests/usr.bin/indent/opt_bad.c |   4 ++--
 usr.bin/indent/pr_comment.c    |  10 +++-------
 2 files changed, 5 insertions(+), 9 deletions(-)

diffs (60 lines):

diff -r ae812f3aaf49 -r 7f118440aa2c tests/usr.bin/indent/opt_bad.c
--- a/tests/usr.bin/indent/opt_bad.c    Sun May 14 16:13:05 2023 +0000
+++ b/tests/usr.bin/indent/opt_bad.c    Sun May 14 16:47:06 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bad.c,v 1.9 2023/05/13 15:34:22 rillig Exp $ */
+/* $NetBSD: opt_bad.c,v 1.10 2023/05/14 16:47:06 rillig Exp $ */
 
 /*
  * Tests for the options '-bad' and '-nbad'.
@@ -110,8 +110,8 @@ comments(void)
 {
        int local_var_1;        /* comment */
        int local_var_2;        /* comment */
+
        /* comment line */
-       /* $ TODO: Add blank line here. */
        function_call();
 }
 //indent end
diff -r ae812f3aaf49 -r 7f118440aa2c usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c       Sun May 14 16:13:05 2023 +0000
+++ b/usr.bin/indent/pr_comment.c       Sun May 14 16:47:06 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pr_comment.c,v 1.134 2023/05/14 14:14:07 rillig Exp $  */
+/*     $NetBSD: pr_comment.c,v 1.135 2023/05/14 16:47:06 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pr_comment.c,v 1.134 2023/05/14 14:14:07 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.135 2023/05/14 16:47:06 rillig Exp $");
 
 #include <string.h>
 
@@ -111,7 +111,7 @@ analyze_comment(bool *p_may_wrap, bool *
         * XXX: This condition looks suspicious since it ignores the case
         * where the end of the previous comment is still in 'com'.
         *
-        * See test token_comment.c, keyword 'analyze_comment'.
+        * See test lsym_comment.c, keyword 'analyze_comment'.
         */
        if (lab.s == lab.e && code.s == code.e) {
            adj_max_line_length = opt.block_comment_max_line_length;
@@ -340,13 +340,9 @@ process_comment(void)
     int adj_max_line_length;
     bool may_wrap, break_delim;
 
-    ps.declaration = decl_no;
-
-    enum declaration saved_just_saw_decl = ps.declaration;
     analyze_comment(&may_wrap, &break_delim, &adj_max_line_length);
     if (may_wrap)
        copy_comment_wrap(adj_max_line_length, break_delim);
     else
        copy_comment_nowrap();
-    ps.declaration = saved_just_saw_decl;
 }



Home | Main Index | Thread Index | Old Index