Module Name: src Committed By: rillig Date: Tue Jun 6 07:14:20 UTC 2023
Modified Files: src/usr.bin/indent: pr_comment.c Log Message: indent: clean up formatting of comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.153 -r1.154 src/usr.bin/indent/pr_comment.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/indent/pr_comment.c diff -u src/usr.bin/indent/pr_comment.c:1.153 src/usr.bin/indent/pr_comment.c:1.154 --- src/usr.bin/indent/pr_comment.c:1.153 Tue Jun 6 06:59:39 2023 +++ src/usr.bin/indent/pr_comment.c Tue Jun 6 07:14:20 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.153 2023/06/06 06:59:39 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.154 2023/06/06 07:14:20 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pr_comment.c,v 1.153 2023/06/06 06:59:39 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.154 2023/06/06 07:14:20 rillig Exp $"); #include <string.h> @@ -53,9 +53,8 @@ com_add_char(char ch) static void com_add_delim(void) { - if (!opt.star_comment_cont) - return; - buf_add_chars(&com, " * ", 3); + if (opt.star_comment_cont) + buf_add_chars(&com, " * ", 3); } static bool @@ -253,16 +252,16 @@ copy_comment_wrap_finish(int line_length size_t len = com.len; while (ch_isblank(com.s[len - 1])) len--; - int now_len = ind_add(ps.com_ind, com.s, len); - if (now_len + 3 > line_length) + int end_ind = ind_add(ps.com_ind, com.s, len); + if (end_ind + 3 > line_length) output_line(); } inp_p += 2; - if (!(com.len > 0 && ch_isblank(com.s[com.len - 1]))) - com_add_char(' '); - com_add_char('*'); - com_add_char('/'); + if (com.len > 0 && ch_isblank(com.s[com.len - 1])) + buf_add_chars(&com, "*/", 2); + else + buf_add_chars(&com, " */", 3); } /*