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: fix formatting of a few declarations ...



details:   https://anonhg.NetBSD.org/src/rev/9bbd6584a737
branches:  trunk
changeset: 1026446:9bbd6584a737
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Nov 25 08:03:08 2021 +0000

description:
indent: fix formatting of a few declarations involving unknown types

diffstat:

 tests/usr.bin/indent/fmt_decl.c |  50 ++++++++++++----------------------------
 usr.bin/indent/lexi.c           |  10 +++++--
 2 files changed, 22 insertions(+), 38 deletions(-)

diffs (136 lines):

diff -r 19a482b64257 -r 9bbd6584a737 tests/usr.bin/indent/fmt_decl.c
--- a/tests/usr.bin/indent/fmt_decl.c   Thu Nov 25 07:47:55 2021 +0000
+++ b/tests/usr.bin/indent/fmt_decl.c   Thu Nov 25 08:03:08 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fmt_decl.c,v 1.23 2021/11/24 21:34:34 rillig Exp $     */
+/*     $NetBSD: fmt_decl.c,v 1.24 2021/11/25 08:03:08 rillig Exp $     */
 /* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
 
 /*
@@ -583,14 +583,9 @@
 }
 #indent end
 
-#indent run
-static Token
-/* $ FIXME: missing space between ')' and '{'. */
-ToToken(bool cond){
-}
-#indent end
-
 #indent run-equals-input -TToken
+/* Since lexi.c 1.153 from 2021-11-25. */
+#indent run-equals-input
 
 
 /*
@@ -622,12 +617,9 @@
 static CachedDir *dot = NULL;
 #indent end
 
-/* FIXME: The space after '*' is wrong. */
-#indent run
-static CachedDir * dot = NULL;
-#indent end
-
 #indent run-equals-input -TCachedDir
+/* Since lexi.c 1.153 from 2021-11-25. */
+#indent run-equals-input
 
 
 /*
@@ -640,13 +632,8 @@
 }
 #indent end
 
-/* FIXME: The space between '){' is missing. */
-/* FIXME: The '{' must be in column 1 of the next line. */
-#indent run
-static CachedDir *
-CachedDir_New(const char *name){
-}
-#indent end
+/* Since lexi.c 1.153 from 2021-11-25. */
+#indent run-equals-input
 
 
 /*
@@ -660,10 +647,10 @@
 #indent end
 
 /* FIXME: Extraneous ' ' between '*' and 'dir'. */
-/* FIXME: The '{' must be in column 1 of the next line. */
 #indent run
 static CachedDir *
-CachedDir_Ref(CachedDir * dir) {
+CachedDir_Ref(CachedDir * dir)
+{
 }
 #indent end
 
@@ -710,12 +697,12 @@
 
 
 /*
- * All initializer expressions after the first one are indented as if they
- * would be statement continuations. Maybe the comma is interpreted as a
- * binary operator instead of being a separator.
+ * Before lexi.c 1.153 from 2021-11-25, all initializer expressions after the
+ * first one were indented as if they would be statement continuations. This
+ * was because the token 'Shell' was identified as a word, not as a type name.
  */
 #indent input
-static Shell shells[] = {
+static Shell   shells[] = {
        {
                first,
                second,
@@ -723,15 +710,8 @@
 };
 #indent end
 
-#indent run
-static Shell shells[] = {
-       {
-               first,
-/* $ FIXME: The identifier 'second' gets indented too far. */
-                       second,
-       },
-};
-#indent end
+/* Since lexi.c 1.153 from 2021-11-25. */
+#indent run-equals-input
 
 
 /*
diff -r 19a482b64257 -r 9bbd6584a737 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Thu Nov 25 07:47:55 2021 +0000
+++ b/usr.bin/indent/lexi.c     Thu Nov 25 08:03:08 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.152 2021/11/25 07:45:32 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.153 2021/11/25 08:03:08 rillig Exp $        */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.152 2021/11/25 07:45:32 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.153 2021/11/25 08:03:08 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -396,7 +396,11 @@
 static bool
 probably_typename(void)
 {
-    if (ps.block_init || ps.in_stmt_or_decl)
+    if (ps.prev_token == lsym_storage_class)
+       return true;
+    if (ps.block_init)
+       return false;
+    if (ps.in_stmt_or_decl)    /* XXX: this condition looks incorrect */
        return false;
     if (inp_peek() == '*' && inp_lookahead(1) != '=')
        goto maybe;



Home | Main Index | Thread Index | Old Index