Module Name: src Committed By: rillig Date: Mon May 15 14:12:03 UTC 2023
Modified Files: src/tests/usr.bin/indent: lsym_tag.c src/usr.bin/indent: indent.c Log Message: indent: fix indentation of struct member names To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/lsym_tag.c cvs rdiff -u -r1.277 -r1.278 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/lsym_tag.c diff -u src/tests/usr.bin/indent/lsym_tag.c:1.6 src/tests/usr.bin/indent/lsym_tag.c:1.7 --- src/tests/usr.bin/indent/lsym_tag.c:1.6 Mon May 15 13:53:32 2023 +++ src/tests/usr.bin/indent/lsym_tag.c Mon May 15 14:12:03 2023 @@ -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 Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.277 src/usr.bin/indent/indent.c:1.278 --- src/usr.bin/indent/indent.c:1.277 Mon May 15 13:37:16 2023 +++ src/usr.bin/indent/indent.c Mon May 15 14:12:03 2023 @@ -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;