From 3d441a70642d95823f0ae5e2327e4ff596f76f62 Mon Sep 17 00:00:00 2001 From: pstef Date: Sun, 23 Jul 2017 20:25:53 +0000 Subject: [PATCH] indent(1): better alignment of comments on code. If aligning the beginning of a comment to -cn would mean no space between code and the comment, align it to the next tab stop. --- usr.bin/indent/pr_comment.c | 2 +- usr.bin/indent/tests/comments.0 | 7 +++++++ usr.bin/indent/tests/comments.0.stdout | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/usr.bin/indent/pr_comment.c b/usr.bin/indent/pr_comment.c index 686deafe7aa1..00cb23a657c4 100644 --- a/usr.bin/indent/pr_comment.c +++ b/usr.bin/indent/pr_comment.c @@ -141,7 +141,7 @@ pr_comment(void) target_col = count_spaces(compute_label_target(), s_lab); } ps.com_col = ps.decl_on_line || ps.ind_level == 0 ? ps.decl_com_ind : ps.com_ind; - if (ps.com_col < target_col) + if (ps.com_col <= target_col) ps.com_col = ((target_col + 7) & ~7) + 1; if (ps.com_col + 24 > adj_max_col) adj_max_col = ps.com_col + 24; diff --git a/usr.bin/indent/tests/comments.0 b/usr.bin/indent/tests/comments.0 index e642bccab42d..567d234ec1a0 100644 --- a/usr.bin/indent/tests/comments.0 +++ b/usr.bin/indent/tests/comments.0 @@ -1,4 +1,11 @@ /* $FreeBSD$ */ +typedef enum x { + aaaaaaaaaaaaaaaaaaaaaa = 1 << 0, /* test a */ + bbbbbbbbbbbbbbbbb = 1 << 1, /* test b */ + cccccccccccccc = 1 << 1, /* test c */ + dddddddddddddddddddddddddddddd = 1 << 2 /* test d */ +} x; + /* See r303597, r303598, r309219, and r309343 */ void t(void) { /* diff --git a/usr.bin/indent/tests/comments.0.stdout b/usr.bin/indent/tests/comments.0.stdout index 69e119a6ba7c..0ad246bd8179 100644 --- a/usr.bin/indent/tests/comments.0.stdout +++ b/usr.bin/indent/tests/comments.0.stdout @@ -1,4 +1,11 @@ /* $FreeBSD$ */ +typedef enum x { + aaaaaaaaaaaaaaaaaaaaaa = 1 << 0, /* test a */ + bbbbbbbbbbbbbbbbb = 1 << 1, /* test b */ + cccccccccccccc = 1 << 1, /* test c */ + dddddddddddddddddddddddddddddd = 1 << 2 /* test d */ +} x; + /* See r303597, r303598, r309219, and r309343 */ void t(void)