Module Name: src
Committed By: rillig
Date: Sun Nov 28 15:26:22 UTC 2021
Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/indent: Makefile lsym_comma.c
Removed Files:
src/tests/usr.bin/indent: token_comma.c
Log Message:
tests/indent: migrate token_comma to lsym_comma
The section on initializer values is new.
To generate a diff of this commit:
cvs rdiff -u -r1.1170 -r1.1171 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.36 -r1.37 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lsym_comma.c
cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/indent/token_comma.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1170 src/distrib/sets/lists/tests/mi:1.1171
--- src/distrib/sets/lists/tests/mi:1.1170 Sun Nov 28 14:49:28 2021
+++ src/distrib/sets/lists/tests/mi Sun Nov 28 15:26:22 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1170 2021/11/28 14:49:28 rillig Exp $
+# $NetBSD: mi,v 1.1171 2021/11/28 15:26:22 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -5245,7 +5245,7 @@
./usr/tests/usr.bin/indent/token_binary_op.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/token_case_label.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/token_colon.c tests-obsolete obsolete,atf
-./usr/tests/usr.bin/indent/token_comma.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/token_comma.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/indent/token_comment.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/token_decl.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/token_do_stmt.c tests-usr.bin-tests compattestfile,atf
Index: src/tests/usr.bin/indent/Makefile
diff -u src/tests/usr.bin/indent/Makefile:1.36 src/tests/usr.bin/indent/Makefile:1.37
--- src/tests/usr.bin/indent/Makefile:1.36 Sun Nov 28 14:49:28 2021
+++ src/tests/usr.bin/indent/Makefile Sun Nov 28 15:26:22 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.36 2021/11/28 14:49:28 rillig Exp $
+# $NetBSD: Makefile,v 1.37 2021/11/28 15:26:22 rillig Exp $
.include <bsd.own.mk>
@@ -112,7 +112,6 @@ FILES+= psym_while_expr.c
FILES+= t_options.awk
FILES+= token_binary_op.c
FILES+= token_case_label.c
-FILES+= token_comma.c
FILES+= token_comment.c
FILES+= token_decl.c
FILES+= token_do_stmt.c
Index: src/tests/usr.bin/indent/lsym_comma.c
diff -u src/tests/usr.bin/indent/lsym_comma.c:1.2 src/tests/usr.bin/indent/lsym_comma.c:1.3
--- src/tests/usr.bin/indent/lsym_comma.c:1.2 Sat Nov 20 16:54:17 2021
+++ src/tests/usr.bin/indent/lsym_comma.c Sun Nov 28 15:26:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_comma.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */
+/* $NetBSD: lsym_comma.c,v 1.3 2021/11/28 15:26:22 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -22,10 +22,161 @@
* In a macro definition, a ',' separates the parameter names.
*
* In a macro invocation, a ',' separates the arguments.
+ *
+ * In an initializer list, a ',' separates the initializer expressions.
*/
+/*
+ * The ',' is a binary operator with very low precedence.
+ */
#indent input
-// TODO: add input
+int
+comma_expression(void)
+{
+ return 1, 3;
+ return a = b, c = d;
+}
#indent end
#indent run-equals-input
+
+
+/*
+ * In a declaration, a ',' separates the declarators.
+ */
+#indent input
+int decl, old_style(), prototype(const char *, double *);
+int a, b, c;
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In a parameter list of a function type, a ',' separates the parameter
+ * declarations.
+ */
+#indent input
+double dbl_reduce(double init, const double *s, const double *e, double (*merge)(double, double));
+double dbl_reduce(double, const double *, const double *, double (*)(double, double));
+void debug_printf(const char *, ...);
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In a traditional function definition, a ',' separates the parameter names.
+ */
+#indent input
+double
+trad_dbl_reduce(init, s, e, merge)
+ double init;
+ double *s, *e;
+ double (*merge)()
+{
+ double x = init;
+ while (s < e)
+ x = merge(x, *s++);
+ return x;
+}
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In a prototype function definition, a ',' separates the parameter
+ * declarations.
+ */
+#indent input
+void
+dbl_reduce(double init, const double *s, const double *e, double (*merge)(double, double))
+{
+ double x = init;
+ while (s < e)
+ x = merge(x, *s++);
+ return x;
+}
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In a function call expression, a ',' separates the arguments.
+ */
+#indent input
+void
+function(void)
+{
+ function_call(arg1, arg2);
+ (*indirect_function_call)(arg1, arg2);
+}
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In a macro definition, a ',' separates the parameter names.
+ */
+#indent input
+#define no_space(a,b) a ## b
+#define normal_space(a, b) a ## b
+#define wide_space(a , b) a ## b
+#indent end
+
+/*
+ * Indent does not touch preprocessor directives, except for the spacing
+ * between the '#' and the directive.
+ */
+#indent run-equals-input
+
+
+/*
+ * In a macro invocation, a ',' separates the arguments.
+ */
+#indent input
+void
+function(void)
+{
+ macro_invocation(arg1, arg2);
+ empty_arguments(,,,);
+}
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * In an initializer list, a ',' separates the initializer expressions.
+ *
+ * If a ',' starts a line, indent doesn't put a space before it.
+ */
+#indent input
+int arr[] = {1, 2, 3};
+int arr[] = {
+ 1,
+ 2,
+ 3, /* there may be a trailing comma */
+};
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * If a ',' starts a line, indent doesn't put a space before it. This style is
+ * uncommon and looks unbalanced since the '1' is not aligned to the other
+ * numbers.
+ */
+#indent input
+int arr[] = {
+ 1
+ ,2
+ ,3
+};
+#indent end
+
+#indent run-equals-input -di0