Module Name: src
Committed By: rillig
Date: Thu Nov 25 08:03:08 UTC 2021
Modified Files:
src/tests/usr.bin/indent: fmt_decl.c
src/usr.bin/indent: lexi.c
Log Message:
indent: fix formatting of a few declarations involving unknown types
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.152 -r1.153 src/usr.bin/indent/lexi.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.23 src/tests/usr.bin/indent/fmt_decl.c:1.24
--- src/tests/usr.bin/indent/fmt_decl.c:1.23 Wed Nov 24 21:34:34 2021
+++ src/tests/usr.bin/indent/fmt_decl.c Thu Nov 25 08:03:08 2021
@@ -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 @@ ToToken(bool cond)
}
#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 @@ typedef struct OpenDirs {
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 @@ CachedDir_New(const char *name)
}
#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 @@ CachedDir_Ref(CachedDir *dir)
#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 @@ CachedDir_Assign(CachedDir * *var, Cache
/*
- * 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 @@ static Shell shells[] = {
};
#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
/*
Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.152 src/usr.bin/indent/lexi.c:1.153
--- src/usr.bin/indent/lexi.c:1.152 Thu Nov 25 07:45:32 2021
+++ src/usr.bin/indent/lexi.c Thu Nov 25 08:03:08 2021
@@ -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 @@ static char sccsid[] = "@(#)lexi.c 8.1 (
#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 @@ lex_char_or_string(void)
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;