Module Name: src
Committed By: rillig
Date: Sat Nov 20 11:13:18 UTC 2021
Modified Files:
src/tests/usr.bin/indent: fmt_decl.c indent_off_on.c label.c opt_bs.c
opt_ci.c opt_di.c opt_dj.c opt_pcs.c opt_psl.c opt_sc.c opt_v.c
t_options.awk token_binary_op.c token_colon.c token_comma.c
token_comment.c token_ident.c
Log Message:
tests/indent: normalize empty lines in tests
To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/indent_off_on.c \
src/tests/usr.bin/indent/opt_di.c src/tests/usr.bin/indent/opt_psl.c \
src/tests/usr.bin/indent/opt_sc.c src/tests/usr.bin/indent/opt_v.c \
src/tests/usr.bin/indent/t_options.awk \
src/tests/usr.bin/indent/token_ident.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/label.c \
src/tests/usr.bin/indent/token_colon.c \
src/tests/usr.bin/indent/token_comma.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/opt_bs.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/opt_ci.c \
src/tests/usr.bin/indent/opt_dj.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/opt_pcs.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/token_binary_op.c
cvs rdiff -u -r1.22 -r1.23 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/fmt_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.20 src/tests/usr.bin/indent/fmt_decl.c:1.21
--- src/tests/usr.bin/indent/fmt_decl.c:1.20 Sat Nov 20 09:59:53 2021
+++ src/tests/usr.bin/indent/fmt_decl.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fmt_decl.c,v 1.20 2021/11/20 09:59:53 rillig Exp $ */
+/* $NetBSD: fmt_decl.c,v 1.21 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
/*
@@ -369,6 +369,7 @@ x(void)
}
#indent end
+
#indent input
int *
y(void) {
Index: src/tests/usr.bin/indent/indent_off_on.c
diff -u src/tests/usr.bin/indent/indent_off_on.c:1.4 src/tests/usr.bin/indent/indent_off_on.c:1.5
--- src/tests/usr.bin/indent/indent_off_on.c:1.4 Fri Nov 19 22:24:29 2021
+++ src/tests/usr.bin/indent/indent_off_on.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent_off_on.c,v 1.4 2021/11/19 22:24:29 rillig Exp $ */
+/* $NetBSD: indent_off_on.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -91,6 +91,7 @@
}
#indent end
+
/*
* The INDENT comments can be written without space between the words, but
* nobody does this.
Index: src/tests/usr.bin/indent/opt_di.c
diff -u src/tests/usr.bin/indent/opt_di.c:1.4 src/tests/usr.bin/indent/opt_di.c:1.5
--- src/tests/usr.bin/indent/opt_di.c:1.4 Sun Oct 24 20:43:28 2021
+++ src/tests/usr.bin/indent/opt_di.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_di.c,v 1.4 2021/10/24 20:43:28 rillig Exp $ */
+/* $NetBSD: opt_di.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -85,7 +85,6 @@ int decl;
* Ensure that all whitespace is normalized to be indented by 8 columns,
* which in the default configuration amounts to a single tab.
*/
-
#indent input
int space;
int tab;
Index: src/tests/usr.bin/indent/opt_psl.c
diff -u src/tests/usr.bin/indent/opt_psl.c:1.4 src/tests/usr.bin/indent/opt_psl.c:1.5
--- src/tests/usr.bin/indent/opt_psl.c:1.4 Mon Oct 18 07:11:31 2021
+++ src/tests/usr.bin/indent/opt_psl.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_psl.c,v 1.4 2021/10/18 07:11:31 rillig Exp $ */
+/* $NetBSD: opt_psl.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -22,6 +22,7 @@ void function_declaration(void);
#indent run-equals-prev-output -npsl
+
/*
* Multi-line function declarations are affected by these options since indent
* wrongly assumes they were function definitions, not declarations.
@@ -46,6 +47,7 @@ void function_declaration(
void);
#indent end
+
/*
* In a function definition, in contrast to a declaration, the function name
* is not indented to column 17 since the other function definitions are too
Index: src/tests/usr.bin/indent/opt_sc.c
diff -u src/tests/usr.bin/indent/opt_sc.c:1.4 src/tests/usr.bin/indent/opt_sc.c:1.5
--- src/tests/usr.bin/indent/opt_sc.c:1.4 Mon Oct 18 07:11:31 2021
+++ src/tests/usr.bin/indent/opt_sc.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_sc.c,v 1.4 2021/10/18 07:11:31 rillig Exp $ */
+/* $NetBSD: opt_sc.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -50,6 +50,7 @@ comment without asterisks
*/
#indent end
+
/*
* Comments that start with '*' or '-' do not get modified at all.
*/
Index: src/tests/usr.bin/indent/opt_v.c
diff -u src/tests/usr.bin/indent/opt_v.c:1.4 src/tests/usr.bin/indent/opt_v.c:1.5
--- src/tests/usr.bin/indent/opt_v.c:1.4 Sun Nov 7 15:44:28 2021
+++ src/tests/usr.bin/indent/opt_v.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_v.c,v 1.4 2021/11/07 15:44:28 rillig Exp $ */
+/* $NetBSD: opt_v.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -46,6 +46,7 @@ There were 10 output lines and 2 comment
(Lines with comments)/(Lines with code): 0.571
#indent end
+
#indent input
void
example(void)
Index: src/tests/usr.bin/indent/t_options.awk
diff -u src/tests/usr.bin/indent/t_options.awk:1.4 src/tests/usr.bin/indent/t_options.awk:1.5
--- src/tests/usr.bin/indent/t_options.awk:1.4 Sat Nov 20 10:24:30 2021
+++ src/tests/usr.bin/indent/t_options.awk Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_options.awk,v 1.4 2021/11/20 10:24:30 rillig Exp $
+# $NetBSD: t_options.awk,v 1.5 2021/11/20 11:13:18 rillig Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -56,6 +56,10 @@ BEGIN {
warned = 0
died = 0
+ prev_empty_lines = 0 # the finished "block" of empty lines
+ curr_empty_lines = 0 # the ongoing "block" of empty lines
+ seen_input_section = 0 # the first input section is not checked
+
section = "" # "", "input" or "run"
section_excl_comm = "" # without dollar comments
section_incl_comm = "" # with dollar comments
@@ -106,6 +110,20 @@ function run_indent(inp, i, cmd)
close(cmd)
}
+section == "" {
+ if (NF == 0)
+ curr_empty_lines++
+ else {
+ if (curr_empty_lines > 0) {
+ if (prev_empty_lines > 1)
+ warn(NR - curr_empty_lines,
+ "excess empty lines a few lines above")
+ prev_empty_lines = curr_empty_lines
+ }
+ curr_empty_lines = 0
+ }
+}
+
# Hide comments starting with dollar from indent; they are used for marking
# bugs and adding other remarks directly in the input or output sections.
/^[[:space:]]*\/[*][[:space:]]*[$].*[*]\/$/ ||
@@ -120,15 +138,22 @@ function run_indent(inp, i, cmd)
print $0 > "expected.out"
if ($2 == "input") {
+ if (prev_empty_lines != 2 && seen_input_section)
+ warn(NR, "input section needs 2 empty lines above, " \
+ "not " prev_empty_lines)
check_unused_input()
section = "input"
section_excl_comm = ""
section_incl_comm = ""
unused_input_lineno = NR
+ seen_input_section = 1
} else if ($2 == "run") {
if (section != "")
warn(NR, "unfinished section " quote(section))
+ if (prev_empty_lines != 1)
+ warn(NR, "run section needs 1 empty line above, " \
+ "not " prev_empty_lines)
section = "run"
output_lineno = NR
section_excl_comm = ""
@@ -173,6 +198,8 @@ function run_indent(inp, i, cmd)
die(NR, "invalid line " quote($0))
}
+ prev_empty_lines = 0
+ curr_empty_lines = 0
next
}
Index: src/tests/usr.bin/indent/token_ident.c
diff -u src/tests/usr.bin/indent/token_ident.c:1.4 src/tests/usr.bin/indent/token_ident.c:1.5
--- src/tests/usr.bin/indent/token_ident.c:1.4 Sat Nov 20 09:59:53 2021
+++ src/tests/usr.bin/indent/token_ident.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_ident.c,v 1.4 2021/11/20 09:59:53 rillig Exp $ */
+/* $NetBSD: token_ident.c,v 1.5 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -40,6 +40,7 @@ t(void)
}
#indent end
+
/* Floating point numbers. */
#indent input
void t(void) {
Index: src/tests/usr.bin/indent/label.c
diff -u src/tests/usr.bin/indent/label.c:1.1 src/tests/usr.bin/indent/label.c:1.2
--- src/tests/usr.bin/indent/label.c:1.1 Mon Oct 18 20:18:00 2021
+++ src/tests/usr.bin/indent/label.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: label.c,v 1.1 2021/10/18 20:18:00 rillig Exp $ */
+/* $NetBSD: label.c,v 1.2 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD: head/usr.bin/indent/tests/label.0 313544 2017-02-10 09:31:39Z pstef $ */
/* See FreeBSD r303489 */
@@ -32,6 +32,7 @@ U: ;
}
#indent end
+
#indent input
void
label_width(void)
@@ -62,6 +63,7 @@ L______8:;
}
#indent end
+
/*
* The indentation of statement labels is fixed to -2, it is not configurable.
*/
Index: src/tests/usr.bin/indent/token_colon.c
diff -u src/tests/usr.bin/indent/token_colon.c:1.1 src/tests/usr.bin/indent/token_colon.c:1.2
--- src/tests/usr.bin/indent/token_colon.c:1.1 Mon Oct 18 22:30:34 2021
+++ src/tests/usr.bin/indent/token_colon.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_colon.c,v 1.1 2021/10/18 22:30:34 rillig Exp $ */
+/* $NetBSD: token_colon.c,v 1.2 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -39,6 +39,7 @@ label1:
}
#indent end
+
#indent input
int constant_expression = true?4:12345;
#indent end
@@ -47,6 +48,7 @@ int constant_expression = true?4:12345;
int constant_expression = true ? 4 : 12345;
#indent end
+
#indent input
struct bit_field {
bool flag:1;
Index: src/tests/usr.bin/indent/token_comma.c
diff -u src/tests/usr.bin/indent/token_comma.c:1.1 src/tests/usr.bin/indent/token_comma.c:1.2
--- src/tests/usr.bin/indent/token_comma.c:1.1 Mon Oct 18 22:30:34 2021
+++ src/tests/usr.bin/indent/token_comma.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comma.c,v 1.1 2021/10/18 22:30:34 rillig Exp $ */
+/* $NetBSD: token_comma.c,v 1.2 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -32,6 +32,7 @@ comma_expression(void)
}
#indent end
+
/*
* A comma that occurs at the beginning of a line is probably part of an
* initializer list, placed there for alignment.
Index: src/tests/usr.bin/indent/opt_bs.c
diff -u src/tests/usr.bin/indent/opt_bs.c:1.6 src/tests/usr.bin/indent/opt_bs.c:1.7
--- src/tests/usr.bin/indent/opt_bs.c:1.6 Fri Nov 19 22:24:29 2021
+++ src/tests/usr.bin/indent/opt_bs.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bs.c,v 1.6 2021/11/19 22:24:29 rillig Exp $ */
+/* $NetBSD: opt_bs.c,v 1.7 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -61,6 +61,7 @@ example(int i)
}
#indent end
+
/*
* The option '-bs' only affects 'sizeof', not 'offsetof', even though these
* two keywords are syntactically similar.
Index: src/tests/usr.bin/indent/opt_ci.c
diff -u src/tests/usr.bin/indent/opt_ci.c:1.3 src/tests/usr.bin/indent/opt_ci.c:1.4
--- src/tests/usr.bin/indent/opt_ci.c:1.3 Mon Nov 1 23:44:08 2021
+++ src/tests/usr.bin/indent/opt_ci.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_ci.c,v 1.3 2021/11/01 23:44:08 rillig Exp $ */
+/* $NetBSD: opt_ci.c,v 1.4 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -58,6 +58,7 @@ int top_level = (1 +
3));
#indent end
+
/*
* Declarations in functions without parentheses.
*/
Index: src/tests/usr.bin/indent/opt_dj.c
diff -u src/tests/usr.bin/indent/opt_dj.c:1.3 src/tests/usr.bin/indent/opt_dj.c:1.4
--- src/tests/usr.bin/indent/opt_dj.c:1.3 Mon Oct 18 07:11:31 2021
+++ src/tests/usr.bin/indent/opt_dj.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_dj.c,v 1.3 2021/10/18 07:11:31 rillig Exp $ */
+/* $NetBSD: opt_dj.c,v 1.4 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -30,6 +30,7 @@ const void ********vpppppppp;
#indent run-equals-prev-output -ndj
+
#indent input
void example(void) {
int decl;
Index: src/tests/usr.bin/indent/opt_pcs.c
diff -u src/tests/usr.bin/indent/opt_pcs.c:1.8 src/tests/usr.bin/indent/opt_pcs.c:1.9
--- src/tests/usr.bin/indent/opt_pcs.c:1.8 Sun Oct 31 21:43:43 2021
+++ src/tests/usr.bin/indent/opt_pcs.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_pcs.c,v 1.8 2021/10/31 21:43:43 rillig Exp $ */
+/* $NetBSD: opt_pcs.c,v 1.9 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -57,6 +57,7 @@ void (*signal(void (*handler)(int)))(int
int var = (function)(arg);
#indent end
+
/*
* The option '-pcs' also applies to 'sizeof' and 'offsetof', even though
* these are not functions.
Index: src/tests/usr.bin/indent/token_binary_op.c
diff -u src/tests/usr.bin/indent/token_binary_op.c:1.7 src/tests/usr.bin/indent/token_binary_op.c:1.8
--- src/tests/usr.bin/indent/token_binary_op.c:1.7 Thu Nov 4 17:12:12 2021
+++ src/tests/usr.bin/indent/token_binary_op.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_binary_op.c,v 1.7 2021/11/04 17:12:12 rillig Exp $ */
+/* $NetBSD: token_binary_op.c,v 1.8 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -139,6 +139,7 @@ number = array <:subscript:>;
}
#indent end
+
#indent input
void
peculiarities(void)
Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.22 src/tests/usr.bin/indent/token_comment.c:1.23
--- src/tests/usr.bin/indent/token_comment.c:1.22 Sun Nov 7 12:26:22 2021
+++ src/tests/usr.bin/indent/token_comment.c Sat Nov 20 11:13:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.22 2021/11/07 12:26:22 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.23 2021/11/20 11:13:18 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -63,6 +63,7 @@ typedef enum x {
#indent run-equals-input -bbb
+
#indent input
/* See FreeBSD r303597, r303598, r309219, and r309343 */
void
@@ -372,6 +373,7 @@ tab1+++ tab2--- tab3+++ tab4--- tab5+++
*/
#indent end
+
/*
* The following comments test line breaking when the comment does not end
* with a space. Since indent adds a trailing space to a single-line comment,
@@ -407,6 +409,7 @@ tab1+++ tab2--- tab3+++ tab4--- tab5+++
*/
#indent end
+
/*
* The different types of comments that indent distinguishes, starting in
* column 1 (see options '-fc1' and '-nfc1').
@@ -462,6 +465,7 @@ tab1+++ tab2--- tab3+++ tab4--- tab5+++
*/
#indent end
+
/*
* The different types of comments that indent distinguishes, starting in
* column 9, so they are independent of the option '-fc1'.
@@ -517,6 +521,7 @@ function(void)
}
#indent end
+
/*
* Comments to the right of declarations.
*/
@@ -585,6 +590,7 @@ function(void)
}
#indent end
+
/*
* Comments to the right of code.
*/
@@ -706,6 +712,7 @@ There may also be
*/
#indent end
+
#indent input
void loop(void)
{
@@ -729,6 +736,7 @@ loop(void)
}
#indent end
+
/*
* The following comment starts really far to the right. To avoid that each
* line only contains a single word, the maximum allowed line width is
@@ -751,6 +759,7 @@ int global_variable_with_really_long_na
* 123456 */
#indent end
+
/*
* Demonstrates handling of line-end '//' comments.
*
@@ -759,7 +768,6 @@ int global_variable_with_really_long_na
* unpredictable ways. It treated any sequence of '/' as a binary operator,
* no matter whether it was '/' or '//' or '/////'.
*/
-
#indent input
int dummy // comment
= // eq
@@ -803,6 +811,7 @@ main(void)
}
#indent end
+
/*
* Between March 2021 and October 2021, indent supported C99 comments only
* very basically. It messed up the following code, repeating the identifier
@@ -825,6 +834,7 @@ c99_comment(void)
}
#indent end
+
#indent input
void
comment_at_end_of_function(void)
@@ -845,6 +855,7 @@ comment_at_end_of_function(void)
}
#indent end
+
#indent input
int decl;
// end-of-line comment at the end of the file
@@ -861,6 +872,7 @@ int decl;
#indent end
#indent run-equals-input
+
/*
* At the beginning of a block comment or after a '*', '\f' is special. This
* is an implementation detail that should not be visible from the outside.
@@ -887,6 +899,7 @@ int decl;
#indent run-equals-input -nfc1
+
/*
* A completely empty line in a box comment must be copied unmodified to the
* output. This is done in process_comment by adding a space to the end of an
@@ -915,9 +928,6 @@ end */
#indent end
-/*
- *
- */
#indent input
int f(void)
{
@@ -1034,6 +1044,7 @@ line 4
#indent run-equals-input
+
/*
* Cover the code for expanding the comment buffer in com_terminate. As of
* 2021-11-07, the default buffer size is 200, with a safety margin of 1 at