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: don't insert blank line between two c...



details:   https://anonhg.NetBSD.org/src/rev/f74f71aa6ff8
branches:  trunk
changeset: 375904:f74f71aa6ff8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat May 20 12:05:01 2023 +0000

description:
indent: don't insert blank line between two closing lines

diffstat:

 tests/usr.bin/indent/opt_bap.c |  18 +++++++++++++++++-
 usr.bin/indent/io.c            |   7 ++++---
 2 files changed, 21 insertions(+), 4 deletions(-)

diffs (57 lines):

diff -r 46e947100fda -r f74f71aa6ff8 tests/usr.bin/indent/opt_bap.c
--- a/tests/usr.bin/indent/opt_bap.c    Sat May 20 11:53:53 2023 +0000
+++ b/tests/usr.bin/indent/opt_bap.c    Sat May 20 12:05:01 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bap.c,v 1.7 2023/05/20 10:46:22 rillig Exp $ */
+/* $NetBSD: opt_bap.c,v 1.8 2023/05/20 12:05:01 rillig Exp $ */
 
 /*
  * Tests for the options '-bap' and '-nbap' ("blank line after procedure
@@ -95,3 +95,19 @@ has_several_blank_lines_below(void)
 
 int            the_end;
 //indent end
+
+
+/*
+ * Don't insert a blank line between the end of a function body and an '#endif'
+ * line, as both are closing elements.
+ */
+//indent input
+#if 0
+void
+example(void)
+{
+}
+#endif
+//indent end
+
+//indent run-equals-input -bap
diff -r 46e947100fda -r f74f71aa6ff8 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Sat May 20 11:53:53 2023 +0000
+++ b/usr.bin/indent/io.c       Sat May 20 12:05:01 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.183 2023/05/20 11:53:53 rillig Exp $  */
+/*     $NetBSD: io.c,v 1.184 2023/05/20 12:05:01 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.183 2023/05/20 11:53:53 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.184 2023/05/20 12:05:01 rillig Exp $");
 
 #include <stdio.h>
 
@@ -152,7 +152,8 @@ want_blank_line(void)
                    && out.line_kind != lk_endif)
                        return true;
        }
-       if (opt.blanklines_after_procs && out.prev_line_kind == lk_func_end)
+       if (opt.blanklines_after_procs && out.prev_line_kind == lk_func_end
+           && out.line_kind != lk_endif)
                return true;
        if (opt.blanklines_before_block_comments
            && out.line_kind == lk_block_comment)



Home | Main Index | Thread Index | Old Index