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: make fits_in_one_line independent of ps
details: https://anonhg.NetBSD.org/src/rev/46c5063dfc2f
branches: trunk
changeset: 1026473:46c5063dfc2f
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Nov 25 21:01:32 2021 +0000
description:
indent: make fits_in_one_line independent of ps
This makes it easier to understand the function. Having the dependency
to the input line handling is already complicated enough.
No functional change.
diffstat:
usr.bin/indent/pr_comment.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diffs (45 lines):
diff -r b3b65c870e5e -r 46c5063dfc2f usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c Thu Nov 25 20:44:09 2021 +0000
+++ b/usr.bin/indent/pr_comment.c Thu Nov 25 21:01:32 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.123 2021/11/25 20:44:09 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.124 2021/11/25 21:01:32 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.123 2021/11/25 20:44:09 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.124 2021/11/25 21:01:32 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -83,7 +83,7 @@
}
static bool
-fits_in_one_line(int max_line_length)
+fits_in_one_line(int com_ind, int max_line_length)
{
for (const char *p = inp_p(); *p != '\n'; p++) {
assert(*p != '\0');
@@ -91,7 +91,7 @@
if (!(p[0] == '*' && p[1] == '/'))
continue;
- int len = ind_add(ps.com_ind + 3, inp_p(), p);
+ int len = ind_add(com_ind + 3, inp_p(), p);
len += ch_isblank(p[-1]) ? 2 : 3;
return len <= max_line_length;
}
@@ -174,7 +174,7 @@
if (inp_peek() != ' ' && may_wrap)
com_add_char(' ');
- if (break_delim && fits_in_one_line(adj_max_line_length))
+ if (break_delim && fits_in_one_line(com_ind, adj_max_line_length))
break_delim = false;
if (break_delim) {
Home |
Main Index |
Thread Index |
Old Index