Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/indent tests/indent: demonstrate bugs in -bacc...



details:   https://anonhg.NetBSD.org/src/rev/3f15d4ead664
branches:  trunk
changeset: 988257:3f15d4ead664
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Oct 05 19:43:05 2021 +0000

description:
tests/indent: demonstrate bugs in -bacc and -nbacc

This part of indent has been broken since at least 2000. The update from
FreeBSD indent on 2019-04-04 made it worse than before.

To see the various results over time, older versions of indent compile
fine if they get passed the -fcommon compiler option.

diffstat:

 tests/usr.bin/indent/opt-bacc.0         |  21 ++++++++++++++++++++-
 tests/usr.bin/indent/opt-bacc.0.stdout  |  27 ++++++++++++++++++++++++++-
 tests/usr.bin/indent/opt-nbacc.0        |  12 +++++++++++-
 tests/usr.bin/indent/opt-nbacc.0.stdout |  12 +++++++++++-
 4 files changed, 68 insertions(+), 4 deletions(-)

diffs (120 lines):

diff -r 1a2111329f2c -r 3f15d4ead664 tests/usr.bin/indent/opt-bacc.0
--- a/tests/usr.bin/indent/opt-bacc.0   Tue Oct 05 18:50:42 2021 +0000
+++ b/tests/usr.bin/indent/opt-bacc.0   Tue Oct 05 19:43:05 2021 +0000
@@ -1,6 +1,15 @@
-/* $NetBSD: opt-bacc.0,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
+/* $NetBSD: opt-bacc.0,v 1.3 2021/10/05 19:43:05 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Test the option -bacc, which forces a blank line around every conditional
+ * compilation block.  For example, in front of every #ifdef and after every
+ * #endif.  Other blank lines surrounding such blocks are swallowed.
+ *
+ * XXX: As of 2021-10-05, the option -bacc has no effect on declarations since
+ * process_decl resets prefix_blankline_requested unconditionally.
+ */
+
 int            a;
 #if 0                          /* FIXME: need blank line above */
 int            b;
@@ -17,3 +26,13 @@
 #endif
 
 int            space_c;
+
+const char *
+os_name(void)
+{
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+       return "BSD";
+#else
+       return "unknown";
+#endif
+}
diff -r 1a2111329f2c -r 3f15d4ead664 tests/usr.bin/indent/opt-bacc.0.stdout
--- a/tests/usr.bin/indent/opt-bacc.0.stdout    Tue Oct 05 18:50:42 2021 +0000
+++ b/tests/usr.bin/indent/opt-bacc.0.stdout    Tue Oct 05 19:43:05 2021 +0000
@@ -1,6 +1,15 @@
-/* $NetBSD: opt-bacc.0.stdout,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
+/* $NetBSD: opt-bacc.0.stdout,v 1.3 2021/10/05 19:43:05 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Test the option -bacc, which forces a blank line around every conditional
+ * compilation block.  For example, in front of every #ifdef and after every
+ * #endif.  Other blank lines surrounding such blocks are swallowed.
+ *
+ * XXX: As of 2021-10-05, the option -bacc has no effect on declarations since
+ * process_decl resets prefix_blankline_requested unconditionally.
+ */
+
 int            a;
 #if 0                          /* FIXME: need blank line above */
 int            b;
@@ -15,3 +24,19 @@
 #endif
 
 int            space_c;
+
+/* $ XXX: The '*' should not be set apart from the rest of the return type. */
+const char     *
+os_name(void)
+{
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+
+/* $ FIXME: This empty line _below_ the '#if' contradicts the manual page. */
+       return "BSD";
+#else
+
+/* $ FIXME: This empty line _below_ the '#else' contradicts the manual page. */
+       return "unknown";
+#endif
+/* $ FIXME: There should be an empty line after the '#endif'. */
+}
diff -r 1a2111329f2c -r 3f15d4ead664 tests/usr.bin/indent/opt-nbacc.0
--- a/tests/usr.bin/indent/opt-nbacc.0  Tue Oct 05 18:50:42 2021 +0000
+++ b/tests/usr.bin/indent/opt-nbacc.0  Tue Oct 05 19:43:05 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt-nbacc.0,v 1.2 2021/03/06 23:09:17 rillig Exp $ */
+/* $NetBSD: opt-nbacc.0,v 1.3 2021/10/05 19:43:05 rillig Exp $ */
 /* $FreeBSD$ */
 
 int            a;
@@ -17,3 +17,13 @@
 #endif
 
 int            space_c;
+
+const char *
+os_name(void)
+{
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+       return "BSD";
+#else
+       return "unknown";
+#endif
+}
diff -r 1a2111329f2c -r 3f15d4ead664 tests/usr.bin/indent/opt-nbacc.0.stdout
--- a/tests/usr.bin/indent/opt-nbacc.0.stdout   Tue Oct 05 18:50:42 2021 +0000
+++ b/tests/usr.bin/indent/opt-nbacc.0.stdout   Tue Oct 05 19:43:05 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt-nbacc.0.stdout,v 1.2 2021/03/06 23:09:17 rillig Exp $ */
+/* $NetBSD: opt-nbacc.0.stdout,v 1.3 2021/10/05 19:43:05 rillig Exp $ */
 /* $FreeBSD$ */
 
 int            a;
@@ -17,3 +17,13 @@
 #endif
 
 int            space_c;
+
+const char     *
+os_name(void)
+{
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+       return "BSD";
+#else
+       return "unknown";
+#endif
+}



Home | Main Index | Thread Index | Old Index