Module Name:    src
Committed By:   rillig
Date:           Thu Sep 30 20:58:26 UTC 2021

Modified Files:
        src/tests/usr.bin/indent: token-lparen.0.stdout
        src/usr.bin/indent: indent.c

Log Message:
indent: add space between ',' and '[' in C99 initializations


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/token-lparen.0.stdout
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/indent/indent.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/token-lparen.0.stdout
diff -u src/tests/usr.bin/indent/token-lparen.0.stdout:1.2 src/tests/usr.bin/indent/token-lparen.0.stdout:1.3
--- src/tests/usr.bin/indent/token-lparen.0.stdout:1.2	Tue Sep 28 06:57:48 2021
+++ src/tests/usr.bin/indent/token-lparen.0.stdout	Thu Sep 30 20:58:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-lparen.0.stdout,v 1.2 2021/09/28 06:57:48 rillig Exp $ */
+/* $NetBSD: token-lparen.0.stdout,v 1.3 2021/09/30 20:58:26 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -31,6 +31,6 @@ function(void)
 }
 
 int array[] = {
-/* $ FIXME: Add space after comma */
-	1, 2,[2] = 3,[3] = 4,
+/* $ This is the rare situation where there is a space before '['. */
+	1, 2, [2] = 3, [3] = 4,
 };

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.92 src/usr.bin/indent/indent.c:1.93
--- src/usr.bin/indent/indent.c:1.92	Mon Sep 27 20:09:55 2021
+++ src/usr.bin/indent/indent.c	Thu Sep 30 20:58:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.92 2021/09/27 20:09:55 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.93 2021/09/30 20:58:26 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.92 2021/09/27 20:09:55 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.93 2021/09/30 20:58:26 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -602,9 +602,8 @@ process_lparen_or_lbracket(int dec_ind, 
 	    nitems(ps.paren_indents));
 	ps.p_l_follow--;
     }
-    if (*token.s == '[')
-	/* not a function pointer declaration or a function call */;
-    else if (ps.in_decl && !ps.block_init && !ps.dumped_decl_indent &&
+    if (token.s[0] == '(' && ps.in_decl
+	&& !ps.block_init && !ps.dumped_decl_indent &&
 	ps.procname[0] == '\0' && ps.paren_level == 0) {
 	/* function pointer declarations */
 	indent_declaration(dec_ind, tabs_to_var);

Reply via email to