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: add space between ',' and '[' in C99 ...



details:   https://anonhg.NetBSD.org/src/rev/63c13e7d2960
branches:  trunk
changeset: 987532:63c13e7d2960
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Sep 30 20:58:26 2021 +0000

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

diffstat:

 tests/usr.bin/indent/token-lparen.0.stdout |  6 +++---
 usr.bin/indent/indent.c                    |  9 ++++-----
 2 files changed, 7 insertions(+), 8 deletions(-)

diffs (48 lines):

diff -r b75d54413e2e -r 63c13e7d2960 tests/usr.bin/indent/token-lparen.0.stdout
--- a/tests/usr.bin/indent/token-lparen.0.stdout        Thu Sep 30 20:02:54 2021 +0000
+++ b/tests/usr.bin/indent/token-lparen.0.stdout        Thu Sep 30 20:58:26 2021 +0000
@@ -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 @@
 }
 
 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,
 };
diff -r b75d54413e2e -r 63c13e7d2960 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Thu Sep 30 20:02:54 2021 +0000
+++ b/usr.bin/indent/indent.c   Thu Sep 30 20:58:26 2021 +0000
@@ -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 @@
 
 #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 @@
            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);



Home | Main Index | Thread Index | Old Index