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 indentation of struct member names
details: https://anonhg.NetBSD.org/src/rev/5709ba0dd3e1
branches: trunk
changeset: 375354:5709ba0dd3e1
user: rillig <rillig%NetBSD.org@localhost>
date: Mon May 15 14:12:03 2023 +0000
description:
indent: fix indentation of struct member names
diffstat:
tests/usr.bin/indent/lsym_tag.c | 25 ++++++++-----------------
usr.bin/indent/indent.c | 7 +++++--
2 files changed, 13 insertions(+), 19 deletions(-)
diffs (73 lines):
diff -r bf411451c741 -r 5709ba0dd3e1 tests/usr.bin/indent/lsym_tag.c
--- a/tests/usr.bin/indent/lsym_tag.c Mon May 15 14:08:17 2023 +0000
+++ b/tests/usr.bin/indent/lsym_tag.c Mon May 15 14:12:03 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_tag.c,v 1.6 2023/05/15 13:53:32 rillig Exp $ */
+/* $NetBSD: lsym_tag.c,v 1.7 2023/05/15 14:12:03 rillig Exp $ */
/*
* Tests for the token lsym_tag, which represents one of the keywords
@@ -118,28 +118,19 @@ struct /* comment */ tag var;
/*
* Ensure that the names of struct members are all indented the same.
- * Before XXXX-XX-XX, the indentation depended on their type name.
+ * Before 2023-05-15, the indentation depended on their type name.
*/
//indent input
-struct {
+struct outer {
enum {
untagged_constant,
- } untagged_member;
+ } untagged_member,
+ second_untagged_member;
enum tag_name {
tagged_constant,
- } tagged_member;
+ } tagged_member,
+ second_tagged_member;
};
//indent end
-//indent run -di0
-struct {
- enum {
- untagged_constant,
- } untagged_member;
- /* $ FIXME: 4 spaces above, should be 1. */
- enum tag_name {
- tagged_constant,
- } tagged_member;
- /* $ FIXME: 8 spaces above, should be 1. */
-};
-//indent end
+//indent run-equals-input -di0
diff -r bf411451c741 -r 5709ba0dd3e1 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Mon May 15 14:08:17 2023 +0000
+++ b/usr.bin/indent/indent.c Mon May 15 14:12:03 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.277 2023/05/15 13:37:16 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.278 2023/05/15 14:12:03 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.277 2023/05/15 13:37:16 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.278 2023/05/15 14:12:03 rillig Exp $");
#include <sys/param.h>
#include <err.h>
@@ -799,6 +799,9 @@ process_ident(lexer_symbol lsym)
} else if (!ps.block_init && !ps.decl_indent_done &&
ps.line_start_nparen == 0) {
+ if (opt.decl_indent == 0
+ && code.len > 0 && code.mem[code.len - 1] == '}')
+ ps.decl_ind = ind_add(0, code.st, code.len) + 1;
code_add_decl_indent(ps.decl_ind, ps.tabs_to_var);
ps.decl_indent_done = true;
ps.want_blank = false;
Home |
Main Index |
Thread Index |
Old Index