Module Name:    src
Committed By:   rillig
Date:           Fri Oct 22 19:27:53 UTC 2021

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/tests/usr.bin/indent: Makefile opt_v.c t_misc.sh
Added Files:
        src/tests/usr.bin/indent: fmt_block.c fmt_decl.c fmt_else_comment.c
            lex_ident.c
Removed Files:
        src/tests/usr.bin/indent: block.0 block.0.stdout declarations.0
            declarations.0.stderr declarations.0.stdout elsecomment.0
            elsecomment.0.pro elsecomment.0.stdout indent_variables.0
            indent_variables.0.pro indent_variables.0.stdout lex.0 lex.0.pro
            lex.0.stdout lineno.0 lineno.0.pro lineno.0.stdout

Log Message:
tests/indent: migrate a few more tests to t_options


To generate a diff of this commit:
cvs rdiff -u -r1.1148 -r1.1149 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.24 -r1.25 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r1.1 -r0 src/tests/usr.bin/indent/block.0 \
    src/tests/usr.bin/indent/block.0.stdout \
    src/tests/usr.bin/indent/declarations.0.stderr \
    src/tests/usr.bin/indent/elsecomment.0 \
    src/tests/usr.bin/indent/elsecomment.0.pro \
    src/tests/usr.bin/indent/indent_variables.0 \
    src/tests/usr.bin/indent/indent_variables.0.pro \
    src/tests/usr.bin/indent/indent_variables.0.stdout \
    src/tests/usr.bin/indent/lex.0 src/tests/usr.bin/indent/lex.0.pro \
    src/tests/usr.bin/indent/lex.0.stdout src/tests/usr.bin/indent/lineno.0 \
    src/tests/usr.bin/indent/lineno.0.pro \
    src/tests/usr.bin/indent/lineno.0.stdout
cvs rdiff -u -r1.4 -r0 src/tests/usr.bin/indent/declarations.0
cvs rdiff -u -r1.5 -r0 src/tests/usr.bin/indent/declarations.0.stdout
cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/indent/elsecomment.0.stdout
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/indent/fmt_block.c \
    src/tests/usr.bin/indent/fmt_decl.c \
    src/tests/usr.bin/indent/fmt_else_comment.c \
    src/tests/usr.bin/indent/lex_ident.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt_v.c \
    src/tests/usr.bin/indent/t_misc.sh

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.1148 src/distrib/sets/lists/tests/mi:1.1149
--- src/distrib/sets/lists/tests/mi:1.1148	Tue Oct 19 20:20:24 2021
+++ src/distrib/sets/lists/tests/mi	Fri Oct 22 19:27:53 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1148 2021/10/19 20:20:24 rillig Exp $
+# $NetBSD: mi,v 1.1149 2021/10/22 19:27:53 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4732,8 +4732,8 @@
 ./usr/tests/usr.bin/indent/Kyuafile					tests-usr.bin-tests	compattestfile,atf,kyua
 ./usr/tests/usr.bin/indent/binary.0					tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/binary.0.stdout				tests-obsolete		obsolete,atf
-./usr/tests/usr.bin/indent/block.0					tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/block.0.stdout				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/block.0					tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/block.0.stdout				tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/comment-line-end.0				tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/comment-line-end.0.stdout			tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/comments.0					tests-obsolete		obsolete,atf
@@ -4742,36 +4742,41 @@
 ./usr/tests/usr.bin/indent/cs.0						tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/cs.0.pro					tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/cs.0.stdout					tests-obsolete		obsolete,atf
-./usr/tests/usr.bin/indent/declarations.0				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/declarations.0.stderr			tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/declarations.0.stdout			tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/elsecomment.0				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/elsecomment.0.pro				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/elsecomment.0.stdout				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/declarations.0				tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/declarations.0.stderr			tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/declarations.0.stdout			tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/elsecomment.0				tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/elsecomment.0.pro				tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/elsecomment.0.stdout				tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/f_decls.0					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/f_decls.0.stdout				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/float.0					tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/float.0.stdout				tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/fmt_block.c					tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/fmt_decl.c					tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/fmt_else_comment.c				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/indent_off_on.c				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/indent_variables.0				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/indent_variables.0.pro			tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/indent_variables.0.stdout			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/indent_variables.0				tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/indent_variables.0.pro			tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/indent_variables.0.stdout			tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/label.0					tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/label.0.pro					tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/label.0.stdout				tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/label.c					tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/lex.0					tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/lex.0.pro					tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/lex.0.stdout					tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/lex.0					tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/lex.0.pro					tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/lex.0.stdout					tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/lex.c					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/lex_char.0					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/lex_char.0.pro				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/lex_char.0.stdout				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/lex_ident.c					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/lex_string.0					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/lex_string.0.pro				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/lex_string.0.stdout				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/lineno.0					tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/lineno.0.pro					tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/lineno.0.stdout				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/lineno.0					tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/lineno.0.pro					tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/lineno.0.stdout				tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/list_head.0					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/list_head.0.stdout				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/ncs.0					tests-obsolete		obsolete,atf

