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 alignment of multi-line declarations
details: https://anonhg.NetBSD.org/src/rev/055a1713ad9e
branches: trunk
changeset: 376386:055a1713ad9e
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Jun 15 08:40:20 2023 +0000
description:
indent: fix alignment of multi-line declarations
diffstat:
tests/usr.bin/indent/fmt_decl.c | 33 +++++++++++++++------------------
usr.bin/indent/indent.c | 7 ++++---
2 files changed, 19 insertions(+), 21 deletions(-)
diffs (88 lines):
diff -r 0d7b6d3af537 -r 055a1713ad9e tests/usr.bin/indent/fmt_decl.c
--- a/tests/usr.bin/indent/fmt_decl.c Thu Jun 15 07:21:45 2023 +0000
+++ b/tests/usr.bin/indent/fmt_decl.c Thu Jun 15 08:40:20 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fmt_decl.c,v 1.55 2023/06/14 20:46:08 rillig Exp $ */
+/* $NetBSD: fmt_decl.c,v 1.56 2023/06/15 08:40:20 rillig Exp $ */
/*
* Tests for declarations of global variables, external functions, and local
@@ -295,36 +295,33 @@ struct s01234567890123 a,b;
struct s a, b;
/* $ XXX: See process_comma, varname_len for why this line is broken. */
struct s0 a,
- b;
-/* $ XXX: The indentation of the second line is wrong. The variable names */
-/* $ XXX: 'a' and 'b' should be in the same column; the word 'struct' is */
-/* $ XXX: missing in the calculation for the indentation. */
+ b;
struct s01 a,
- b;
+ b;
struct s012 a,
- b;
+ b;
struct s0123 a,
- b;
+ b;
struct s01234 a,
- b;
+ b;
struct s012345 a,
- b;
+ b;
struct s0123456 a,
- b;
+ b;
struct s01234567 a,
- b;
+ b;
struct s012345678 a,
- b;
+ b;
struct s0123456789 a,
- b;
+ b;
struct s01234567890 a,
- b;
+ b;
struct s012345678901 a,
- b;
+ b;
struct s0123456789012 a,
- b;
+ b;
struct s01234567890123 a,
- b;
+ b;
//indent end
diff -r 0d7b6d3af537 -r 055a1713ad9e usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Thu Jun 15 07:21:45 2023 +0000
+++ b/usr.bin/indent/indent.c Thu Jun 15 08:40:20 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.367 2023/06/14 20:46:08 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.368 2023/06/15 08:40:20 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.367 2023/06/14 20:46:08 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.368 2023/06/15 08:40:20 rillig Exp $");
#include <sys/param.h>
#include <err.h>
@@ -933,7 +933,8 @@ process_type_outside_parentheses(void)
if (ps.decl_level <= 0)
ps.declaration = decl_begin;
- int len = (int)token.len + 1;
+ int len = (code.len > 0 ? ind_add(0, code.s, code.len) + 1 : 0)
+ + (int)token.len + 1;
int ind = ps.ind_level > 0 && ps.decl_level == 0
? opt.local_decl_indent /* local variable */
: opt.decl_indent; /* global variable, or member */
Home |
Main Index |
Thread Index |
Old Index