Module Name:    src
Committed By:   rillig
Date:           Wed Oct 27 00:04:51 UTC 2021

Modified Files:
        src/tests/usr.bin/indent: fmt_decl.c
        src/usr.bin/indent: io.c

Log Message:
indent: fix indentation of local variable declarations

This had been broken since the import of FreeBSD indent in 2019.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/indent/io.c

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/fmt_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.5 src/tests/usr.bin/indent/fmt_decl.c:1.6
--- src/tests/usr.bin/indent/fmt_decl.c:1.5	Tue Oct 26 23:58:40 2021
+++ src/tests/usr.bin/indent/fmt_decl.c	Wed Oct 27 00:04:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmt_decl.c,v 1.5 2021/10/26 23:58:40 rillig Exp $	*/
+/*	$NetBSD: fmt_decl.c,v 1.6 2021/10/27 00:04:51 rillig Exp $	*/
 /* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
 
 /* See FreeBSD r303570 */
@@ -365,15 +365,18 @@ int main(void) {
 }
 #indent end
 
+/*
+ * Before NetBSD io.c 1.103 from 2021-10-27, indent wrongly placed the second
+ * and third variable declaration in column 1. This bug has been introduced
+ * to NetBSD when FreeBSD indent was imported in 2019.
+ */
 #indent run -ldi0
 int
 main(void)
 {
 	char (*f1)() = NULL;
-/* $ FIXME: The following declaration must be indented. */
-char *(*f1)() = NULL;
-/* $ FIXME: The following declaration must be indented. */
-char *(*f2)();
+	char *(*f1)() = NULL;
+	char *(*f2)();
 }
 #indent end
 
@@ -383,11 +386,9 @@ main(void)
 {
 /* $ XXX: Not really pretty, the name 'f1' should be aligned, if at all. */
 	char		(*f1)() = NULL;
-/* $ FIXME: The following declaration must be indented. */
 /* $ XXX: Not really pretty, the name 'f1' should be aligned, if at all. */
-char *(*	f1)() = NULL;
-/* $ FIXME: The following declaration must be indented. */
+	char *(*	f1)() = NULL;
 /* $ XXX: Not really pretty, the name 'f2' should be aligned, if at all. */
-char *(*	f2)();
+	char *(*	f2)();
 }
 #indent end

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.102 src/usr.bin/indent/io.c:1.103
--- src/usr.bin/indent/io.c:1.102	Sun Oct 24 17:19:48 2021
+++ src/usr.bin/indent/io.c	Wed Oct 27 00:04:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.102 2021/10/24 17:19:48 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.103 2021/10/27 00:04:51 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.102 2021/10/24 17:19:48 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.103 2021/10/27 00:04:51 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -212,10 +212,7 @@ output_line(char line_terminator)
 {
     static bool first_line = true;
 
-    if (ps.procname[0] != '\0') {
-	ps.ind_level = 0;
-	ps.procname[0] = '\0';
-    }
+    ps.procname[0] = '\0';
 
     if (code.s == code.e && lab.s == lab.e && com.s == com.e) {
 	if (suppress_blanklines)

Reply via email to