Index: src/tests/usr.bin/indent/Makefile
diff -u src/tests/usr.bin/indent/Makefile:1.24 src/tests/usr.bin/indent/Makefile:1.25
--- src/tests/usr.bin/indent/Makefile:1.24	Tue Oct 19 20:20:24 2021
+++ src/tests/usr.bin/indent/Makefile	Fri Oct 22 19:27:53 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.24 2021/10/19 20:20:24 rillig Exp $
+#	$NetBSD: Makefile,v 1.25 2021/10/22 19:27:53 rillig Exp $
 
 .include <bsd.own.mk>
 
@@ -9,33 +9,20 @@ TESTS_SH+=	t_misc
 TESTS_SH+=	t_options
 
 FILESDIR=	${TESTSDIR}
-FILES=		block.0
-FILES+=		block.0.stdout
-FILES+=		declarations.0
-FILES+=		declarations.0.stderr
-FILES+=		declarations.0.stdout
-FILES+=		elsecomment.0
-FILES+=		elsecomment.0.stdout
-FILES+=		elsecomment.0.pro
+FILES=		fmt_block.c
+FILES+=		fmt_decl.c
+FILES+=		fmt_else_comment.c
 FILES+=		f_decls.0
 FILES+=		f_decls.0.stdout
 FILES+=		indent_off_on.c
-FILES+=		indent_variables.0
-FILES+=		indent_variables.0.pro
-FILES+=		indent_variables.0.stdout
 FILES+=		label.c
-FILES+=		lex.0
-FILES+=		lex.0.pro
-FILES+=		lex.0.stdout
+FILES+=		lex_ident.c
 FILES+=		lex_char.0
 FILES+=		lex_char.0.pro
 FILES+=		lex_char.0.stdout
 FILES+=		lex_string.0
 FILES+=		lex_string.0.pro
 FILES+=		lex_string.0.stdout
-FILES+=		lineno.0
-FILES+=		lineno.0.pro
-FILES+=		lineno.0.stdout
 FILES+=		list_head.0
 FILES+=		list_head.0.stdout
 FILES+=		offsetof.0

Index: src/tests/usr.bin/indent/opt_v.c
diff -u src/tests/usr.bin/indent/opt_v.c:1.2 src/tests/usr.bin/indent/opt_v.c:1.3
--- src/tests/usr.bin/indent/opt_v.c:1.2	Sat Oct 16 21:32:10 2021
+++ src/tests/usr.bin/indent/opt_v.c	Fri Oct 22 19:27:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_v.c,v 1.2 2021/10/16 21:32:10 rillig Exp $ */
+/* $NetBSD: opt_v.c,v 1.3 2021/10/22 19:27:53 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -65,3 +65,28 @@ example(void)
 	int		sum2 = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21);
 }
 #indent end
+
+
+#indent input
+/* Demonstrates line number counting in verbose mode. */
+
+int *function(void)
+{}
+#indent end
+
+#indent run -v
+/* Demonstrates line number counting in verbose mode. */
+
+int *
+function(void)
+{
+}
+There were 5 output lines and 1 comments
+(Lines with comments)/(Lines with code):  0.250
+#indent end
+/* In the above output, the '5' means 5 non-empty lines. */
+
+/*
+ * XXX: It's rather strange that -v writes to stdout, even in filter mode.
+ * This output belongs on stderr instead.
+ */
Index: src/tests/usr.bin/indent/t_misc.sh
diff -u src/tests/usr.bin/indent/t_misc.sh:1.2 src/tests/usr.bin/indent/t_misc.sh:1.3
--- src/tests/usr.bin/indent/t_misc.sh:1.2	Thu Oct 14 18:55:41 2021
+++ src/tests/usr.bin/indent/t_misc.sh	Fri Oct 22 19:27:53 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_misc.sh,v 1.2 2021/10/14 18:55:41 rillig Exp $
+# $NetBSD: t_misc.sh,v 1.3 2021/10/22 19:27:53 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -91,8 +91,90 @@ verbose_profile_body()
 	     cat after.c
 }
 
