Module Name: src
Committed By: rillig
Date: Thu May 18 05:33:27 UTC 2023
Modified Files:
src/tests/usr.bin/indent: opt_ci.c
src/usr.bin/indent: args.c debug.c indent.c io.c lexi.c parse.c
pr_comment.c
Log Message:
indent: manually wrap overly long lines
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/opt_ci.c
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/indent/args.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.292 -r1.293 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.177 -r1.178 src/usr.bin/indent/io.c
cvs rdiff -u -r1.198 -r1.199 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.60 -r1.61 src/usr.bin/indent/parse.c
cvs rdiff -u -r1.145 -r1.146 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/tests/usr.bin/indent/opt_ci.c
diff -u src/tests/usr.bin/indent/opt_ci.c:1.8 src/tests/usr.bin/indent/opt_ci.c:1.9
--- src/tests/usr.bin/indent/opt_ci.c:1.8 Sun Apr 24 09:04:12 2022
+++ src/tests/usr.bin/indent/opt_ci.c Thu May 18 05:33:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_ci.c,v 1.8 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: opt_ci.c,v 1.9 2023/05/18 05:33:27 rillig Exp $ */
/*
* Tests for the option '-ci', which controls the indentation of continuation
@@ -234,3 +234,19 @@ function(void)
}
}
//indent end
+
+
+//indent input
+{
+ size_t last_word_len = com.len
+ - (size_t)(last_blank + 1);
+}
+//indent end
+
+//indent run -ldi0 -ci4
+{
+ size_t last_word_len = com.len
+/* $ FIXME: The '-' must be indented by 4 spaces. */
+ - (size_t)(last_blank + 1);
+}
+//indent end
Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.78 src/usr.bin/indent/args.c:1.79
--- src/usr.bin/indent/args.c:1.78 Thu May 18 04:23:03 2023
+++ src/usr.bin/indent/args.c Thu May 18 05:33:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: args.c,v 1.78 2023/05/18 04:23:03 rillig Exp $ */
+/* $NetBSD: args.c,v 1.79 2023/05/18 05:33:27 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: args.c,v 1.78 2023/05/18 04:23:03 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.79 2023/05/18 05:33:27 rillig Exp $");
/* Read options from profile files and from the command line. */
@@ -159,7 +159,8 @@ set_special_option(const char *arg, cons
char *end;
opt.case_indent = (float)strtod(arg_end, &end);
if (*end != '\0')
- errx(1, "%s: argument \"%s\" to option \"-%.*s\" must be numeric",
+ errx(1, "%s: argument \"%s\" to option \"-%.*s\" "
+ "must be numeric",
option_source, arg_end, (int)(arg_end - arg), arg);
return true;
}
@@ -218,29 +219,35 @@ set_option(const char *arg, const char *
if (set_special_option(arg, option_source))
return;
- for (p = pro + array_length(pro); p-- != pro;)
- if ((arg_arg = skip_over(arg, p->p_may_negate, p->p_name)) != NULL)
+ for (p = pro + array_length(pro); p-- != pro;) {
+ arg_arg = skip_over(arg, p->p_may_negate, p->p_name);
+ if (arg_arg != NULL)
goto found;
+ }
errx(1, "%s: unknown option \"-%s\"", option_source, arg);
found:
if (p->p_is_bool) {
if (arg_arg[0] != '\0')
- errx(1, "%s: unknown option \"-%s\"", option_source, arg);
+ errx(1, "%s: unknown option \"-%s\"",
+ option_source, arg);
- *(bool *)p->p_var = p->p_may_negate ? arg[0] != 'n' : p->p_bool_value;
+ *(bool *)p->p_var =
+ p->p_may_negate ? arg[0] != 'n' : p->p_bool_value;
return;
}
char *end;
long num = strtol(arg_arg, &end, 10);
if (*end != '\0')
- errx(1, "%s: argument \"%s\" to option \"-%s\" must be an integer",
+ errx(1, "%s: argument \"%s\" to option \"-%s\" "
+ "must be an integer",
option_source, arg_arg, p->p_name);
if (!(ch_isdigit(*arg_arg) && p->i_min <= num && num <= p->i_max))
errx(1,
- "%s: argument \"%s\" to option \"-%s\" must be between %d and %d",
+ "%s: argument \"%s\" to option \"-%s\" "
+ "must be between %d and %d",
option_source, arg_arg, p->p_name, p->i_min, p->i_max);
*(int *)p->p_var = (int)num;
@@ -263,15 +270,18 @@ load_profile(const char *fname, bool mus
int ch, comment_ch = -1;
while ((ch = getc(f)) != EOF) {
- if (ch == '*' && comment_ch == -1 && n > 0 && buf[n - 1] == '/') {
+ if (ch == '*' && comment_ch == -1
+ && n > 0 && buf[n - 1] == '/') {
n--;
comment_ch = '*';
} else if (comment_ch != -1) {
- comment_ch = ch == '/' && comment_ch == '*' ? -1 : ch;
+ comment_ch = ch == '/' && comment_ch == '*'
+ ? -1 : ch;
} else if (ch_isspace((char)ch)) {
break;
} else if (n >= array_length(buf) - 2) {
- errx(1, "buffer overflow in %s, starting with '%.10s'",
+ errx(1, "buffer overflow in %s, "
+ "starting with '%.10s'",
fname, buf);
} else
buf[n++] = (char)ch;
Index: src/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.13 src/usr.bin/indent/debug.c:1.14
--- src/usr.bin/indent/debug.c:1.13 Thu May 18 04:23:03 2023
+++ src/usr.bin/indent/debug.c Thu May 18 05:33:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.13 2023/05/18 04:23:03 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.14 2023/05/18 05:33:27 rillig Exp $ */
/*-
* Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: debug.c,v 1.13 2023/05/18 04:23:03 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.14 2023/05/18 05:33:27 rillig Exp $");
#include <stdarg.h>
@@ -214,7 +214,8 @@ ps_paren_has_changed(const struct parser
return true;
for (int i = 0; i < ps.nparen; i++)
- if (curr[i].indent != prev[i].indent || curr[i].cast != prev[i].cast)
+ if (curr[i].indent != prev[i].indent
+ || curr[i].cast != prev[i].cast)
return true;
return false;
}
@@ -228,7 +229,8 @@ debug_ps_paren(const struct parser_state
debug_printf(" ps.paren:");
for (int i = 0; i < ps.nparen; i++) {
debug_printf(" %s%d",
- paren_level_cast_name[ps.paren[i].cast], ps.paren[i].indent);
+ paren_level_cast_name[ps.paren[i].cast],
+ ps.paren[i].indent);
}
if (ps.nparen == 0)
debug_printf(" none");
@@ -248,7 +250,8 @@ debug_parser_state(lexer_symbol lsym)
debug_print_buf("code", &code);
debug_print_buf("comment", &com);
- debug_println(" ps.prev_token = %s", lsym_name[ps.prev_token]);
+ debug_println(" ps.prev_token = %s",
+ lsym_name[ps.prev_token]);
debug_ps_bool(curr_col_1);
debug_ps_bool(next_col_1);
debug_ps_bool(next_unary);
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.292 src/usr.bin/indent/indent.c:1.293
--- src/usr.bin/indent/indent.c:1.292 Thu May 18 04:23:03 2023
+++ src/usr.bin/indent/indent.c Thu May 18 05:33:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.292 2023/05/18 04:23:03 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.293 2023/05/18 05:33:27 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.292 2023/05/18 04:23:03 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.293 2023/05/18 05:33:27 rillig Exp $");
#include <sys/param.h>
#include <err.h>
@@ -254,7 +254,8 @@ main_parse_command_line(int argc, char *
} else if (output == NULL) {
out_name = arg;
if (strcmp(in_name, out_name) == 0)
- errx(1, "input and output files must be different");
+ errx(1, "input and output files "
+ "must be different");
if ((output = fopen(out_name, "w")) == NULL)
err(1, "%s", out_name);
@@ -306,16 +307,16 @@ main_prepare_parsing(void)
static void
code_add_decl_indent(int decl_ind, bool tabs_to_var)
{
- int base_ind = ps.ind_level * opt.indent_size;
- int ind = base_ind + (int)code.len;
- int target_ind = base_ind + decl_ind;
+ int base = ps.ind_level * opt.indent_size;
+ int ind = base + (int)code.len;
+ int target = base + decl_ind;
size_t orig_code_len = code.len;
if (tabs_to_var)
- for (int next; (next = next_tab(ind)) <= target_ind; ind = next)
+ for (int next; (next = next_tab(ind)) <= target; ind = next)
buf_add_char(&code, '\t');
- for (; ind < target_ind; ind++)
+ for (; ind < target; ind++)
buf_add_char(&code, ' ');
if (code.len == orig_code_len && ps.want_blank) {
@@ -534,7 +535,8 @@ process_unary_op(void)
if (!ps.decl_indent_done && ps.in_decl && !ps.block_init &&
!ps.is_function_definition && ps.line_start_nparen == 0) {
/* pointer declarations */
- code_add_decl_indent(ps.decl_ind - (int)token.len, ps.tabs_to_var);
+ code_add_decl_indent(ps.decl_ind - (int)token.len,
+ ps.tabs_to_var);
ps.decl_indent_done = true;
} else if (want_blank_before_unary_op())
buf_add_char(&code, ' ');
@@ -772,7 +774,8 @@ process_else(void)
{
ps.in_stmt_or_decl = false;
- if (code.len > 0 && !(opt.cuddle_else && code.mem[code.len - 1] == '}')) {
+ if (code.len > 0
+ && !(opt.cuddle_else && code.mem[code.len - 1] == '}')) {
if (opt.verbose)
diag(0, "Line broken");
output_line();
@@ -827,7 +830,8 @@ process_ident(lexer_symbol lsym)
ps.line_start_nparen == 0) {
if (opt.decl_indent == 0
&& code.len > 0 && code.mem[code.len - 1] == '}')
- ps.decl_ind = ind_add(0, code.st, code.len) + 1;
+ ps.decl_ind =
+ ind_add(0, code.st, code.len) + 1;
code_add_decl_indent(ps.decl_ind, ps.tabs_to_var);
ps.decl_indent_done = true;
ps.want_blank = false;
@@ -975,7 +979,8 @@ process_preprocessing(void)
} else if (substring_starts_with(dir, "el")) { /* else, elif */
if (ifdef_level <= 0)
- diag(1, dir.s[2] == 'i' ? "Unmatched #elif" : "Unmatched #else");
+ diag(1, dir.s[2] == 'i'
+ ? "Unmatched #elif" : "Unmatched #else");
else
ps = state_stack[ifdef_level - 1];
@@ -1014,17 +1019,19 @@ main_loop(void)
if (lsym == lsym_eof)
return process_eof();
- if (lsym == lsym_if && ps.prev_token == lsym_else && opt.else_if)
+ if (lsym == lsym_if && ps.prev_token == lsym_else
+ && opt.else_if)
ps.force_nl = false;
if (lsym == lsym_newline || lsym == lsym_preprocessing)
ps.force_nl = false;
else if (lsym != lsym_comment) {
maybe_break_line(lsym);
- ps.in_stmt_or_decl = true; /* add an extra level of
- * indentation; turned
- * off again by a ';' or
- * '}' */
+ /*
+ * Add an extra level of indentation; turned off again
+ * by a ';' or '}'.
+ */
+ ps.in_stmt_or_decl = true;
if (com.len > 0)
move_com_to_code(lsym);
}
Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.177 src/usr.bin/indent/io.c:1.178
--- src/usr.bin/indent/io.c:1.177 Thu May 18 04:23:03 2023
+++ src/usr.bin/indent/io.c Thu May 18 05:33:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.177 2023/05/18 04:23:03 rillig Exp $ */
+/* $NetBSD: io.c,v 1.178 2023/05/18 05:33:27 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.177 2023/05/18 04:23:03 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.178 2023/05/18 05:33:27 rillig Exp $");
#include <stdio.h>
#include <string.h>
@@ -154,7 +154,8 @@ output_line_code(int ind)
if (paren_ind >= 0) {
ps.paren[i].indent = -1 - (paren_ind + target_ind);
debug_println(
- "setting paren_indents[%d] from %d to %d for column %d",
+ "setting paren_indents[%d] from %d to %d "
+ "for column %d",
i, paren_ind, ps.paren[i].indent, target_ind + 1);
}
}
@@ -314,7 +315,8 @@ compute_code_indent(void)
if (2 * opt.continuation_indent == opt.indent_size)
return base_ind + opt.continuation_indent;
else
- return base_ind + opt.continuation_indent * ps.line_start_nparen;
+ return base_ind +
+ opt.continuation_indent * ps.line_start_nparen;
}
int
Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.198 src/usr.bin/indent/lexi.c:1.199
--- src/usr.bin/indent/lexi.c:1.198 Thu May 18 04:23:03 2023
+++ src/usr.bin/indent/lexi.c Thu May 18 05:33:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.198 2023/05/18 04:23:03 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.199 2023/05/18 05:33:27 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.198 2023/05/18 04:23:03 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.199 2023/05/18 05:33:27 rillig Exp $");
#include <stdlib.h>
#include <string.h>
@@ -121,31 +121,31 @@ static struct {
*/
/* INDENT OFF */
static const unsigned char lex_number_state[][26] = {
- /* examples:
- 00
- s 0xx
- t 00xaa
- a 11 101100xxa..
- r 11ee0001101lbuuxx.a.pp
- t.01.e+008bLuxll0Ll.aa.p+0
- states: ABCDEFGHIJKLMNOPQRSTUVWXYZ */
- [0] = "uuiifuufiuuiiuiiiiiuiuuuuu", /* (other) */
- [1] = "CEIDEHHHIJQ U Q VUVVZZZ", /* 0 */
- [2] = "DEIDEHHHIJQ U Q VUVVZZZ", /* 1 */
- [3] = "DEIDEHHHIJ U VUVVZZZ", /* 2 3 4 5 6 7 */
- [4] = "DEJDEHHHJJ U VUVVZZZ", /* 8 9 */
- [5] = " U VUVV ", /* A a C c D d */
- [6] = " K U VUVV ", /* B b */
- [7] = " FFF FF U VUVV ", /* E e */
- [8] = " f f U VUVV f", /* F f */
- [9] = " LLf fL PR Li L f", /* L */
- [10] = " OOf fO S P O i O f", /* l */
- [11] = " FFX ", /* P p */
- [12] = " MM M i iiM M ", /* U u */
- [13] = " N ", /* X x */
- [14] = " G Y ", /* + - */
- [15] = "B EE EE T W ", /* . */
- /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
+ /* examples:
+ 00
+ s 0xx
+ t 00xaa
+ a 11 101100xxa..
+ r 11ee0001101lbuuxx.a.pp
+ t.01.e+008bLuxll0Ll.aa.p+0
+ states: ABCDEFGHIJKLMNOPQRSTUVWXYZ */
+ [0] = "uuiifuufiuuiiuiiiiiuiuuuuu", /* (other) */
+ [1] = "CEIDEHHHIJQ U Q VUVVZZZ", /* 0 */
+ [2] = "DEIDEHHHIJQ U Q VUVVZZZ", /* 1 */
+ [3] = "DEIDEHHHIJ U VUVVZZZ", /* 2 3 4 5 6 7 */
+ [4] = "DEJDEHHHJJ U VUVVZZZ", /* 8 9 */
+ [5] = " U VUVV ", /* A a C c D d */
+ [6] = " K U VUVV ", /* B b */
+ [7] = " FFF FF U VUVV ", /* E e */
+ [8] = " f f U VUVV f", /* F f */
+ [9] = " LLf fL PR Li L f", /* L */
+ [10] = " OOf fO S P O i O f", /* l */
+ [11] = " FFX ", /* P p */
+ [12] = " MM M i iiM M ", /* U u */
+ [13] = " N ", /* X x */
+ [14] = " G Y ", /* + - */
+ [15] = "B EE EE T W ", /* . */
+ /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
};
/* INDENT ON */
@@ -173,7 +173,6 @@ token_add_char(char ch)
buf_add_char(&token, ch);
}
-
static void
lex_number(void)
{
@@ -185,7 +184,8 @@ lex_number(void)
line_no++;
continue;
}
- if (ch >= array_length(lex_number_row) || lex_number_row[ch] == 0)
+ if (ch >= array_length(lex_number_row)
+ || lex_number_row[ch] == 0)
break;
unsigned char row = lex_number_row[ch];
@@ -322,7 +322,8 @@ probably_looking_at_definition(void)
if (*p == ')' && --paren_level == 0) {
p++;
- while (*p != '\n' && (ch_isspace(*p) || is_identifier_part(*p)))
+ while (*p != '\n'
+ && (ch_isspace(*p) || is_identifier_part(*p)))
p++; /* '__dead' or '__unused' */
if (*p == '\n') /* func(...) */
@@ -405,7 +406,8 @@ found_typename:
if (ps.paren[ps.nparen - 1].cast == cast_unknown)
ps.paren[ps.nparen - 1].cast = cast_maybe;
}
- if (ps.prev_token != lsym_period && ps.prev_token != lsym_unary_op) {
+ if (ps.prev_token != lsym_period
+ && ps.prev_token != lsym_unary_op) {
if (kw != NULL && kw->lsym == lsym_tag) {
if (token.st[0] == 'e' /* enum */)
ps.in_enum = in_enum_enum;
@@ -593,11 +595,13 @@ lexi(void)
lsym = ps.next_unary ? lsym_unary_op : lsym_binary_op;
next_unary = true;
- if (inp.st[0] == token.mem[token.len - 1]) { /* '++' or '--' */
+ /* '++' or '--' */
+ if (inp.st[0] == token.mem[token.len - 1]) {
token_add_char(*inp.st++);
if (ps.prev_token == lsym_word ||
ps.prev_token == lsym_rparen_or_rbracket) {
- lsym = ps.next_unary ? lsym_unary_op : lsym_postfix_op;
+ lsym = ps.next_unary
+ ? lsym_unary_op : lsym_postfix_op;
next_unary = false;
}
@@ -658,9 +662,9 @@ lexi(void)
break;
}
- /* handle '||', '&&', etc., and also things as in 'int *****i'
- */
- while (inp.st[0] == token.mem[token.len - 1] || inp.st[0] == '=')
+ /* things like '||', '&&', '<<=', 'int *****i' */
+ while (inp.st[0] == token.mem[token.len - 1]
+ || inp.st[0] == '=')
token_add_char(*inp.st++);
lsym = ps.next_unary ? lsym_unary_op : lsym_binary_op;
Index: src/usr.bin/indent/parse.c
diff -u src/usr.bin/indent/parse.c:1.60 src/usr.bin/indent/parse.c:1.61
--- src/usr.bin/indent/parse.c:1.60 Thu May 18 04:23:03 2023
+++ src/usr.bin/indent/parse.c Thu May 18 05:33:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.60 2023/05/18 04:23:03 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.61 2023/05/18 05:33:27 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: parse.c,v 1.60 2023/05/18 04:23:03 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.61 2023/05/18 05:33:27 rillig Exp $");
#include <err.h>
@@ -88,7 +88,8 @@ parse(parser_symbol psym)
break;
case psym_if_expr:
- if (ps.s_sym[ps.tos] == psym_if_expr_stmt_else && opt.else_if) {
+ if (ps.s_sym[ps.tos] == psym_if_expr_stmt_else
+ && opt.else_if) {
/* Reduce "else if" to "if". This saves a lot of stack
* space in case of a long "if-else-if ... else-if"
* sequence. */
@@ -105,7 +106,8 @@ parse(parser_symbol psym)
case psym_lbrace:
break_comma = false; /* don't break comma in an initializer
* list */
- if (ps.s_sym[ps.tos] == psym_stmt || ps.s_sym[ps.tos] == psym_decl
+ if (ps.s_sym[ps.tos] == psym_stmt
+ || ps.s_sym[ps.tos] == psym_decl
|| ps.s_sym[ps.tos] == psym_stmt_list)
++ps.ind_level_follow; /* it is a random, isolated
* stmt group or a declaration
@@ -133,9 +135,10 @@ parse(parser_symbol psym)
case psym_while_expr:
if (ps.s_sym[ps.tos] == psym_do_stmt) {
/* it is matched with do stmt */
- ps.ind_level = ps.ind_level_follow = ps.s_ind_level[ps.tos];
+ ps.ind_level =
+ ps.ind_level_follow = ps.s_ind_level[ps.tos];
ps.s_sym[++ps.tos] = psym_while_expr;
- ps.s_ind_level[ps.tos] = ps.ind_level = ps.ind_level_follow;
+ ps.s_ind_level[ps.tos] = ps.ind_level;
} else { /* it is a while loop */
ps.s_sym[++ps.tos] = psym_while_expr;
@@ -158,7 +161,8 @@ parse(parser_symbol psym)
case psym_rbrace:
/* stack should have <lbrace> <stmt> or <lbrace> <stmt_list> */
if (ps.tos > 0 && ps.s_sym[ps.tos - 1] == psym_lbrace) {
- ps.ind_level = ps.ind_level_follow = ps.s_ind_level[--ps.tos];
+ ps.ind_level = ps.ind_level_follow
+ = ps.s_ind_level[--ps.tos];
ps.s_sym[ps.tos] = psym_stmt;
} else
diag(1, "Statement nesting error");
Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.145 src/usr.bin/indent/pr_comment.c:1.146
--- src/usr.bin/indent/pr_comment.c:1.145 Thu May 18 04:23:03 2023
+++ src/usr.bin/indent/pr_comment.c Thu May 18 05:33:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.145 2023/05/18 04:23:03 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.146 2023/05/18 05:33:27 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pr_comment.c,v 1.145 2023/05/18 04:23:03 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.146 2023/05/18 05:33:27 rillig Exp $");
#include <string.h>
@@ -63,7 +63,8 @@ fits_in_one_line(int com_ind, int max_li
{
for (const char *start = inp.st, *p = start; *p != '\n'; p++) {
if (p[0] == '*' && p[1] == '/') {
- int len = ind_add(com_ind + 3, start, (size_t)(p - start));
+ int len = ind_add(com_ind + 3,
+ start, (size_t)(p - start));
len += p == start || ch_isblank(p[-1]) ? 2 : 3;
return len <= max_line_length;
}
@@ -95,7 +96,8 @@ analyze_comment(bool *p_may_wrap, bool *
if (com.len > 0)
output_line();
if (lab.len == 0 && code.len == 0) {
- ind = (ps.ind_level - opt.unindent_displace) * opt.indent_size;
+ ind = (ps.ind_level - opt.unindent_displace)
+ * opt.indent_size;
if (ind <= 0)
ind = opt.format_col1_comments ? 0 : 1;
line_length = opt.block_comment_max_line_length;
@@ -107,7 +109,8 @@ analyze_comment(bool *p_may_wrap, bool *
: ind_add(compute_label_indent(), lab.st, lab.len);
ind = ps.decl_on_line || ps.ind_level == 0
- ? opt.decl_comment_column - 1 : opt.comment_column - 1;
+ ? opt.decl_comment_column - 1
+ : opt.comment_column - 1;
if (ind <= target_ind)
ind = next_tab(target_ind);
if (ind + 25 > line_length)
@@ -173,9 +176,10 @@ copy_comment_wrap(int line_length, bool
last_blank = -1;
if (ps.next_col_1) {
- if (com.len == 0)
- com_add_char(' '); /* force empty line of
- * output */
+ if (com.len == 0) {
+ /* force empty line of output */
+ com_add_char(' ');
+ }
if (com.len > 3) {
output_line();
com_add_delim();
@@ -185,7 +189,8 @@ copy_comment_wrap(int line_length, bool
} else {
ps.next_col_1 = true;
- if (!(com.len > 0 && ch_isblank(com.mem[com.len - 1])))
+ if (!(com.len > 0
+ && ch_isblank(com.mem[com.len - 1])))
com_add_char(' ');
last_blank = (int)com.len - 1;
}
@@ -218,15 +223,17 @@ copy_comment_wrap(int line_length, bool
com.len = 0;
com_add_char(' ');
} else {
- size_t trimmed_len = com.len;
- while (ch_isblank(com.mem[trimmed_len - 1]))
- trimmed_len--;
- int now_len = ind_add(ps.com_ind, com.st, trimmed_len);
- if (now_len + 3 /* ' ' '*' '/' */ > line_length)
+ size_t len = com.len;
+ while (ch_isblank(com.mem[len - 1]))
+ len--;
+ int now_len = ind_add(
+ ps.com_ind, com.st, len);
+ if (now_len + 3 > line_length)
output_line();
}
- if (!(com.len > 0 && ch_isblank(com.mem[com.len - 1])))
+ if (!(com.len > 0
+ && ch_isblank(com.mem[com.len - 1])))
com_add_char(' ');
com_add_char('*');
com_add_char('/');
@@ -258,15 +265,16 @@ copy_comment_wrap(int line_length, bool
if (ch_isspace(com.mem[com.len - 1]))
break;
- if (last_blank == -1) { /* only a single word in this
- * line */
+ if (last_blank == -1) {
+ /* only a single word in this line */
output_line();
com_add_delim();
break;
}
const char *last_word_s = com.mem + last_blank + 1;
- size_t last_word_len = com.len - (size_t)(last_blank + 1);
+ size_t last_word_len = com.len
+ - (size_t)(last_blank + 1);
com.len = (size_t)last_blank;
output_line();
com_add_delim();