From 5f35ea69afff23db1184469a315cd86cb3112aad Mon Sep 17 00:00:00 2001 From: Piotr Pawel Stefaniak Date: Fri, 1 Jun 2018 09:32:42 +0000 Subject: [PATCH] indent(1): consider tab characters when forcing a newline after a comma --- usr.bin/indent/indent.c | 4 +++- usr.bin/indent/tests/declarations.0 | 1 + usr.bin/indent/tests/declarations.0.stdout | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c index 1686e537f616..7bf739a7379b 100644 --- a/usr.bin/indent/indent.c +++ b/usr.bin/indent/indent.c @@ -1058,7 +1058,9 @@ check_type: if (ps.p_l_follow == 0) { if (ps.block_init_level <= 0) ps.block_init = 0; - if (break_comma && (!ps.leave_comma || compute_code_target() + (e_code - s_code) > max_col - tabsize)) + if (break_comma && (!ps.leave_comma || + count_spaces_until(compute_code_target(), s_code, e_code) > + max_col - tabsize)) force_nl = true; } break; diff --git a/usr.bin/indent/tests/declarations.0 b/usr.bin/indent/tests/declarations.0 index a5482846ec02..875c1d076ed8 100644 --- a/usr.bin/indent/tests/declarations.0 +++ b/usr.bin/indent/tests/declarations.0 @@ -44,6 +44,7 @@ void t2 (char *x, int y) ,n ,o ; + int chars[ /* push the comma beyond column 74 .... */ ], x; } const int int_minimum_size = diff --git a/usr.bin/indent/tests/declarations.0.stdout b/usr.bin/indent/tests/declarations.0.stdout index 9c8384255d8b..99cb4191ff28 100644 --- a/usr.bin/indent/tests/declarations.0.stdout +++ b/usr.bin/indent/tests/declarations.0.stdout @@ -36,6 +36,8 @@ t2(char *x, int y) ,n ,o ; + int chars[ /* push the comma beyond column 74 .... */ ], + x; } const int int_minimum_size =