+atf_test_case 'nested_struct_declarations'
+nested_struct_declarations_body()
+{
+	# Trigger the warning about nested struct declarations.
+
+	cat <<-\EOF > code.c
+		struct s01 { struct s02 { struct s03 { struct s04 {
+		struct s05 { struct s06 { struct s07 { struct s08 {
+		struct s09 { struct s10 { struct s11 { struct s12 {
+		struct s13 { struct s14 { struct s15 { struct s16 {
+		struct s17 { struct s18 { struct s19 { struct s20 {
+		struct s21 { struct s22 { struct s23 { struct s24 {
+		};};};};
+		};};};};
+		};};};};
+		};};};};
+		};};};};
+		};};};};
+	EOF
+	cat <<-\EOF > expected.out
+		struct s01 {
+		 struct s02 {
+		  struct s03 {
+		   struct s04 {
+		    struct s05 {
+		     struct s06 {
+		      struct s07 {
+		       struct s08 {
+		        struct s09 {
+		         struct s10 {
+		          struct s11 {
+		           struct s12 {
+		            struct s13 {
+		             struct s14 {
+		              struct s15 {
+		               struct s16 {
+		                struct s17 {
+		                 struct s18 {
+		                  struct s19 {
+		                   struct s20 {
+		                    struct s21 {
+		                     struct s22 {
+		                      struct s23 {
+		                       struct s24 {
+		                       };
+		                      };
+		                     };
+		                    };
+		                   };
+		                  };
+		                 };
+		                };
+		               };
+		              };
+		             };
+		            };
+		           };
+		          };
+		         };
+		        };
+		       };
+		      };
+		     };
+		    };
+		   };
+		  };
+		 };
+		};
+	EOF
+	cat <<-\EOF > expected.err
+		/**INDENT** Warning@5: Reached internal limit of 20 struct levels */
+		/**INDENT** Warning@6: Reached internal limit of 20 struct levels */
+		/**INDENT** Warning@6: Reached internal limit of 20 struct levels */
+		/**INDENT** Warning@6: Reached internal limit of 20 struct levels */
+		/**INDENT** Warning@6: Reached internal limit of 20 struct levels */
+	EOF
+
+	atf_check -o 'file:expected.out' -e 'file:expected.err' \
+	    "$indent" -i1 -nut < 'code.c'
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case 'in_place'
 	atf_add_test_case 'verbose_profile'
+	atf_add_test_case 'nested_struct_declarations'
 }

Added files:

