Module Name: src Committed By: rillig Date: Sat Nov 20 16:54:18 UTC 2021
Modified Files: src/tests/usr.bin/indent: lsym_case_label.c lsym_comma.c lsym_lbrace.c lsym_postfix_op.c lsym_preprocessing.c opt_ce.c opt_ci.c opt_cli.c opt_d.c opt_di.c opt_dj.c opt_eei.c opt_ei.c opt_fc1.c opt_fcb.c opt_i.c opt_ip.c opt_l.c opt_lc.c opt_ldi.c opt_lp.c opt_lpl.c opt_psl.c opt_ta.c opt_ut.c opt_v.c ps_ind_level.c psym_for_exprs.c psym_switch_expr.c psym_while_expr.c token_binary_op.c token_comment.c token_newline.c token_period.c token_while_expr.c Log Message: tests/indent: clean up and extend tests To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_case_label.c \ src/tests/usr.bin/indent/lsym_comma.c \ src/tests/usr.bin/indent/lsym_lbrace.c \ src/tests/usr.bin/indent/lsym_postfix_op.c \ src/tests/usr.bin/indent/lsym_preprocessing.c \ src/tests/usr.bin/indent/opt_cli.c src/tests/usr.bin/indent/opt_d.c \ src/tests/usr.bin/indent/opt_i.c src/tests/usr.bin/indent/opt_l.c \ src/tests/usr.bin/indent/opt_lc.c src/tests/usr.bin/indent/opt_ta.c \ src/tests/usr.bin/indent/psym_for_exprs.c \ src/tests/usr.bin/indent/psym_switch_expr.c \ src/tests/usr.bin/indent/psym_while_expr.c \ src/tests/usr.bin/indent/token_newline.c \ src/tests/usr.bin/indent/token_period.c \ src/tests/usr.bin/indent/token_while_expr.c cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/opt_ce.c \ src/tests/usr.bin/indent/opt_lp.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/opt_ci.c \ src/tests/usr.bin/indent/opt_dj.c src/tests/usr.bin/indent/opt_ei.c \ src/tests/usr.bin/indent/opt_fc1.c src/tests/usr.bin/indent/opt_fcb.c \ src/tests/usr.bin/indent/opt_ip.c src/tests/usr.bin/indent/opt_lpl.c cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/opt_di.c \ src/tests/usr.bin/indent/opt_eei.c src/tests/usr.bin/indent/opt_psl.c \ src/tests/usr.bin/indent/opt_v.c cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt_ldi.c \ src/tests/usr.bin/indent/opt_ut.c src/tests/usr.bin/indent/ps_ind_level.c cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/token_binary_op.c cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/indent/token_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/lsym_case_label.c diff -u src/tests/usr.bin/indent/lsym_case_label.c:1.1 src/tests/usr.bin/indent/lsym_case_label.c:1.2 --- src/tests/usr.bin/indent/lsym_case_label.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/lsym_case_label.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_case_label.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: lsym_case_label.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -9,6 +9,7 @@ * Since C11, the keyword 'default' is used in _Generic selections as well. * * See also: + * opt_cli.c * psym_switch_expr.c * C11 6.5.1.1 "Generic selection" */ Index: src/tests/usr.bin/indent/lsym_comma.c diff -u src/tests/usr.bin/indent/lsym_comma.c:1.1 src/tests/usr.bin/indent/lsym_comma.c:1.2 --- src/tests/usr.bin/indent/lsym_comma.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/lsym_comma.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_comma.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: lsym_comma.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -7,6 +7,8 @@ * In an expression, the binary operator ',' evaluates its left operand before * its right operand, inserting a sequence point. * + * In a declaration, a ',' separates the declarators. + * * In a parameter list of a function type, a ',' separates the parameter * declarations. * Index: src/tests/usr.bin/indent/lsym_lbrace.c diff -u src/tests/usr.bin/indent/lsym_lbrace.c:1.1 src/tests/usr.bin/indent/lsym_lbrace.c:1.2 --- src/tests/usr.bin/indent/lsym_lbrace.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/lsym_lbrace.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_lbrace.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: lsym_lbrace.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -11,6 +11,8 @@ * * In an expression, '(type){' starts a compound expression that is typically * used in an assignment to a struct or array. + * + * TODO: try to split this token into lsym_lbrace_block and lsym_lbrace_init. */ #indent input Index: src/tests/usr.bin/indent/lsym_postfix_op.c diff -u src/tests/usr.bin/indent/lsym_postfix_op.c:1.1 src/tests/usr.bin/indent/lsym_postfix_op.c:1.2 --- src/tests/usr.bin/indent/lsym_postfix_op.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/lsym_postfix_op.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_postfix_op.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: lsym_postfix_op.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -10,7 +10,23 @@ */ #indent input -// TODO: add input +int decl = lvalue ++; +int decl = lvalue --; #indent end -#indent run-equals-input +#indent run -di0 +int decl = lvalue++; +int decl = lvalue--; +#indent end + + +/* + * There is no operator '**', so try that just for fun. + */ +#indent input +int decl = lvalue **; +#indent end + +#indent run -di0 +int decl = lvalue * *; +#indent end Index: src/tests/usr.bin/indent/lsym_preprocessing.c diff -u src/tests/usr.bin/indent/lsym_preprocessing.c:1.1 src/tests/usr.bin/indent/lsym_preprocessing.c:1.2 --- src/tests/usr.bin/indent/lsym_preprocessing.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/lsym_preprocessing.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_preprocessing.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: lsym_preprocessing.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -18,3 +18,25 @@ #indent end #indent run-equals-input + + +/* + * Whitespace in the following preprocessing directives is preserved. + */ +#indent input +#define space ' ' /* the 'define' is followed by a space */ +#define tab '\t' /* the 'define' is followed by a tab */ +#if 0 /* 3 spaces */ +#elif 0 /* 2 tabs */ +#elif 0 > 1 /* tabs between the tokens */ +#endif +#indent end + +#indent run-equals-input + +// TODO: #define unfinished_string "... +// TODO: #define unfinished_char '... +// TODO: # 123 "file.h" +// TODO: backslash-newline +// TODO: block comment +// TODO: line comment Index: src/tests/usr.bin/indent/opt_cli.c diff -u src/tests/usr.bin/indent/opt_cli.c:1.1 src/tests/usr.bin/indent/opt_cli.c:1.2 --- src/tests/usr.bin/indent/opt_cli.c:1.1 Fri Oct 22 20:54:36 2021 +++ src/tests/usr.bin/indent/opt_cli.c Sat Nov 20 16:54:17 2021 @@ -1,6 +1,15 @@ -/* $NetBSD: opt_cli.c,v 1.1 2021/10/22 20:54:36 rillig Exp $ */ +/* $NetBSD: opt_cli.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ +/* + * Tests for the option '-cli' ("case label indentation"), which sets the + * amount of indentation of a 'case' relative to the surrounding 'switch', + * measured in indentation levels. + * + * See also: + * lsym_case_label.c + */ + #indent input void classify(int n) Index: src/tests/usr.bin/indent/opt_d.c diff -u src/tests/usr.bin/indent/opt_d.c:1.1 src/tests/usr.bin/indent/opt_d.c:1.2 --- src/tests/usr.bin/indent/opt_d.c:1.1 Fri Oct 22 20:54:36 2021 +++ src/tests/usr.bin/indent/opt_d.c Sat Nov 20 16:54:17 2021 @@ -1,7 +1,11 @@ -/* $NetBSD: opt_d.c,v 1.1 2021/10/22 20:54:36 rillig Exp $ */ +/* $NetBSD: opt_d.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ -/* XXX: oops, the comments at level 0 move below the '{' */ +/* + * Tests for the option '-d', which moves comments to the left of the + * current code indentation level. + */ + #indent input void example(void) @@ -20,6 +24,7 @@ example(void) } #indent end +/* The comments at level 0 move below the '{', due to the option '-br'. */ #indent run -d1 void example(void) Index: src/tests/usr.bin/indent/opt_i.c diff -u src/tests/usr.bin/indent/opt_i.c:1.1 src/tests/usr.bin/indent/opt_i.c:1.2 --- src/tests/usr.bin/indent/opt_i.c:1.1 Fri Oct 22 20:54:36 2021 +++ src/tests/usr.bin/indent/opt_i.c Sat Nov 20 16:54:17 2021 @@ -1,6 +1,11 @@ -/* $NetBSD: opt_i.c,v 1.1 2021/10/22 20:54:36 rillig Exp $ */ +/* $NetBSD: opt_i.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ +/* + * Tests for the option '-i', which specifies the indentation for a single + * brace level. + */ + #indent input void example(void) Index: src/tests/usr.bin/indent/opt_l.c diff -u src/tests/usr.bin/indent/opt_l.c:1.1 src/tests/usr.bin/indent/opt_l.c:1.2 --- src/tests/usr.bin/indent/opt_l.c:1.1 Fri Oct 22 20:54:36 2021 +++ src/tests/usr.bin/indent/opt_l.c Sat Nov 20 16:54:17 2021 @@ -1,6 +1,13 @@ -/* $NetBSD: opt_l.c,v 1.1 2021/10/22 20:54:36 rillig Exp $ */ +/* $NetBSD: opt_l.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ +/* + * Tests for the option '-l', which specifies the maximum length of a line. + * + * As of 2021-11-20, indent assumes that each byte occupies a single column, + * it does not properly handle Unicode. + */ + #indent input /* * With a line length of 38, this comment and the next one are broken. @@ -23,11 +30,18 @@ #indent end #indent run-equals-prev-output -lc38 +#indent run-equals-input -l78 +#indent run-equals-input -lc78 + #indent input int decl; /* comment comment comment comment */ #indent end +/* + * The option '-lc' only applies to block comments, not to comments to the + * right of code or declarations. + */ #indent run -di8 -c17 -lc32 int decl; /* comment comment comment comment */ #indent end Index: src/tests/usr.bin/indent/opt_lc.c diff -u src/tests/usr.bin/indent/opt_lc.c:1.1 src/tests/usr.bin/indent/opt_lc.c:1.2 --- src/tests/usr.bin/indent/opt_lc.c:1.1 Fri Oct 22 20:54:36 2021 +++ src/tests/usr.bin/indent/opt_lc.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_lc.c,v 1.1 2021/10/22 20:54:36 rillig Exp $ */ +/* $NetBSD: opt_lc.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -8,17 +8,22 @@ */ #indent input -void -example(int a, int b, int c, const char *cp) -{ - for (const char *p = cp; *p != '\0'; p++) - if (*p > a) - if (*p > b) - if (*p > c) - return; +/* + * This block comment starts in column 1, it is broken into separate lines. + */ - function(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); -} +int decl; /* This is not a + * block comment, it is not affected by the option '-lc'. + */ #indent end -#indent run-equals-input -lc38 +#indent run -di0 -c17 -lc38 +/* + * This block comment starts in column + * 1, it is broken into separate + * lines. + */ + +int decl; /* This is not a block comment, it is not affected by the + * option '-lc'. */ +#indent end Index: src/tests/usr.bin/indent/opt_ta.c diff -u src/tests/usr.bin/indent/opt_ta.c:1.1 src/tests/usr.bin/indent/opt_ta.c:1.2 --- src/tests/usr.bin/indent/opt_ta.c:1.1 Fri Oct 22 20:54:36 2021 +++ src/tests/usr.bin/indent/opt_ta.c Sat Nov 20 16:54:17 2021 @@ -1,13 +1,19 @@ -/* $NetBSD: opt_ta.c,v 1.1 2021/10/22 20:54:36 rillig Exp $ */ +/* $NetBSD: opt_ta.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ +/* + * Tests for the option '-ta', which assumes that all identifiers that end in + * '_t' are type names. This mainly affects declarations and expressions + * containing type casts. + */ + #indent input void example(void *arg) { - int mult = (unknown_type_name) * arg; + int mult = (unknown_type_name) * arg; - int suff = (unknown_type_name_t) * arg; + int cast = (unknown_type_name_t) * arg; } #indent end @@ -17,6 +23,6 @@ example(void *arg) { int mult = (unknown_type_name) * arg; - int suff = (unknown_type_name_t)*arg; + int cast = (unknown_type_name_t)*arg; } #indent end Index: src/tests/usr.bin/indent/psym_for_exprs.c diff -u src/tests/usr.bin/indent/psym_for_exprs.c:1.1 src/tests/usr.bin/indent/psym_for_exprs.c:1.2 --- src/tests/usr.bin/indent/psym_for_exprs.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/psym_for_exprs.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: psym_for_exprs.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: psym_for_exprs.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -12,3 +12,19 @@ #indent end #indent run-equals-input + + +/* + * Since C99, the first expression of a 'for' loop may be a declaration, not + * only an expression. + */ +#indent input +void +function(void) +{ + for (int i = 0; i < 3; i++) + stmt(); +} +#indent end + +#indent run-equals-input Index: src/tests/usr.bin/indent/psym_switch_expr.c diff -u src/tests/usr.bin/indent/psym_switch_expr.c:1.1 src/tests/usr.bin/indent/psym_switch_expr.c:1.2 --- src/tests/usr.bin/indent/psym_switch_expr.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/psym_switch_expr.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: psym_switch_expr.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: psym_switch_expr.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -12,3 +12,35 @@ #indent end #indent run-equals-input + + +/* + * In all practical cases, a 'switch (expr)' is followed by a block, but the + * C syntax allows an arbitrary statement. Unless such a statement has a + * label, it is unreachable. + */ +#indent input +void +function(void) +{ + switch (expr) + if (cond) { + case 1: return; + case 2: break; + } +} +#indent end + +#indent run +void +function(void) +{ + switch (expr) + if (cond) { + case 1: + return; + case 2: + break; + } +} +#indent end Index: src/tests/usr.bin/indent/psym_while_expr.c diff -u src/tests/usr.bin/indent/psym_while_expr.c:1.1 src/tests/usr.bin/indent/psym_while_expr.c:1.2 --- src/tests/usr.bin/indent/psym_while_expr.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/psym_while_expr.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: psym_while_expr.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: psym_while_expr.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -12,3 +12,38 @@ #indent end #indent run-equals-input + + +#indent input +void +function(void) +{ + while(cond){} + + do{}while(cond); + + if(cmd)while(cond); + + {}while(cond); +} +#indent end + +#indent run +void +function(void) +{ + while (cond) { + } + + do { + } while (cond); + + if (cmd) + /* $ XXX: Where does the code say that ';' stays on the same line? */ + while (cond); + + { + /* $ FIXME: the '}' must be on a line of its own. */ + } while (cond); +} +#indent end Index: src/tests/usr.bin/indent/token_newline.c diff -u src/tests/usr.bin/indent/token_newline.c:1.1 src/tests/usr.bin/indent/token_newline.c:1.2 --- src/tests/usr.bin/indent/token_newline.c:1.1 Mon Oct 18 22:30:34 2021 +++ src/tests/usr.bin/indent/token_newline.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: token_newline.c,v 1.1 2021/10/18 22:30:34 rillig Exp $ */ +/* $NetBSD: token_newline.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /*- @@ -10,7 +10,7 @@ * characters are merged and continue the logical line (C11 5.1.1.2p1i2). * * In other contexts, a newline is an ordinary space character from a - * compiler's point of view. Indent preserves line breaks though. + * compiler's point of view. Indent preserves most line breaks though. */ #indent input Index: src/tests/usr.bin/indent/token_period.c diff -u src/tests/usr.bin/indent/token_period.c:1.1 src/tests/usr.bin/indent/token_period.c:1.2 --- src/tests/usr.bin/indent/token_period.c:1.1 Mon Oct 18 22:30:34 2021 +++ src/tests/usr.bin/indent/token_period.c Sat Nov 20 16:54:17 2021 @@ -1,16 +1,7 @@ -/* $NetBSD: token_period.c,v 1.1 2021/10/18 22:30:34 rillig Exp $ */ +/* $NetBSD: token_period.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* - * Tests for the token '.'. - * - * The '.' in numbers such as 3.14159265358979 is not a token '.'. - * - * The token '.' is used to access a member of a struct or union. - */ - - -/* * The ellipsis for the function parameter is a sequence of three '.' tokens. * It would have been more intuitive to model them as a single token, but it * doesn't make any difference for formatting the code. Index: src/tests/usr.bin/indent/token_while_expr.c diff -u src/tests/usr.bin/indent/token_while_expr.c:1.1 src/tests/usr.bin/indent/token_while_expr.c:1.2 --- src/tests/usr.bin/indent/token_while_expr.c:1.1 Mon Oct 18 22:30:34 2021 +++ src/tests/usr.bin/indent/token_while_expr.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: token_while_expr.c,v 1.1 2021/10/18 22:30:34 rillig Exp $ */ +/* $NetBSD: token_while_expr.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -24,7 +24,7 @@ main(int argc, char **argv) break; default: usage(); -/* $ XXX: The 'return' should be in a separate line. */ +/* $ FIXME: The 'return' must be in a separate line. */ } return 0; } #indent end Index: src/tests/usr.bin/indent/opt_ce.c diff -u src/tests/usr.bin/indent/opt_ce.c:1.3 src/tests/usr.bin/indent/opt_ce.c:1.4 --- src/tests/usr.bin/indent/opt_ce.c:1.3 Sat Oct 16 21:32:10 2021 +++ src/tests/usr.bin/indent/opt_ce.c Sat Nov 20 16:54:17 2021 @@ -1,13 +1,15 @@ -/* $NetBSD: opt_ce.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */ +/* $NetBSD: opt_ce.c,v 1.4 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* * Tests for the options '-ce' and '-nce'. * - * The option '-ce' places the 'else if' in a single line, as if it were only - * a single keyword. + * The option '-ce' places the 'else' on the same line as the preceding '}'. * * The option '-nce' places the 'else' on the next line. + * + * See also: + * opt_ei.c */ #indent input Index: src/tests/usr.bin/indent/opt_lp.c diff -u src/tests/usr.bin/indent/opt_lp.c:1.3 src/tests/usr.bin/indent/opt_lp.c:1.4 --- src/tests/usr.bin/indent/opt_lp.c:1.3 Sat Oct 16 21:32:10 2021 +++ src/tests/usr.bin/indent/opt_lp.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_lp.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */ +/* $NetBSD: opt_lp.c,v 1.4 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -24,6 +24,10 @@ example(void) p3), third_procedure(p4, p5)); + + p1 = first_procedure( + second_procedure(p2, p3), + third_procedure(p4, p5)); } #indent end @@ -38,6 +42,10 @@ example(void) p3), third_procedure(p4, p5)); + + p1 = first_procedure( + second_procedure(p2, p3), + third_procedure(p4, p5)); } #indent end @@ -52,5 +60,31 @@ example(void) p3), third_procedure(p4, p5)); + + p1 = first_procedure( + second_procedure(p2, p3), + third_procedure(p4, p5)); +} +#indent end + +/* + * XXX: Combining the options '-nlp' and '-ci4' is counterproductive as the + * indentation does not make the nesting level of the function calls visible. + */ +#indent run -nlp -ci4 +void +example(void) +{ + p1 = first_procedure(second_procedure(p2, p3), + third_procedure(p4, p5)); + + p1 = first_procedure(second_procedure(p2, + p3), + third_procedure(p4, + p5)); + + p1 = first_procedure( + second_procedure(p2, p3), + third_procedure(p4, p5)); } #indent end Index: src/tests/usr.bin/indent/opt_ci.c diff -u src/tests/usr.bin/indent/opt_ci.c:1.4 src/tests/usr.bin/indent/opt_ci.c:1.5 --- src/tests/usr.bin/indent/opt_ci.c:1.4 Sat Nov 20 11:13:18 2021 +++ src/tests/usr.bin/indent/opt_ci.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_ci.c,v 1.4 2021/11/20 11:13:18 rillig Exp $ */ +/* $NetBSD: opt_ci.c,v 1.5 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -189,3 +189,43 @@ sum(int a, int b) third)); } #indent end + + +/* + * In the default configuration, the indentation level from '-i' is the same + * as the continuation indentation from '-ci'. The difference between these + * becomes visible for structural macros like 'forever' or 'foreach'. + */ +#indent input +#define forever for (;;) +void +function(void) +{ + forever + stmt(); + + forever { + stmt(); + } +} +#indent end + +#indent run-equals-input + +/* + * The difference between the block indentation and the continuation + * indentation only becomes visible when these two differ. + */ +#indent run -i8 -ci4 +#define forever for (;;) +void +function(void) +{ + forever + stmt(); + + forever { + stmt(); + } +} +#indent end Index: src/tests/usr.bin/indent/opt_dj.c diff -u src/tests/usr.bin/indent/opt_dj.c:1.4 src/tests/usr.bin/indent/opt_dj.c:1.5 --- src/tests/usr.bin/indent/opt_dj.c:1.4 Sat Nov 20 11:13:18 2021 +++ src/tests/usr.bin/indent/opt_dj.c Sat Nov 20 16:54:17 2021 @@ -1,10 +1,10 @@ -/* $NetBSD: opt_dj.c,v 1.4 2021/11/20 11:13:18 rillig Exp $ */ +/* $NetBSD: opt_dj.c,v 1.5 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* * Tests for the options '-dj' and '-ndj'. * - * The option '-dj' left-justifies declarations. + * The option '-dj' left-justifies declarations of local variables. * * The option '-ndj' indents declarations the same as code. */ @@ -55,3 +55,25 @@ example(void) code(); } #indent end + + +/* + * The option '-dj' does not influence traditional function definitions. + */ +#indent input +double +dbl_plus3(a, b, c) +double a, b, c; +{ + return a + b + c; +} +#indent end + +#indent run -dj +double +dbl_plus3(a, b, c) + double a, b, c; +{ + return a + b + c; +} +#indent end Index: src/tests/usr.bin/indent/opt_ei.c diff -u src/tests/usr.bin/indent/opt_ei.c:1.4 src/tests/usr.bin/indent/opt_ei.c:1.5 --- src/tests/usr.bin/indent/opt_ei.c:1.4 Mon Oct 18 07:11:31 2021 +++ src/tests/usr.bin/indent/opt_ei.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_ei.c,v 1.4 2021/10/18 07:11:31 rillig Exp $ */ +/* $NetBSD: opt_ei.c,v 1.5 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -46,3 +46,23 @@ example(int n) } } #indent end + +#indent run -nei -nce +void +example(int n) +{ + if (n > 99) { + print("large"); + } + else + if (n > 9) { + print("double-digit"); + } + else + if (n > 0) + print("positive"); + else { + print("negative"); + } +} +#indent end Index: src/tests/usr.bin/indent/opt_fc1.c diff -u src/tests/usr.bin/indent/opt_fc1.c:1.4 src/tests/usr.bin/indent/opt_fc1.c:1.5 --- src/tests/usr.bin/indent/opt_fc1.c:1.4 Mon Oct 18 07:11:31 2021 +++ src/tests/usr.bin/indent/opt_fc1.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_fc1.c,v 1.4 2021/10/18 07:11:31 rillig Exp $ */ +/* $NetBSD: opt_fc1.c,v 1.5 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -6,7 +6,8 @@ * * The option '-fc1' formats comments in column 1. * - * The option '-nfc1' prevents comments in column 1 as is. + * The option '-nfc1' preserves the original formatting of comments that start + * in column 1. */ #indent input @@ -39,7 +40,7 @@ /* space */ /* $ Indented by a single tab, single tabs around the text. */ - /* tab */ + /* indented tab */ /* $ The space between these comments gets removed. */ /* block1 */ /* block2 */ @@ -56,7 +57,7 @@ /* space */ /* $ The indentation got removed, only the leading tab got replaced by a space. */ -/* tab */ +/* indented tab */ /* $ The space between these comments got removed. */ /* block1 *//* block2 */ @@ -76,7 +77,7 @@ /* space */ /* $ The indentation was changed from a single tab to a single space. */ - /* tab */ + /* indented tab */ /* $ The space between these two comments got removed. */ /* $ XXX: The option '-nfc1' says that comments in column 1 do not get */ @@ -111,7 +112,7 @@ * * followed by another multi-line comment that starts in column 4. */ -/* $ XXX: The two comments have been merged into a single comment. */ +/* $ FIXME: The two comments have been merged into a single comment. */ #indent end #indent run -nfc1 @@ -121,7 +122,7 @@ * * followed by another multi-line comment that starts in column 4. */ -/* $ XXX: The two comments have been merged into a single comment. */ +/* $ FIXME: The two comments have been merged into a single comment. */ #indent end Index: src/tests/usr.bin/indent/opt_fcb.c diff -u src/tests/usr.bin/indent/opt_fcb.c:1.4 src/tests/usr.bin/indent/opt_fcb.c:1.5 --- src/tests/usr.bin/indent/opt_fcb.c:1.4 Mon Oct 18 07:11:31 2021 +++ src/tests/usr.bin/indent/opt_fcb.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_fcb.c,v 1.4 2021/10/18 07:11:31 rillig Exp $ */ +/* $NetBSD: opt_fcb.c,v 1.5 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -7,32 +7,55 @@ * The option '-fcb' formats block comments (ones that begin with '/' '*' * '\n'). * - * The option '-nfcb' formats block comments like other box comments. + * The option '-nfcb' preserves block comments, like other box comments. */ -/* FIXME: The options -fcb and -nfcb result in exactly the same output. */ +/* + * The following comment starts with '/' '*' '\n'. + */ +#indent input +/* + * Block + * comment + * with delimiters. + */ +#indent end +#indent run -fcb +/* + * Block comment with delimiters. + */ +#indent end + +#indent run-equals-input -nfcb + + +/* + * The following comment does not count as a block comment since it has a word + * in its first line. + */ #indent input /* Not * - * so carefully - * formatted - * comment */ - -/*- - * car mat men - * efu for ted com t - * lly box . - */ + * a block + * comment. */ #indent end #indent run -fcb /* * Not * - * so carefully formatted comment + * a block comment. */ +#indent end +#indent run-equals-prev-output -nfcb + + +/* + * Block comments that start with '-' or another '*' are always preserved. + */ +#indent input /*- * car mat men * efu for ted com t @@ -40,23 +63,49 @@ */ #indent end -#indent run-equals-prev-output -nfcb +#indent run-equals-input -fcb +#indent run-equals-input -nfcb +/* + * The option '-fcb' does not distinguish between comments at the top level + * and comments in functions. + */ #indent input void example(void) { /* Not * - * so carefully - * formatted + * a block * comment */ +} +#indent end - /*- - * car mat men - * efu for ted com t - * lly box . +#indent run -fcb +void +example(void) +{ + /* + * Not + * + * a block comment + */ +} +#indent end + +#indent run-equals-prev-output -nfcb + + +#indent input +void +example(void) +{ + /* + * This is + * + * a block + * comment. */ } #indent end @@ -66,11 +115,20 @@ void example(void) { /* - * Not + * This is * - * so carefully formatted comment + * a block comment. */ +} +#indent end + +#indent run-equals-input -nfcb + +#indent input +void +example(void) +{ /*- * car mat men * efu for ted com t @@ -79,4 +137,5 @@ example(void) } #indent end -#indent run-equals-prev-output -nfcb +#indent run-equals-input -fcb +#indent run-equals-input -nfcb Index: src/tests/usr.bin/indent/opt_ip.c diff -u src/tests/usr.bin/indent/opt_ip.c:1.4 src/tests/usr.bin/indent/opt_ip.c:1.5 --- src/tests/usr.bin/indent/opt_ip.c:1.4 Mon Oct 18 07:11:31 2021 +++ src/tests/usr.bin/indent/opt_ip.c Sat Nov 20 16:54:17 2021 @@ -1,30 +1,57 @@ -/* $NetBSD: opt_ip.c,v 1.4 2021/10/18 07:11:31 rillig Exp $ */ +/* $NetBSD: opt_ip.c,v 1.5 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* * Tests for the options '-ip' and '-nip'. * - * The option '-ip' indents parameter declarations from the left margin. + * The option '-ip' indents parameter declarations from the left margin, for + * traditional function definitions. * - * The option '-nip' TODO. + * The option '-nip' places the parameter declarations in column 1. */ -/* FIXME: The options -ip and -nip produce the same output. */ +#indent input +double +plus3(a, b, c) + double a, b, c; +{ + return a + b + c; +} +#indent end + +#indent run -ip +double +plus3(a, b, c) + double a, b, c; +{ + return a + b + c; +} +#indent end + +#indent run -nip +double +plus3(a, b, c) +double a, b, c; +{ + return a + b + c; +} +#indent end + #indent input int -several_parameters_1(int a, +first_parameter_in_same_line(int a, int b, const char *cp); int -several_parameters_2( +parameters_in_separate_lines( int a, int b, const char *cp); int -several_parameters_3( +multiple_parameters_per_line( int a1, int a2, int b1, int b2, const char *cp); @@ -32,21 +59,21 @@ const char *cp); #indent run -ip int -several_parameters_1(int a, - int b, - const char *cp); +first_parameter_in_same_line(int a, + int b, + const char *cp); int -several_parameters_2( - int a, - int b, - const char *cp); +parameters_in_separate_lines( + int a, + int b, + const char *cp); int -several_parameters_3( - int a1, int a2, - int b1, int b2, - const char *cp); +multiple_parameters_per_line( + int a1, int a2, + int b1, int b2, + const char *cp); #indent end #indent run-equals-prev-output -nip Index: src/tests/usr.bin/indent/opt_lpl.c diff -u src/tests/usr.bin/indent/opt_lpl.c:1.4 src/tests/usr.bin/indent/opt_lpl.c:1.5 --- src/tests/usr.bin/indent/opt_lpl.c:1.4 Mon Oct 18 07:11:31 2021 +++ src/tests/usr.bin/indent/opt_lpl.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_lpl.c,v 1.4 2021/10/18 07:11:31 rillig Exp $ */ +/* $NetBSD: opt_lpl.c,v 1.5 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -8,8 +8,8 @@ * lines, even if it would extend past the right margin. * * The option '-nlpl' moves continuation lines that would stick over the right - * margin to the left, to keep it within the margin, if that does not require - * placing it to the left of the prevailing indentation level. + * margin to the left, to keep them within the margin, as long as that does + * not require placing them to the left of the prevailing indentation level. * * These switches have no effect if '-nlp' is selected. */ Index: src/tests/usr.bin/indent/opt_di.c diff -u src/tests/usr.bin/indent/opt_di.c:1.5 src/tests/usr.bin/indent/opt_di.c:1.6 --- src/tests/usr.bin/indent/opt_di.c:1.5 Sat Nov 20 11:13:18 2021 +++ src/tests/usr.bin/indent/opt_di.c Sat Nov 20 16:54:17 2021 @@ -1,9 +1,9 @@ -/* $NetBSD: opt_di.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */ +/* $NetBSD: opt_di.c,v 1.6 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* - * Test the option '-di', which specifies the indentation of the variable - * declarator. + * Test the option '-di', which specifies the indentation of the first + * variable name in a declaration. */ #indent input Index: src/tests/usr.bin/indent/opt_eei.c diff -u src/tests/usr.bin/indent/opt_eei.c:1.5 src/tests/usr.bin/indent/opt_eei.c:1.6 --- src/tests/usr.bin/indent/opt_eei.c:1.5 Sun Nov 7 08:03:15 2021 +++ src/tests/usr.bin/indent/opt_eei.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_eei.c,v 1.5 2021/11/07 08:03:15 rillig Exp $ */ +/* $NetBSD: opt_eei.c,v 1.6 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -43,8 +43,9 @@ less(int a, int b) #indent run-equals-input -neei /* - * When the indentation level is the same as the continuation indentation, the - * indentation does not show the structure of the code. + * When a single indentation level is the same as the continuation + * indentation, the code does not clearly show whether the 'b' belongs to the + * condition or the body statement. */ #indent run -neei -i4 bool Index: src/tests/usr.bin/indent/opt_psl.c diff -u src/tests/usr.bin/indent/opt_psl.c:1.5 src/tests/usr.bin/indent/opt_psl.c:1.6 --- src/tests/usr.bin/indent/opt_psl.c:1.5 Sat Nov 20 11:13:18 2021 +++ src/tests/usr.bin/indent/opt_psl.c Sat Nov 20 16:54:17 2021 @@ -1,8 +1,9 @@ -/* $NetBSD: opt_psl.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */ +/* $NetBSD: opt_psl.c,v 1.6 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* - * Tests for the options '-psl' and '-npsl'. + * Tests for the options '-psl' and '-npsl' ("procedure definition in separate + * line"). * * The option '-psl' starts a new line for the function name in a function * definition. @@ -26,6 +27,11 @@ void function_declaration(void); /* * Multi-line function declarations are affected by these options since indent * wrongly assumes they were function definitions, not declarations. + * + * Before 1990, when C90 added function prototypes, this case was rare since + * function definitions consisted only of the return type (defaulting to + * 'int'), the function name and the list of parameter names, without + * parameter types or type qualifiers like 'const'. */ #indent input void function_declaration( Index: src/tests/usr.bin/indent/opt_v.c diff -u src/tests/usr.bin/indent/opt_v.c:1.5 src/tests/usr.bin/indent/opt_v.c:1.6 --- src/tests/usr.bin/indent/opt_v.c:1.5 Sat Nov 20 11:13:18 2021 +++ src/tests/usr.bin/indent/opt_v.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_v.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */ +/* $NetBSD: opt_v.c,v 1.6 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -14,7 +14,7 @@ #indent input /* - * A long comment. + * A block comment. */ void example(void) @@ -22,16 +22,16 @@ example(void) printf("A very long message template with %d arguments: %s, %s, %s", 3, "first", "second", "third"); } -/* $ This comment is neither counted nor formatted. */ +/* $ The below comment is neither counted nor formatted. */ #define macro1 /* prefix */ suffix -/* $ This comment is formatted and counted. */ +/* $ The below comment is formatted and counted. */ #define macro2 prefix /* suffix */ #indent end #indent run -v /* - * A long comment. + * A block comment. */ void example(void) Index: src/tests/usr.bin/indent/opt_ldi.c diff -u src/tests/usr.bin/indent/opt_ldi.c:1.2 src/tests/usr.bin/indent/opt_ldi.c:1.3 --- src/tests/usr.bin/indent/opt_ldi.c:1.2 Sun Oct 24 20:43:28 2021 +++ src/tests/usr.bin/indent/opt_ldi.c Sat Nov 20 16:54:17 2021 @@ -1,9 +1,12 @@ -/* $NetBSD: opt_ldi.c,v 1.2 2021/10/24 20:43:28 rillig Exp $ */ +/* $NetBSD: opt_ldi.c,v 1.3 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* * Tests for the option '-ldi', which specifies where the variable names of * locally declared variables are placed. + * + * See also: + * opt_di.c */ #indent input @@ -16,6 +19,16 @@ function(void) } #indent end +#indent run -ldi0 +int global; + +void +function(void) +{ + int local; +} +#indent end + #indent run -ldi8 int global; @@ -57,7 +70,7 @@ function(void) #indent end /* - * Struct members use -di for indentation, no matter whether they are + * Struct members use '-di' for indentation, no matter whether they are * declared globally or locally. */ #indent run -ldi0 Index: src/tests/usr.bin/indent/opt_ut.c diff -u src/tests/usr.bin/indent/opt_ut.c:1.2 src/tests/usr.bin/indent/opt_ut.c:1.3 --- src/tests/usr.bin/indent/opt_ut.c:1.2 Sat Oct 16 21:32:10 2021 +++ src/tests/usr.bin/indent/opt_ut.c Sat Nov 20 16:54:17 2021 @@ -1,12 +1,12 @@ -/* $NetBSD: opt_ut.c,v 1.2 2021/10/16 21:32:10 rillig Exp $ */ +/* $NetBSD: opt_ut.c,v 1.3 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* * Tests for the options '-ut' and '-nut'. * - * The option '-ut' uses tabs for indentation. + * The option '-ut' uses tabs for indentation and alignment. * - * The option '-nut' uses only spaces for indentation. + * The option '-nut' uses only spaces for indentation and alignment. */ #indent input Index: src/tests/usr.bin/indent/ps_ind_level.c diff -u src/tests/usr.bin/indent/ps_ind_level.c:1.2 src/tests/usr.bin/indent/ps_ind_level.c:1.3 --- src/tests/usr.bin/indent/ps_ind_level.c:1.2 Sat Oct 30 10:52:43 2021 +++ src/tests/usr.bin/indent/ps_ind_level.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ps_ind_level.c,v 1.2 2021/10/30 10:52:43 rillig Exp $ */ +/* $NetBSD: ps_ind_level.c,v 1.3 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -16,14 +16,14 @@ * to 4 levels of indentation, amounting to 20 spaces. */ #indent input - int declaration_in_column_25; + int indented_by_24; void function_in_column_1(void){} #indent end /* 5 spaces indentation, 8 spaces per tabulator */ #indent run -i5 -ts8 - int declaration_in_column_25; + int indented_by_24; void function_in_column_1(void){ } Index: src/tests/usr.bin/indent/token_binary_op.c diff -u src/tests/usr.bin/indent/token_binary_op.c:1.8 src/tests/usr.bin/indent/token_binary_op.c:1.9 --- src/tests/usr.bin/indent/token_binary_op.c:1.8 Sat Nov 20 11:13:18 2021 +++ src/tests/usr.bin/indent/token_binary_op.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: token_binary_op.c,v 1.8 2021/11/20 11:13:18 rillig Exp $ */ +/* $NetBSD: token_binary_op.c,v 1.9 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -9,6 +9,8 @@ * multiplication, or pointer dereference, or pointer type declaration. */ +/* TODO: split into separate tests */ + /* See C99 6.4.6 */ #indent input void @@ -138,83 +140,64 @@ number = array <:subscript:>; number = (int)<%initializer % >; } #indent end +/* TODO: move digraphs into separate test */ +/* TODO: test trigraphs, which are as unusual as digraphs */ +/* TODO: test digraphs and trigraphs in string literals, just for fun */ +/* + * When indent tokenizes some of the operators, it allows for + * arbitrary repetitions of the operator character, followed by an + * arbitrary amount of '='. This is used for operators like '&&' or + * '|||==='. + * + * Before 2021-03-07 22:11:01, the comment '//' was treated as an + * operator as well, and so was the comment '/////', leading to + * unexpected results. + * + * See lexi.c, lexi, "default:". + */ #indent input void -peculiarities(void) +long_run_of_operators(void) { - /* - * When indent tokenizes some of the operators, it allows for - * arbitrary repetitions of the operator character, followed by an - * arbitrary amount of '='. This is used for operators like '&&' or - * '|||==='. - * - * Before 2021-03-07 22:11:01, the comment '//' was treated as an - * operator as well, and so was the comment '/////', leading to - * unexpected results; see comment-line-end.0 for more details. - * - * See lexi.c, lexi, "default:". - */ if (a &&&&&&& b) return; if (a |||=== b) return; +} +#indent end + +#indent run-equals-input + - /*- - * For '+' and '-', this does not work since the lexer has to - * distinguish between '++' and '+' early. The following sequence is - * thus tokenized as: - * - * ident 'a' - * postfix '++' - * binary_op '++' - * unary_op '++' - * unary_op '+' - * ident 'b' - * - * See lexi.c, lexi, "case '+':". - */ +/* + * For '+' and '-', this does not work since the lexer has to + * distinguish between '++' and '+' early. The following sequence is + * thus tokenized as: + * + * word "a" + * postfix_op "++" + * binary_op "++" + * unary_op "++" + * unary_op "+" + * word "b" + * + * See lexi.c, lexi, "case '+':". + */ +#indent input +void +joined_unary_and_binary_operators(void) +{ if (a +++++++ b) return; } #indent end -#indent run -ldi0 +#indent run void -peculiarities(void) +joined_unary_and_binary_operators(void) { - /* - * When indent tokenizes some of the operators, it allows for - * arbitrary repetitions of the operator character, followed by an - * arbitrary amount of '='. This is used for operators like '&&' or - * '|||==='. - * - * Before 2021-03-07 22:11:01, the comment '//' was treated as an - * operator as well, and so was the comment '/////', leading to - * unexpected results; see comment-line-end.0 for more details. - * - * See lexi.c, lexi, "default:". - */ - if (a &&&&&&& b) - return; - if (a |||=== b) - return; - - /*- - * For '+' and '-', this does not work since the lexer has to - * distinguish between '++' and '+' early. The following sequence is - * thus tokenized as: - * - * ident 'a' - * postfix '++' - * binary_op '++' - * unary_op '++' - * unary_op '+' - * ident 'b' - * - * See lexi.c, lexi, "case '+':". - */ if (a++ ++ ++ +b) return; } Index: src/tests/usr.bin/indent/token_comment.c diff -u src/tests/usr.bin/indent/token_comment.c:1.23 src/tests/usr.bin/indent/token_comment.c:1.24 --- src/tests/usr.bin/indent/token_comment.c:1.23 Sat Nov 20 11:13:18 2021 +++ src/tests/usr.bin/indent/token_comment.c Sat Nov 20 16:54:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: token_comment.c,v 1.23 2021/11/20 11:13:18 rillig Exp $ */ +/* $NetBSD: token_comment.c,v 1.24 2021/11/20 16:54:17 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -349,26 +349,26 @@ tab1+++ tab2--- tab3+++ tab4--- tab5+++ * space. */ #indent input -/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345 */ -/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456 */ -/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567 */ -/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678 */ -/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 */ +/* 456789 123456789 123456789 12345 */ +/* 456789 123456789 123456789 123456 */ +/* 456789 123456789 123456789 1234567 */ +/* 456789 123456789 123456789 12345678 */ +/* 456789 123456789 123456789 123456789 */ #indent end -#indent run -/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345 */ +#indent run -l38 +/* 456789 123456789 123456789 12345 */ /* - * 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456 + * 456789 123456789 123456789 123456 */ /* - * 456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567 + * 456789 123456789 123456789 1234567 */ /* - * 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678 + * 456789 123456789 123456789 12345678 */ /* - * 456789 123456789 123456789 123456789 123456789 123456789 123456789 + * 456789 123456789 123456789 * 123456789 */ #indent end @@ -380,32 +380,32 @@ tab1+++ tab2--- tab3+++ tab4--- tab5+++ * this space has to be taken into account when computing the line length. */ #indent input -/* x . line length 75*/ -/* x .. line length 76*/ -/* x ... line length 77*/ -/* x .... line length 78*/ -/* x ..... line length 79*/ -/* x ...... line length 80*/ -/* x ....... line length 81*/ -/* x ........ line length 82*/ +/* x . line length 35*/ +/* x .. line length 36*/ +/* x ... line length 37*/ +/* x .... line length 38*/ +/* x ..... line length 39*/ +/* x ...... line length 40*/ +/* x ....... line length 41*/ +/* x ........ line length 42*/ #indent end -#indent run -/* x . line length 75 */ -/* x .. line length 76 */ -/* x ... line length 77 */ -/* x .... line length 78 */ +#indent run -l38 +/* x . line length 35 */ +/* x .. line length 36 */ +/* x ... line length 37 */ +/* x .... line length 38 */ /* - * x ..... line length 79 + * x ..... line length 39 */ /* - * x ...... line length 80 + * x ...... line length 40 */ /* - * x ....... line length 81 + * x ....... line length 41 */ /* - * x ........ line length 82 + * x ........ line length 42 */ #indent end @@ -420,7 +420,8 @@ tab1+++ tab2--- tab3+++ tab4--- tab5+++ // This is a C99 line comment. /* - * This is a box comment since its first line (above this line) is empty. + * This is a box comment since its first line (the one above this line) is + * empty. * * * @@ -446,7 +447,8 @@ tab1+++ tab2--- tab3+++ tab4--- tab5+++ // This is a C99 line comment. /* - * This is a box comment since its first line (above this line) is empty. + * This is a box comment since its first line (the one above this line) is + * empty. * * * @@ -491,7 +493,6 @@ function(void) /*- * This is a box comment * that is not re-wrapped. - * It is often used for copyright declarations. */ } #indent end @@ -516,7 +517,6 @@ function(void) /*- * This is a box comment * that is not re-wrapped. - * It is often used for copyright declarations. */ } #indent end @@ -743,11 +743,11 @@ loop(void) * extended such that each comment line may contain 22 characters. */ #indent input -int global_variable_with_really_long_name_that_reaches_up_to_column_xx; /* 1234567890123456789 1 1234567890123456789 12 1234567890123456789 123 1234567890123456789 1234 1234567890123456789 12345 1234567890123456789 123456 */ +int global_variable_with_really_long_name_that_reaches_up_to_column_83; /* 1234567890123456789 1 1234567890123456789 12 1234567890123456789 123 1234567890123456789 1234 1234567890123456789 12345 1234567890123456789 123456 */ #indent end #indent run -int global_variable_with_really_long_name_that_reaches_up_to_column_xx; /* 1234567890123456789 1 +int global_variable_with_really_long_name_that_reaches_up_to_column_83; /* 1234567890123456789 1 * 1234567890123456789 12 * 1234567890123456789 * 123 @@ -765,15 +765,15 @@ int global_variable_with_really_long_na * * Even though this type of comments had been added in C99, indent didn't * support these comments until 2021 and instead messed up the code in - * unpredictable ways. It treated any sequence of '/' as a binary operator, - * no matter whether it was '/' or '//' or '/////'. + * seemingly unpredictable ways. It treated any sequence of '/' as a binary + * operator, no matter whether it was '/' or '//' or '/////'. */ #indent input int dummy // comment = // eq - 1 // one + 1 // one + // plus - 2; // two + 2;// two /////separator///// @@ -820,7 +820,7 @@ main(void) #indent input void c99_comment(void) { -foo(); // C++ comment +foo(); // C99 comment bar(); } #indent end @@ -829,7 +829,7 @@ bar(); void c99_comment(void) { - foo(); // C++ comment + foo(); // C99 comment bar(); } #indent end @@ -839,22 +839,14 @@ c99_comment(void) void comment_at_end_of_function(void) { - if (cond) - statement(); - // comment -} -#indent end - -#indent run -void -comment_at_end_of_function(void) -{ if (cond) statement(); // comment } #indent end +#indent run-equals-input + #indent input int decl;