Module Name:    src
Committed By:   rillig
Date:           Tue Oct  5 19:43:05 UTC 2021

Modified Files:
        src/tests/usr.bin/indent: opt-bacc.0 opt-bacc.0.stdout opt-nbacc.0
            opt-nbacc.0.stdout

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt-bacc.0 \
    src/tests/usr.bin/indent/opt-bacc.0.stdout \
    src/tests/usr.bin/indent/opt-nbacc.0 \
    src/tests/usr.bin/indent/opt-nbacc.0.stdout

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/opt-bacc.0
diff -u src/tests/usr.bin/indent/opt-bacc.0:1.2 src/tests/usr.bin/indent/opt-bacc.0:1.3
--- src/tests/usr.bin/indent/opt-bacc.0:1.2	Sat Mar  6 19:30:44 2021
+++ src/tests/usr.bin/indent/opt-bacc.0	Tue Oct  5 19:43:05 2021
@@ -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 @@ int		space_b;	/* FIXME: need no blank li
 #endif
 
 int		space_c;
+
+const char *
+os_name(void)
+{
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+	return "BSD";
+#else
+	return "unknown";
+#endif
+}
Index: src/tests/usr.bin/indent/opt-bacc.0.stdout
diff -u src/tests/usr.bin/indent/opt-bacc.0.stdout:1.2 src/tests/usr.bin/indent/opt-bacc.0.stdout:1.3
--- src/tests/usr.bin/indent/opt-bacc.0.stdout:1.2	Sat Mar  6 19:30:44 2021
+++ src/tests/usr.bin/indent/opt-bacc.0.stdout	Tue Oct  5 19:43:05 2021
@@ -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 @@ int		space_b;	/* FIXME: need no blank li
 #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'. */
+}
Index: src/tests/usr.bin/indent/opt-nbacc.0
diff -u src/tests/usr.bin/indent/opt-nbacc.0:1.2 src/tests/usr.bin/indent/opt-nbacc.0:1.3
--- src/tests/usr.bin/indent/opt-nbacc.0:1.2	Sat Mar  6 23:09:17 2021
+++ src/tests/usr.bin/indent/opt-nbacc.0	Tue Oct  5 19:43:05 2021
@@ -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 @@ int		space_b;
 #endif
 
 int		space_c;
+
+const char *
+os_name(void)
+{
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+	return "BSD";
+#else
+	return "unknown";
+#endif
+}
Index: src/tests/usr.bin/indent/opt-nbacc.0.stdout
diff -u src/tests/usr.bin/indent/opt-nbacc.0.stdout:1.2 src/tests/usr.bin/indent/opt-nbacc.0.stdout:1.3
--- src/tests/usr.bin/indent/opt-nbacc.0.stdout:1.2	Sat Mar  6 23:09:17 2021
+++ src/tests/usr.bin/indent/opt-nbacc.0.stdout	Tue Oct  5 19:43:05 2021
@@ -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 @@ int		space_b;
 #endif
 
 int		space_c;
+
+const char     *
+os_name(void)
+{
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+	return "BSD";
+#else
+	return "unknown";
+#endif
+}

Reply via email to