Module Name: src Committed By: rillig Date: Tue May 23 06:18:00 UTC 2023
Modified Files: src/tests/usr.bin/indent: fmt_decl.c lsym_for.c lsym_unary_op.c opt_bap.c opt_lp.c opt_sob.c Log Message: tests/indent: add code snippets found in make and lint1 To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/lsym_for.c cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/lsym_unary_op.c \ src/tests/usr.bin/indent/opt_lp.c cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/opt_bap.c cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/opt_sob.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/fmt_decl.c diff -u src/tests/usr.bin/indent/fmt_decl.c:1.43 src/tests/usr.bin/indent/fmt_decl.c:1.44 --- src/tests/usr.bin/indent/fmt_decl.c:1.43 Tue May 16 08:22:11 2023 +++ src/tests/usr.bin/indent/fmt_decl.c Tue May 23 06:18:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_decl.c,v 1.43 2023/05/16 08:22:11 rillig Exp $ */ +/* $NetBSD: fmt_decl.c,v 1.44 2023/05/23 06:18:00 rillig Exp $ */ /* * Tests for declarations of global variables, external functions, and local @@ -960,3 +960,53 @@ ch_isalpha(char ch) //indent end //indent run-equals-input -i4 -di0 + + +//indent input +struct { + void *list; + Table /* comment */ table; +} var; +//indent end + +//indent run -di0 +struct { + void *list; +// $ FIXME: Wrong indentation, as 'Table' starts a new declaration. + Table /* comment */ table; +} var; +//indent end + + +//indent input +void __printflike(1, 2) +debug_printf(const char *fmt, ...) +{ +} +//indent end + +//indent run +void +// $ FIXME: No line break here. +__printflike(1, 2) +debug_printf(const char *fmt, ...) +{ +} +//indent end + + +//indent input +void +(error_at)(int msgid, const pos_t *pos, ...) +{ +} +//indent end + +//indent run -ci4 -di0 -ndj -nlp +void +// $ FIXME: Wrong indentation, should be 0 instead. +// $ FIXME: Wrong spacing around '*'. + (error_at)(int msgid, const pos_t * pos, ...) +{ +} +//indent end Index: src/tests/usr.bin/indent/lsym_for.c diff -u src/tests/usr.bin/indent/lsym_for.c:1.4 src/tests/usr.bin/indent/lsym_for.c:1.5 --- src/tests/usr.bin/indent/lsym_for.c:1.4 Sun Apr 24 10:36:37 2022 +++ src/tests/usr.bin/indent/lsym_for.c Tue May 23 06:18:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_for.c,v 1.4 2022/04/24 10:36:37 rillig Exp $ */ +/* $NetBSD: lsym_for.c,v 1.5 2023/05/23 06:18:00 rillig Exp $ */ /* * Tests for the token lsym_for, which represents the keyword 'for' that @@ -87,3 +87,19 @@ function(void) //indent end //indent run-equals-input + + +//indent input +{ + for (const list_item *i = first; i != NULL; i = i->next) { + } +} +//indent end + +//indent run +{ +// $ FIXME: Wrong spacing after '*'. + for (const list_item * i = first; i != NULL; i = i->next) { + } +} +//indent end Index: src/tests/usr.bin/indent/lsym_unary_op.c diff -u src/tests/usr.bin/indent/lsym_unary_op.c:1.6 src/tests/usr.bin/indent/lsym_unary_op.c:1.7 --- src/tests/usr.bin/indent/lsym_unary_op.c:1.6 Sat May 13 06:52:48 2023 +++ src/tests/usr.bin/indent/lsym_unary_op.c Tue May 23 06:18:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_unary_op.c,v 1.6 2023/05/13 06:52:48 rillig Exp $ */ +/* $NetBSD: lsym_unary_op.c,v 1.7 2023/05/23 06:18:00 rillig Exp $ */ /* * Tests for the token lsym_unary_op, which represents a unary operator. @@ -77,3 +77,18 @@ unary_operators(void) //indent end //indent run-equals-input -di0 + + +//indent input +{ +sbuf_t *sb = *(sbuf_t **)sp; +} +//indent end + +//indent run -di0 +{ +// $ FIXME: Wrong spacing between the '*'. +// $ FIXME: Wrong spacing after the cast. + sbuf_t *sb = *(sbuf_t * *) sp; +} +//indent end Index: src/tests/usr.bin/indent/opt_lp.c diff -u src/tests/usr.bin/indent/opt_lp.c:1.6 src/tests/usr.bin/indent/opt_lp.c:1.7 --- src/tests/usr.bin/indent/opt_lp.c:1.6 Sun Apr 24 09:04:12 2022 +++ src/tests/usr.bin/indent/opt_lp.c Tue May 23 06:18:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_lp.c,v 1.6 2022/04/24 09:04:12 rillig Exp $ */ +/* $NetBSD: opt_lp.c,v 1.7 2023/05/23 06:18:00 rillig Exp $ */ /* * Tests for the options '-lp' and '-nlp'. @@ -87,3 +87,25 @@ example(void) third_procedure(p4, p5)); } //indent end + + +//indent input +{ +if (cond) { +} else if (cond && +cond && +cond) { +} +} +//indent end + +//indent run -ci4 -nlp +{ + if (cond) { + } else if (cond && +// $ FIXME: Wrong indentation, should be 4 spaces only. + cond && + cond) { + } +} +//indent end Index: src/tests/usr.bin/indent/opt_bap.c diff -u src/tests/usr.bin/indent/opt_bap.c:1.8 src/tests/usr.bin/indent/opt_bap.c:1.9 --- src/tests/usr.bin/indent/opt_bap.c:1.8 Sat May 20 12:05:01 2023 +++ src/tests/usr.bin/indent/opt_bap.c Tue May 23 06:18:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_bap.c,v 1.8 2023/05/20 12:05:01 rillig Exp $ */ +/* $NetBSD: opt_bap.c,v 1.9 2023/05/23 06:18:00 rillig Exp $ */ /* * Tests for the options '-bap' and '-nbap' ("blank line after procedure @@ -111,3 +111,29 @@ example(void) //indent end //indent run-equals-input -bap + + +//indent input +#if 0 +void +f(void) +{ +} +#else +#endif +//indent end + +//indent run -bacc -bap +#if 0 +void +f(void) +{ +} +// $ The following blank line may be considered optional, as it precedes a +// $ preprocessing line. In that case, the -bap option would only apply to +// $ elements on the same syntactic level, such as function definitions and +// $ other declarations. + +#else +#endif +//indent end Index: src/tests/usr.bin/indent/opt_sob.c diff -u src/tests/usr.bin/indent/opt_sob.c:1.7 src/tests/usr.bin/indent/opt_sob.c:1.8 --- src/tests/usr.bin/indent/opt_sob.c:1.7 Mon May 22 10:28:59 2023 +++ src/tests/usr.bin/indent/opt_sob.c Tue May 23 06:18:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_sob.c,v 1.7 2023/05/22 10:28:59 rillig Exp $ */ +/* $NetBSD: opt_sob.c,v 1.8 2023/05/23 06:18:00 rillig Exp $ */ /* * Tests for the options '-sob' and '-nsob'. @@ -26,6 +26,9 @@ function_with_0_blank_lines(void) var = value; if (var > 0) var--; + if (var > 0) { + var--; + } return var; } @@ -42,6 +45,13 @@ function_with_1_blank_line(void) var--; + if (var > 0) { +/* $ The following line is "optional" and is removed due to '-sob'. */ + + var--; + + } + return var; } @@ -65,6 +75,15 @@ function_with_2_blank_lines(void) var--; + if (var > 0) { + + + var--; + + + } + + return var; @@ -82,6 +101,9 @@ function_with_0_blank_lines(void) var = value; if (var > 0) var--; + if (var > 0) { + var--; + } return var; } @@ -96,6 +118,12 @@ function_with_1_blank_line(void) if (var > 0) var--; + if (var > 0) { + var--; +// $ XXX: The following blank line may be considered optional. + + } + return var; } @@ -112,6 +140,12 @@ function_with_2_blank_lines(void) if (var > 0) var--; + if (var > 0) { + var--; +// $ XXX: The following blank line may be considered optional. + + } + return var; }