Module Name: src Committed By: rillig Date: Thu Oct 14 20:15:18 UTC 2021
Modified Files: src/usr.bin/indent: pr_comment.c Log Message: indent: turn ps.com_ind into local variable This makes it immediately clear that ps.com_ind is computed in the first part of process_comment and then only used from there. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 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.77 src/usr.bin/indent/pr_comment.c:1.78 --- src/usr.bin/indent/pr_comment.c:1.77 Wed Oct 13 22:38:02 2021 +++ src/usr.bin/indent/pr_comment.c Thu Oct 14 20:15:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.77 2021/10/13 22:38:02 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.78 2021/10/14 20:15:18 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c #include <sys/cdefs.h> #if defined(__NetBSD__) -__RCSID("$NetBSD: pr_comment.c,v 1.77 2021/10/13 22:38:02 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.78 2021/10/14 20:15:18 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $"); #endif @@ -125,6 +125,7 @@ process_comment(void) ssize_t last_blank; /* index of the last blank in com.buf */ bool break_delim = opt.comment_delimiter_on_blankline; int l_just_saw_decl = ps.just_saw_decl; + int com_ind; adj_max_line_length = opt.max_line_length; ps.just_saw_decl = 0; @@ -137,7 +138,7 @@ process_comment(void) if (ps.col_1 && !opt.format_col1_comments) { may_wrap = false; break_delim = false; - ps.com_ind = 0; + com_ind = 0; } else { if (*inp.s == '-' || *inp.s == '*' || token.e[-1] == '/' || @@ -147,10 +148,10 @@ process_comment(void) } if (lab.s == lab.e && code.s == code.e) { - ps.com_ind = (ps.ind_level - opt.unindent_displace) * opt.indent_size; + com_ind = (ps.ind_level - opt.unindent_displace) * opt.indent_size; adj_max_line_length = opt.block_comment_max_line_length; - if (ps.com_ind <= 0) - ps.com_ind = opt.format_col1_comments ? 0 : 1; + if (com_ind <= 0) + com_ind = opt.format_col1_comments ? 0 : 1; } else { break_delim = false; @@ -163,16 +164,18 @@ process_comment(void) else target_ind = 0; - ps.com_ind = ps.decl_on_line || ps.ind_level == 0 + com_ind = ps.decl_on_line || ps.ind_level == 0 ? opt.decl_comment_column - 1 : opt.comment_column - 1; - if (ps.com_ind <= target_ind) - ps.com_ind = next_tab(target_ind); + if (com_ind <= target_ind) + com_ind = next_tab(target_ind); /* XXX: the '+ 1' smells like an off-by-one error */ - if (ps.com_ind + 1 + 24 > adj_max_line_length) - adj_max_line_length = ps.com_ind + 1 + 24; + if (com_ind + 1 + 24 > adj_max_line_length) + adj_max_line_length = com_ind + 1 + 24; } } + ps.com_ind = com_ind; + if (!may_wrap) { /* * Find out how much indentation there was originally, because that