Index: src/tests/usr.bin/indent/fmt_block.c
diff -u /dev/null src/tests/usr.bin/indent/fmt_block.c:1.1
--- /dev/null	Fri Oct 22 19:27:53 2021
+++ src/tests/usr.bin/indent/fmt_block.c	Fri Oct 22 19:27:53 2021
@@ -0,0 +1,31 @@
+/* $NetBSD: fmt_block.c,v 1.1 2021/10/22 19:27:53 rillig Exp $ */
+/* $FreeBSD$ */
+
+#indent input
+void
+function(void)
+{
+	if (true) {
+
+	}
+
+	{
+		print("block");
+	}
+}
+#indent end
+
+#indent run
+void
+function(void)
+{
+	if (true) {
+
+/* $ FIXME: indent must not merge these braces. */
+	} {
+/* $ FIXME: the following empty line was not in the input. */
+
+		print("block");
+	}
+}
+#indent end
Index: src/tests/usr.bin/indent/fmt_decl.c
diff -u /dev/null src/tests/usr.bin/indent/fmt_decl.c:1.1
--- /dev/null	Fri Oct 22 19:27:53 2021
+++ src/tests/usr.bin/indent/fmt_decl.c	Fri Oct 22 19:27:53 2021
@@ -0,0 +1,262 @@
+/*	$NetBSD: fmt_decl.c,v 1.1 2021/10/22 19:27:53 rillig Exp $	*/
+/* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
+
+/* See FreeBSD r303570 */
+
+#indent input
+typedef void	(*voidptr) (int *);
+#indent end
+
+#indent run
+typedef void (*voidptr)(int *);
+#indent end
+
+
+#indent input
+static const struct
+{
+	double		x;
+	double		y, z;
+} n[m + 1] =
+{
+	{
+		.0,
+		.9,
+		5
+	}
+};
+#indent end
+
+#indent run
+static const struct {
+	double		x;
+	double		y, z;
+}		n[m + 1] =
+{
+	{
+		.0,
+		.9,
+		5
+	}
+};
+#indent end
+
+
+#indent input
+typedef struct Complex
+{
+	double		x;
+	double		y;
+}	Complex;
+#indent end
+
+#indent run
+typedef struct Complex {
+	double		x;
+	double		y;
+}		Complex;
+#indent end
+
+
+#indent input
+void
+t1 (char *a, int b,
+	void (*fn)(void))
+{}
+#indent end
+
+#indent run
+void
+t1(char *a, int b,
+   void (*fn)(void))
+{
+}
+#indent end
+
+
+#indent input
+void t2 (char *x, int y)
+{
+	int a,
+	b,
+	c;
+	int
+	*d,
+	*e,
+	*f;
+	int (*g)(),
+	(*h)(),
+	(*i)();
+	int j,
+	k,
+	l;
+	int m
+	,n
+	,o
+	;
+	int		chars[ /* push the comma beyond column 74 .... */ ], x;
+}
+#indent end
+
+#indent run
+void
+t2(char *x, int y)
+{
+	int		a, b, c;
+	int
+		       *d, *e, *f;
+	int		(*g)(), (*h)(), (*i)();
+	int		j, k, l;
+	int		m
+		       ,n
+		       ,o
+		       ;
+	int		chars[ /* push the comma beyond column 74 .... */ ],
+			x;
+}
+#indent end
+
+
+#indent input
+const int	int_minimum_size =
+MAXALIGN(offsetof(int, test)) + MAXIMUM_ALIGNOF;
+#indent end
+
+#indent run-equals-input
+
+
+#indent input
+int *int_create(void)
+{
+
+}
+#indent end
+
+#indent run
+int	       *
+int_create(void)
+{
+
+}
+#indent end
+
+
+#indent input
+static
+_attribute_printf(1, 2)
+void
+print_error(const char *fmt,...)
+{
+
+}
+#indent end
+
+#indent run
+static
+_attribute_printf(1, 2)
+void
+print_error(const char *fmt, ...)
+{
+
+}
+#indent end
+
+
+#indent input
+static LIST_HEAD(, alq) ald_active;
+static int ald_shutingdown = 0;
+struct thread *ald_thread;
+#indent end
+
+#indent run
+static LIST_HEAD(, alq) ald_active;
+static int	ald_shutingdown = 0;
+struct thread  *ald_thread;
+#indent end
+
+
+#indent input
+static int
+do_execve(td, args, mac_p)
+	struct thread *td;
+	struct image_args *args;
+	struct mac *mac_p;
+{
+
+}
+#indent end
+
+#indent run
+static int
+do_execve(td, args, mac_p)
+	struct thread  *td;
+	struct image_args *args;
+	struct mac     *mac_p;
+{
+
+}
+#indent end
+
+
+#indent input
+int
+my_printf(const char *fmt, ...)
+{
+}
+#indent end
+
+#indent run-equals-input
+
+
+/*
+ * Demonstrate how variable declarations are broken into several lines when
+ * the line length limit is set quite low.
+ */
+#indent input
+struct s0 a,b;
+struct s01 a,b;
+struct s012 a,b;
+struct s0123 a,b;
+struct s01234 a,b;
+struct s012345 a,b;
+struct s0123456 a,b;
+struct s01234567 a,b;
+struct s012345678 a,b;
+struct s0123456789 a,b;
+struct s01234567890 a,b;
+struct s012345678901 a,b;
+struct s0123456789012 a,b;
+struct s01234567890123 a,b;
+#indent end
+
+#indent run -l20 -di0
+/* $ XXX: Why is this declaration broken? There's plenty of space left. */
+struct s0 a,
+   b;
+struct s01 a,
+    b;
+struct s012 a,
+     b;
+struct s0123 a,
+      b;
+struct s01234 a,
+       b;
+struct s012345 a,
+        b;
+struct s0123456 a,
+         b;
+struct s01234567 a,
+          b;
+struct s012345678 a,
+           b;
+struct s0123456789 a,
+            b;
+struct s01234567890 a,
+             b;
+struct s012345678901 a,
+              b;
+struct s0123456789012 a,
+               b;
+struct s01234567890123 a,
+                b;
+#indent end
Index: src/tests/usr.bin/indent/fmt_else_comment.c
diff -u /dev/null src/tests/usr.bin/indent/fmt_else_comment.c:1.1
--- /dev/null	Fri Oct 22 19:27:53 2021
+++ src/tests/usr.bin/indent/fmt_else_comment.c	Fri Oct 22 19:27:53 2021
@@ -0,0 +1,97 @@
+/*	$NetBSD: fmt_else_comment.c,v 1.1 2021/10/22 19:27:53 rillig Exp $	*/
+/* $FreeBSD: head/usr.bin/indent/tests/elsecomment.0.pro 314613 2017-03-03 20:15:22Z ngie $ */
+
+/* See r303484 and r309342 */
+
+#indent input
+void t(void) {
+	/* The two if statements below excercise two different code paths. */
+
+	if (1) /* a */ int a; else /* b */ int b;
+
+	if (1) /* a */
+		int a;
+	else /* b */
+		int b;
+
+	if (1) {
+
+	}
+
+
+
+	/* Old indent would remove the 3 blank lines above, awaiting "else". */
+
+	if (1) {
+		int a;
+	}
+
+
+	else if (0) {
+		int b;
+	}
+	/* test */
+	else
+		;
+
+	if (1)
+		;
+	else /* Old indent would get very confused here */
+	/* We also mustn't assume that there's only one comment */
+	/* before the left brace. */
+	{
+
+
+	}
+}
+#indent end
+
+#indent run -bl
+void
+t(void)
+{
+	/* The two if statements below excercise two different code paths. */
+
+	if (1)			/* a */
+		int		a;
+	else			/* b */
+		int		b;
+
+	if (1)			/* a */
+		int		a;
+	else			/* b */
+		int		b;
+
+	if (1)
+	{
+
+	}
+
+
+
+	/*
+	 * Old indent would remove the 3 blank lines above, awaiting "else".
+	 */
+
+	if (1)
+	{
+		int		a;
+	} else if (0)
+	{
+		int		b;
+	}
+	/* test */
+	else
+		;
+
+	if (1)
+		;
+	else			/* Old indent would get very confused here */
+		/* We also mustn't assume that there's only one comment */
+		/* before the left brace. */
+	{
+
+
+	}
+}
+#indent end
Index: src/tests/usr.bin/indent/lex_ident.c
diff -u /dev/null src/tests/usr.bin/indent/lex_ident.c:1.1
--- /dev/null	Fri Oct 22 19:27:53 2021
+++ src/tests/usr.bin/indent/lex_ident.c	Fri Oct 22 19:27:53 2021
@@ -0,0 +1,66 @@
+/* $NetBSD: lex_ident.c,v 1.1 2021/10/22 19:27:53 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * Test lexing of tokens, such as keywords, identifiers, operators.
+ */
+
+/*
+ * Conceptually, backslash-newline is replaced with nothing, in a very early
+ * stage of the translation, see C11 5.1.1.2p1, item 2. Indent does not
+ * preserve these; in most cases, they are simply removed.
+ */
+#indent input
+in\
+t \
+var\
+iable;
+
+int
+	no_backslash;
+
+/* $ See check_size_token. */
+/* $ The default buffer size is 200, the limit is 195. */
+struct long_tag_name_to_overflow_the_token_buffer_4567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890;
+
+/* $ See check_size_token. */
+/* $ The difference between limit and start got incremented to 595. */
+struct long_tag_name_to_overflow_the_token_buffer_4567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890;
+#indent end
+
+#indent run
+/* $ XXX: The indentation of the backslash is one short of a tab. */
+int	       \
+		variable;
+
+int
+		no_backslash;
+
+struct long_tag_name_to_overflow_the_token_buffer_4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890;
+
+struct long_tag_name_to_overflow_the_token_buffer_45678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890;
+#indent end
+
+
+/* This is a syntax error; see lex_word. */
+#indent input
+int identifier\n;
+#indent end
+
+#indent run
+int		identifier \n;
+#indent end

Reply via email to