CVS commit: src/tests/usr.bin/indent

2021-03-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar  6 15:02:38 UTC 2021

Modified Files:
src/tests/usr.bin/indent: comment-line-end.0 comment-line-end.0.stdout

Log Message:
tests/indent: extend test for '//' comments with more examples


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/comment-line-end.0 \
src/tests/usr.bin/indent/comment-line-end.0.stdout

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/comment-line-end.0
diff -u src/tests/usr.bin/indent/comment-line-end.0:1.1 src/tests/usr.bin/indent/comment-line-end.0:1.2
--- src/tests/usr.bin/indent/comment-line-end.0:1.1	Sun Feb 21 21:26:26 2021
+++ src/tests/usr.bin/indent/comment-line-end.0	Sat Mar  6 15:02:38 2021
@@ -1,9 +1,24 @@
-/* $NetBSD: comment-line-end.0,v 1.1 2021/02/21 21:26:26 rillig Exp $ */
+/* $NetBSD: comment-line-end.0,v 1.2 2021/03/06 15:02:38 rillig Exp $ */
 /* This $FreeBSD$ tag is required by the test suite, for no reason. */
 
 /*
- * Demonstrates that line-end comments can affect the following lines.
+ * Demonstrates handling of line-end comments.
  *
+ * Even though this type of comments was added in C99, indent doesn't support
+ * them, as of 2021, and instead messes up the code in unpredictable ways.
+ */
+
+int dummy // comment
+= // eq
+1 // one
++ // plus
+2; // two
+
+/separator/
+
+void function(void){}
+
+/*
  * FIXME: The '{' of main must be in column 1, not directly after the ')'.
  *
  * FIXME: The 'Note: removing' below gets "indented" to 'Note:removing'.
Index: src/tests/usr.bin/indent/comment-line-end.0.stdout
diff -u src/tests/usr.bin/indent/comment-line-end.0.stdout:1.1 src/tests/usr.bin/indent/comment-line-end.0.stdout:1.2
--- src/tests/usr.bin/indent/comment-line-end.0.stdout:1.1	Sun Feb 21 21:26:26 2021
+++ src/tests/usr.bin/indent/comment-line-end.0.stdout	Sat Mar  6 15:02:38 2021
@@ -1,9 +1,28 @@
-/* $NetBSD: comment-line-end.0.stdout,v 1.1 2021/02/21 21:26:26 rillig Exp $ */
+/* $NetBSD: comment-line-end.0.stdout,v 1.2 2021/03/06 15:02:38 rillig Exp $ */
 /* This $FreeBSD$ tag is required by the test suite, for no reason. */
 
 /*
- * Demonstrates that line-end comments can affect the following lines.
+ * Demonstrates handling of line-end comments.
  *
+ * Even though this type of comments was added in C99, indent doesn't support
+ * them, as of 2021, and instead messes up the code in unpredictable ways.
+ */
+
+int		dummy //comment
+= //eq
+1 // one
++ //plus
+2;
+//two
+
+/ separator /
+
+void
+function(void)
+{
+}
+
+/*
  * FIXME: The '{' of main must be in column 1, not directly after the ')'.
  *
  * FIXME: The 'Note: removing' below gets "indented" to 'Note:removing'.
@@ -11,7 +30,7 @@
  * FIXME: The 'line-end' gets "indented" to 'line - end'.
  */
 
-// Note:removing one of these line - end comments affects the formatting
+//Note:removing one of these line - end comments affects the formatting
 // of the main function below.
 
 int



CVS commit: src/tests/usr.bin/indent

2021-03-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar  6 19:30:44 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt--version.0 opt-bacc.0 opt-bacc.0.stdout
opt-bad.0 opt-bad.0.stdout opt-badp.0 opt-badp.0.stdout opt-bap.0
opt-bap.0.stdout opt-bbb.0 opt-bbb.0.stdout opt-bc.0
opt-bc.0.stdout opt-bl.0 opt-bl.0.stdout opt-br.0 opt-br.0.stdout
opt-bs.0 opt-bs.0.stdout opt-c.0 opt-c.0.stdout

Log Message:
tests/indent: add 11 test cases, demonstrate 8 bugs


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/opt--version.0 \
src/tests/usr.bin/indent/opt-bacc.0 \
src/tests/usr.bin/indent/opt-bacc.0.stdout \
src/tests/usr.bin/indent/opt-bad.0 \
src/tests/usr.bin/indent/opt-bad.0.stdout \
src/tests/usr.bin/indent/opt-badp.0 \
src/tests/usr.bin/indent/opt-badp.0.stdout \
src/tests/usr.bin/indent/opt-bap.0 \
src/tests/usr.bin/indent/opt-bap.0.stdout \
src/tests/usr.bin/indent/opt-bbb.0 \
src/tests/usr.bin/indent/opt-bbb.0.stdout \
src/tests/usr.bin/indent/opt-bc.0 \
src/tests/usr.bin/indent/opt-bc.0.stdout \
src/tests/usr.bin/indent/opt-bl.0 \
src/tests/usr.bin/indent/opt-bl.0.stdout \
src/tests/usr.bin/indent/opt-br.0 \
src/tests/usr.bin/indent/opt-br.0.stdout \
src/tests/usr.bin/indent/opt-bs.0 \
src/tests/usr.bin/indent/opt-bs.0.stdout src/tests/usr.bin/indent/opt-c.0 \
src/tests/usr.bin/indent/opt-c.0.stdout

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/opt--version.0
diff -u src/tests/usr.bin/indent/opt--version.0:1.1 src/tests/usr.bin/indent/opt--version.0:1.2
--- src/tests/usr.bin/indent/opt--version.0:1.1	Sat Mar  6 17:56:33 2021
+++ src/tests/usr.bin/indent/opt--version.0	Sat Mar  6 19:30:44 2021
@@ -1,4 +1,6 @@
-/* $NetBSD: opt--version.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt--version.0,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+When the option '--version' is given, any other options are ignored.
+Therefore the source file, if given, can contain arbitrary text that
+even might generate syntax errors when given to a C compiler.
Index: src/tests/usr.bin/indent/opt-bacc.0
diff -u src/tests/usr.bin/indent/opt-bacc.0:1.1 src/tests/usr.bin/indent/opt-bacc.0:1.2
--- src/tests/usr.bin/indent/opt-bacc.0:1.1	Sat Mar  6 17:56:33 2021
+++ src/tests/usr.bin/indent/opt-bacc.0	Sat Mar  6 19:30:44 2021
@@ -1,4 +1,19 @@
-/* $NetBSD: opt-bacc.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-bacc.0,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+int		a;
+#if 0/* FIXME: need blank line above */
+int		b;
+#endif/* FIXME: need blank line below */
+int		c;
+
+
+int		space_a;
+
+#if 0/* FIXME: need blank line above */
+
+int		space_b;	/* FIXME: need no blank line above */
+
+#endif
+
+int		space_c;
Index: src/tests/usr.bin/indent/opt-bacc.0.stdout
diff -u src/tests/usr.bin/indent/opt-bacc.0.stdout:1.1 src/tests/usr.bin/indent/opt-bacc.0.stdout:1.2
--- src/tests/usr.bin/indent/opt-bacc.0.stdout:1.1	Sat Mar  6 17:56:33 2021
+++ src/tests/usr.bin/indent/opt-bacc.0.stdout	Sat Mar  6 19:30:44 2021
@@ -1,4 +1,17 @@
-/* $NetBSD: opt-bacc.0.stdout,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-bacc.0.stdout,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+int		a;
+#if 0/* FIXME: need blank line above */
+int		b;
+#endif/* FIXME: need blank line below */
+int		c;
+
+
+int		space_a;
+#if 0/* FIXME: need blank line above */
+
+int		space_b;	/* FIXME: need no blank line above */
+#endif
+
+int		space_c;
Index: src/tests/usr.bin/indent/opt-bad.0
diff -u src/tests/usr.bin/indent/opt-bad.0:1.1 src/tests/usr.bin/indent/opt-bad.0:1.2
--- src/tests/usr.bin/indent/opt-bad.0:1.1	Sat Mar  6 17:56:33 2021
+++ src/tests/usr.bin/indent/opt-bad.0	Sat Mar  6 19:30:44 2021
@@ -1,4 +1,18 @@
-/* $NetBSD: opt-bad.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-bad.0,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/*
+ * The option -bad only affects declarations of local variables.  It does not
+ * affect file-scoped declarations or definitions.
+ */
+
+int global_variable;
+void function_declaration(void);
+#if 0
+#endif
+void function_definition(void) {
+	int local_variable;
+	function_call();
+	int local_variable_after_statement;
+	function_call();
+}
Index: src/tests/usr.bin/indent/opt-bad.0.stdout
diff -u src/tests/usr.bin/indent/opt-bad.0.stdout:1.1 src/tests/usr.bin/indent/opt-bad.0.stdout:1.2
--- src/tests/usr.bin/indent/opt-bad.0.stdout:1.1	Sat Mar  6 17:56:33 2021
+++ src/tests/usr.bin/indent/opt-bad.0.stdout	Sat Mar  6 19:30:44 2021
@@ -1,4 +1,22 @@
-/* $NetBSD: opt-bad.0.stdout,v 1.1 2021/

CVS commit: src/tests/usr.bin/indent

2021-03-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar  6 19:51:25 UTC 2021

Modified Files:
src/tests/usr.bin/indent: declarations.0 opt-c.0 parens.0

Log Message:
tests/indent: fix unintended trailing whitespace and space-tab


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/declarations.0 \
src/tests/usr.bin/indent/parens.0
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt-c.0

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/declarations.0
diff -u src/tests/usr.bin/indent/declarations.0:1.1 src/tests/usr.bin/indent/declarations.0:1.2
--- src/tests/usr.bin/indent/declarations.0:1.1	Thu Apr  4 15:27:35 2019
+++ src/tests/usr.bin/indent/declarations.0	Sat Mar  6 19:51:24 2021
@@ -1,8 +1,8 @@
-/*	$NetBSD: declarations.0,v 1.1 2019/04/04 15:27:35 kamil Exp $	*/
+/*	$NetBSD: declarations.0,v 1.2 2021/03/06 19:51:24 rillig Exp $	*/
 /* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
 /* See r303570 */
 
-typedef void 	(*voidptr) (int *);
+typedef void	(*voidptr) (int *);
 
 static const struct
 {
@@ -23,7 +23,7 @@ typedef struct Complex
 	double		y;
 }	Complex;
 
-void 
+void
 t1 (char *a, int b,
 	void (*fn)(void))
 {}
Index: src/tests/usr.bin/indent/parens.0
diff -u src/tests/usr.bin/indent/parens.0:1.1 src/tests/usr.bin/indent/parens.0:1.2
--- src/tests/usr.bin/indent/parens.0:1.1	Thu Apr  4 15:27:35 2019
+++ src/tests/usr.bin/indent/parens.0	Sat Mar  6 19:51:24 2021
@@ -1,9 +1,9 @@
-/*	$NetBSD: parens.0,v 1.1 2019/04/04 15:27:35 kamil Exp $	*/
+/*	$NetBSD: parens.0,v 1.2 2021/03/06 19:51:24 rillig Exp $	*/
 /* $FreeBSD: head/usr.bin/indent/tests/parens.0 334583 2018-06-03 19:05:20Z pstef $ */
-typedef void 	(*xxx) (int,
+typedef void	(*xxx) (int,
 char);
 
-typedef char 	(*) (int *,
+typedef char	(*) (int *,
 		 unsigned *,
 		 char,
 		 float *);

Index: src/tests/usr.bin/indent/opt-c.0
diff -u src/tests/usr.bin/indent/opt-c.0:1.2 src/tests/usr.bin/indent/opt-c.0:1.3
--- src/tests/usr.bin/indent/opt-c.0:1.2	Sat Mar  6 19:30:44 2021
+++ src/tests/usr.bin/indent/opt-c.0	Sat Mar  6 19:51:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt-c.0,v 1.2 2021/03/06 19:30:44 rillig Exp $ */
+/* $NetBSD: opt-c.0,v 1.3 2021/03/06 19:51:24 rillig Exp $ */
 /* $FreeBSD$ */
 
 bool
@@ -8,5 +8,5 @@ is_prime(int n)
 		return n >= 2; /* special case */
 	if (n % 2 == 0)
 		return false;/* even numbers */
-	return true;
+	return true;
 }



CVS commit: src/tests/usr.bin/indent

2021-03-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar  6 21:27:39 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt-cd.0 opt-cd.0.stdout opt-cdb.0
opt-cdb.0.stdout opt-ce.0 opt-ce.0.stdout opt-ci.0 opt-ci.0.stdout
opt-cli.0 opt-cli.0.stdout opt-cs.0 opt-cs.0.stdout opt-d.0
opt-d.0.stdout opt-di.0 opt-di.0.stdout opt-dj.0 opt-dj.0.stdout
opt-eei.0 opt-eei.0.stdout opt-ei.0 opt-ei.0.stdout opt-fbs.0
opt-fbs.0.stdout opt-fc1.0 opt-fc1.0.stdout opt-nce.0
opt-nce.0.stdout opt-nei.0 opt-nei.0.stdout opt-nfbs.0
opt-nfbs.0.stdout opt-nfc1.0 opt-nfc1.0.stdout

Log Message:
tests/indent: add 17 more tests, found only a single new bug

Discovering one bug in 17 command line options is acceptable.  This
compensates the bad first impression I got in the previous batch of
tests, which consisted of 11 tests and found 8 bugs.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/opt-cd.0 \
src/tests/usr.bin/indent/opt-cd.0.stdout \
src/tests/usr.bin/indent/opt-cdb.0 \
src/tests/usr.bin/indent/opt-cdb.0.stdout \
src/tests/usr.bin/indent/opt-ce.0 \
src/tests/usr.bin/indent/opt-ce.0.stdout \
src/tests/usr.bin/indent/opt-ci.0 \
src/tests/usr.bin/indent/opt-ci.0.stdout \
src/tests/usr.bin/indent/opt-cli.0 \
src/tests/usr.bin/indent/opt-cli.0.stdout \
src/tests/usr.bin/indent/opt-cs.0 \
src/tests/usr.bin/indent/opt-cs.0.stdout src/tests/usr.bin/indent/opt-d.0 \
src/tests/usr.bin/indent/opt-d.0.stdout src/tests/usr.bin/indent/opt-di.0 \
src/tests/usr.bin/indent/opt-di.0.stdout \
src/tests/usr.bin/indent/opt-dj.0 \
src/tests/usr.bin/indent/opt-dj.0.stdout \
src/tests/usr.bin/indent/opt-eei.0 \
src/tests/usr.bin/indent/opt-eei.0.stdout \
src/tests/usr.bin/indent/opt-ei.0 \
src/tests/usr.bin/indent/opt-ei.0.stdout \
src/tests/usr.bin/indent/opt-fbs.0 \
src/tests/usr.bin/indent/opt-fbs.0.stdout \
src/tests/usr.bin/indent/opt-fc1.0 \
src/tests/usr.bin/indent/opt-fc1.0.stdout \
src/tests/usr.bin/indent/opt-nce.0 \
src/tests/usr.bin/indent/opt-nce.0.stdout \
src/tests/usr.bin/indent/opt-nei.0 \
src/tests/usr.bin/indent/opt-nei.0.stdout \
src/tests/usr.bin/indent/opt-nfbs.0 \
src/tests/usr.bin/indent/opt-nfbs.0.stdout \
src/tests/usr.bin/indent/opt-nfc1.0 \
src/tests/usr.bin/indent/opt-nfc1.0.stdout

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/opt-cd.0
diff -u src/tests/usr.bin/indent/opt-cd.0:1.1 src/tests/usr.bin/indent/opt-cd.0:1.2
--- src/tests/usr.bin/indent/opt-cd.0:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-cd.0	Sat Mar  6 21:27:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt-cd.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-cd.0,v 1.2 2021/03/06 21:27:39 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+int aflag; /* Apply to all files. */
Index: src/tests/usr.bin/indent/opt-cd.0.stdout
diff -u src/tests/usr.bin/indent/opt-cd.0.stdout:1.1 src/tests/usr.bin/indent/opt-cd.0.stdout:1.2
--- src/tests/usr.bin/indent/opt-cd.0.stdout:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-cd.0.stdout	Sat Mar  6 21:27:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt-cd.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-cd.0.stdout,v 1.2 2021/03/06 21:27:39 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+int		aflag;/* Apply to all files. */
Index: src/tests/usr.bin/indent/opt-cdb.0
diff -u src/tests/usr.bin/indent/opt-cdb.0:1.1 src/tests/usr.bin/indent/opt-cdb.0:1.2
--- src/tests/usr.bin/indent/opt-cdb.0:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-cdb.0	Sat Mar  6 21:27:39 2021
@@ -1,4 +1,45 @@
-/* $NetBSD: opt-cdb.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-cdb.0,v 1.2 2021/03/06 21:27:39 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/* A single-line comment. */
+
+/* A
+ * multi-line
+ * comment. */
+
+/*
+ * A
+ * multi-line
+ * comment.
+ */
+
+int		ga;		/* A single-line comment. */
+
+int		gb;		/* A
+ * multi-line
+ * comment. */
+
+int		gc;		/*
+ * A
+ * multi-line
+ * comment.
+ */
+
+void
+example(void)
+{
+	/* A single-line comment. */
+	int la;
+
+	/* A
+	 * multi-line
+	 * comment. */
+	int lb;
+
+	/*
+	 * A
+	 * multi-line
+	 * comment.
+	 */
+	int lc;
+}
Index: src/tests/usr.bin/indent/opt-cdb.0.stdout
diff -u src/tests/usr.bin/indent/opt-cdb.0.stdout:1.1 src/tests/usr.bin/indent/opt-cdb.0.stdout:1.2
--- src/tests/usr.bin/indent/opt-cdb.0.stdout:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-cdb.0.stdout	Sat Mar  6 21:27:39 2021
@@ -1,4 +1,35 @@
-/* $NetBSD: opt-cdb.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-cdb.0.stdout,v 1.2 2021/03/06 21:27:39 

CVS commit: src/tests/usr.bin/indent

2021-03-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar  6 22:10:40 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt-fcb.0 opt-fcb.0.stdout opt-i.0
opt-i.0.stdout opt-ip.0 opt-ip.0.stdout opt-l.0 opt-l.0.stdout
opt-lc.0 opt-lc.0.stdout opt-ldi.0 opt-ldi.0.stdout opt-lp.0
opt-lp.0.stdout opt-nfcb.0 opt-nfcb.0.stdout opt-nip.0
opt-nip.0.stdout opt-nlp.0 opt-nlp.0.stdout

Log Message:
tests/indent: add more tests, discover more bugs


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/opt-fcb.0 \
src/tests/usr.bin/indent/opt-fcb.0.stdout \
src/tests/usr.bin/indent/opt-i.0 src/tests/usr.bin/indent/opt-i.0.stdout \
src/tests/usr.bin/indent/opt-ip.0 \
src/tests/usr.bin/indent/opt-ip.0.stdout src/tests/usr.bin/indent/opt-l.0 \
src/tests/usr.bin/indent/opt-l.0.stdout src/tests/usr.bin/indent/opt-lc.0 \
src/tests/usr.bin/indent/opt-lc.0.stdout \
src/tests/usr.bin/indent/opt-ldi.0 \
src/tests/usr.bin/indent/opt-ldi.0.stdout \
src/tests/usr.bin/indent/opt-lp.0 \
src/tests/usr.bin/indent/opt-lp.0.stdout \
src/tests/usr.bin/indent/opt-nfcb.0 \
src/tests/usr.bin/indent/opt-nfcb.0.stdout \
src/tests/usr.bin/indent/opt-nip.0 \
src/tests/usr.bin/indent/opt-nip.0.stdout \
src/tests/usr.bin/indent/opt-nlp.0 \
src/tests/usr.bin/indent/opt-nlp.0.stdout

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/opt-fcb.0
diff -u src/tests/usr.bin/indent/opt-fcb.0:1.1 src/tests/usr.bin/indent/opt-fcb.0:1.2
--- src/tests/usr.bin/indent/opt-fcb.0:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-fcb.0	Sat Mar  6 22:10:40 2021
@@ -1,4 +1,32 @@
-/* $NetBSD: opt-fcb.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-fcb.0,v 1.2 2021/03/06 22:10:40 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/* FIXME: The options -fcb and -nfcb result in exactly the same output. */
+
+/* Not
+ *
+ * so carefully
+ * formatted
+ *  comment */
+
+/*-
+ * car mat men
+ *efu   for   ted   com   t
+ *   lly box   .
+ */
+
+void
+example(void)
+{
+	/* Not
+	 *
+	 * so carefully
+	 * formatted
+	 *  comment */
+
+	/*-
+	 * car mat men
+	 *efu   for   ted   com   t
+	 *   lly box   .
+	 */
+}
Index: src/tests/usr.bin/indent/opt-fcb.0.stdout
diff -u src/tests/usr.bin/indent/opt-fcb.0.stdout:1.1 src/tests/usr.bin/indent/opt-fcb.0.stdout:1.2
--- src/tests/usr.bin/indent/opt-fcb.0.stdout:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-fcb.0.stdout	Sat Mar  6 22:10:40 2021
@@ -1,4 +1,32 @@
-/* $NetBSD: opt-fcb.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-fcb.0.stdout,v 1.2 2021/03/06 22:10:40 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/* FIXME: The options -fcb and -nfcb result in exactly the same output. */
+
+/*
+ * Not
+ *
+ * so carefully formatted comment
+ */
+
+/*-
+ * car mat men
+ *efu   for   ted   com   t
+ *   lly box   .
+ */
+
+void
+example(void)
+{
+	/*
+	 * Not
+	 *
+	 * so carefully formatted comment
+	 */
+
+	/*-
+	 * car mat men
+	 *efu   for   ted   com   t
+	 *   lly box   .
+	 */
+}
Index: src/tests/usr.bin/indent/opt-i.0
diff -u src/tests/usr.bin/indent/opt-i.0:1.1 src/tests/usr.bin/indent/opt-i.0:1.2
--- src/tests/usr.bin/indent/opt-i.0:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-i.0	Sat Mar  6 22:10:40 2021
@@ -1,4 +1,8 @@
-/* $NetBSD: opt-i.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-i.0,v 1.2 2021/03/06 22:10:40 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void
+example(void)
+{
+   if (1 > 0) if (2 > 1) return yes; return no;
+}
Index: src/tests/usr.bin/indent/opt-i.0.stdout
diff -u src/tests/usr.bin/indent/opt-i.0.stdout:1.1 src/tests/usr.bin/indent/opt-i.0.stdout:1.2
--- src/tests/usr.bin/indent/opt-i.0.stdout:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-i.0.stdout	Sat Mar  6 22:10:40 2021
@@ -1,4 +1,11 @@
-/* $NetBSD: opt-i.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-i.0.stdout,v 1.2 2021/03/06 22:10:40 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void
+example(void)
+{
+   if (1 > 0)
+  if (2 > 1)
+	 return yes;
+   return no;
+}
Index: src/tests/usr.bin/indent/opt-ip.0
diff -u src/tests/usr.bin/indent/opt-ip.0:1.1 src/tests/usr.bin/indent/opt-ip.0:1.2
--- src/tests/usr.bin/indent/opt-ip.0:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-ip.0	Sat Mar  6 22:10:40 2021
@@ -1,4 +1,21 @@
-/* $NetBSD: opt-ip.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-ip.0,v 1.2 2021/03/06 22:10:40 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/* FIXME: 

CVS commit: src/tests/usr.bin/indent

2021-03-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar  6 23:09:17 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt-nbacc.0 opt-nbacc.0.stdout opt-nbad.0
opt-nbad.0.stdout opt-nbadp.0 opt-nbadp.0.stdout opt-nbap.0
opt-nbap.0.stdout opt-nbbb.0 opt-nbbb.0.stdout opt-nbc.0
opt-nbc.0.stdout opt-nbs.0 opt-nbs.0.stdout opt-ncdb.0
opt-ncdb.0.stdout opt-ncs.0 opt-ncs.0.stdout opt-ndj.0
opt-ndj.0.stdout opt-neei.0 opt-neei.0.stdout

Log Message:
tests/indent: add tests for negative options

Since most of these options are of the form "don't do anything", the
input and output of these tests is very similar.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/opt-nbacc.0 \
src/tests/usr.bin/indent/opt-nbacc.0.stdout \
src/tests/usr.bin/indent/opt-nbad.0 \
src/tests/usr.bin/indent/opt-nbad.0.stdout \
src/tests/usr.bin/indent/opt-nbadp.0 \
src/tests/usr.bin/indent/opt-nbadp.0.stdout \
src/tests/usr.bin/indent/opt-nbap.0 \
src/tests/usr.bin/indent/opt-nbap.0.stdout \
src/tests/usr.bin/indent/opt-nbbb.0 \
src/tests/usr.bin/indent/opt-nbbb.0.stdout \
src/tests/usr.bin/indent/opt-nbc.0 \
src/tests/usr.bin/indent/opt-nbc.0.stdout \
src/tests/usr.bin/indent/opt-nbs.0 \
src/tests/usr.bin/indent/opt-nbs.0.stdout \
src/tests/usr.bin/indent/opt-ncdb.0 \
src/tests/usr.bin/indent/opt-ncdb.0.stdout \
src/tests/usr.bin/indent/opt-ncs.0 \
src/tests/usr.bin/indent/opt-ncs.0.stdout \
src/tests/usr.bin/indent/opt-ndj.0 \
src/tests/usr.bin/indent/opt-ndj.0.stdout \
src/tests/usr.bin/indent/opt-neei.0 \
src/tests/usr.bin/indent/opt-neei.0.stdout

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/opt-nbacc.0
diff -u src/tests/usr.bin/indent/opt-nbacc.0:1.1 src/tests/usr.bin/indent/opt-nbacc.0:1.2
--- src/tests/usr.bin/indent/opt-nbacc.0:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-nbacc.0	Sat Mar  6 23:09:17 2021
@@ -1,4 +1,19 @@
-/* $NetBSD: opt-nbacc.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-nbacc.0,v 1.2 2021/03/06 23:09:17 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+int		a;
+#if 0
+int		b;
+#endif
+int		c;
+
+
+int		space_a;
+
+#if 0
+
+int		space_b;
+
+#endif
+
+int		space_c;
Index: src/tests/usr.bin/indent/opt-nbacc.0.stdout
diff -u src/tests/usr.bin/indent/opt-nbacc.0.stdout:1.1 src/tests/usr.bin/indent/opt-nbacc.0.stdout:1.2
--- src/tests/usr.bin/indent/opt-nbacc.0.stdout:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-nbacc.0.stdout	Sat Mar  6 23:09:17 2021
@@ -1,4 +1,19 @@
-/* $NetBSD: opt-nbacc.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-nbacc.0.stdout,v 1.2 2021/03/06 23:09:17 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+int		a;
+#if 0
+int		b;
+#endif
+int		c;
+
+
+int		space_a;
+
+#if 0
+
+int		space_b;
+
+#endif
+
+int		space_c;
Index: src/tests/usr.bin/indent/opt-nbad.0
diff -u src/tests/usr.bin/indent/opt-nbad.0:1.1 src/tests/usr.bin/indent/opt-nbad.0:1.2
--- src/tests/usr.bin/indent/opt-nbad.0:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-nbad.0	Sat Mar  6 23:09:17 2021
@@ -1,4 +1,13 @@
-/* $NetBSD: opt-nbad.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-nbad.0,v 1.2 2021/03/06 23:09:17 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+int global_variable;
+void function_declaration(void);
+#if 0
+#endif
+void function_definition(void) {
+	int local_variable;
+	function_call();
+	int local_variable_after_statement;
+	function_call();
+}
Index: src/tests/usr.bin/indent/opt-nbad.0.stdout
diff -u src/tests/usr.bin/indent/opt-nbad.0.stdout:1.1 src/tests/usr.bin/indent/opt-nbad.0.stdout:1.2
--- src/tests/usr.bin/indent/opt-nbad.0.stdout:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-nbad.0.stdout	Sat Mar  6 23:09:17 2021
@@ -1,4 +1,15 @@
-/* $NetBSD: opt-nbad.0.stdout,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-nbad.0.stdout,v 1.2 2021/03/06 23:09:17 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+int		global_variable;
+void		function_declaration(void);
+#if 0
+#endif
+void
+function_definition(void)
+{
+	int		local_variable;
+	function_call();
+	int		local_variable_after_statement;
+	function_call();
+}
Index: src/tests/usr.bin/indent/opt-nbadp.0
diff -u src/tests/usr.bin/indent/opt-nbadp.0:1.1 src/tests/usr.bin/indent/opt-nbadp.0:1.2
--- src/tests/usr.bin/indent/opt-nbadp.0:1.1	Sat Mar  6 17:56:34 2021
+++ src/tests/usr.bin/indent/opt-nbadp.0	Sat Mar  6 23:09:17 2021
@@ -1,4 +1,33 @@
-/* $NetBSD: opt-nbadp.0,v 1.1 2021/03/06 17:56:34 rillig Exp $ */
+/* $NetBSD: opt-nbadp.0,v 1.2 2021/03/06 23:09:17 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+static void
+no_declarations(void

CVS commit: src/tests/usr.bin/indent

2021-03-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar  7 08:57:38 UTC 2021

Modified Files:
src/tests/usr.bin/indent: comment-line-end.0 comment-line-end.0.stdout
t_indent.sh

Log Message:
tests/indent: allow for comments in either the input or output files


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/comment-line-end.0 \
src/tests/usr.bin/indent/comment-line-end.0.stdout
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/t_indent.sh

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/comment-line-end.0
diff -u src/tests/usr.bin/indent/comment-line-end.0:1.2 src/tests/usr.bin/indent/comment-line-end.0:1.3
--- src/tests/usr.bin/indent/comment-line-end.0:1.2	Sat Mar  6 15:02:38 2021
+++ src/tests/usr.bin/indent/comment-line-end.0	Sun Mar  7 08:57:38 2021
@@ -1,5 +1,5 @@
-/* $NetBSD: comment-line-end.0,v 1.2 2021/03/06 15:02:38 rillig Exp $ */
-/* This $FreeBSD$ tag is required by the test suite, for no reason. */
+/* $NetBSD: comment-line-end.0,v 1.3 2021/03/07 08:57:38 rillig Exp $ */
+/* $FreeBSD$ */
 
 /*
  * Demonstrates handling of line-end comments.
@@ -18,14 +18,6 @@ int dummy // comment
 
 void function(void){}
 
-/*
- * FIXME: The '{' of main must be in column 1, not directly after the ')'.
- *
- * FIXME: The 'Note: removing' below gets "indented" to 'Note:removing'.
- *
- * FIXME: The 'line-end' gets "indented" to 'line - end'.
- */
-
 // Note: removing one of these line-end comments affects the formatting
 // of the main function below.
 
Index: src/tests/usr.bin/indent/comment-line-end.0.stdout
diff -u src/tests/usr.bin/indent/comment-line-end.0.stdout:1.2 src/tests/usr.bin/indent/comment-line-end.0.stdout:1.3
--- src/tests/usr.bin/indent/comment-line-end.0.stdout:1.2	Sat Mar  6 15:02:38 2021
+++ src/tests/usr.bin/indent/comment-line-end.0.stdout	Sun Mar  7 08:57:38 2021
@@ -1,5 +1,5 @@
-/* $NetBSD: comment-line-end.0.stdout,v 1.2 2021/03/06 15:02:38 rillig Exp $ */
-/* This $FreeBSD$ tag is required by the test suite, for no reason. */
+/* $NetBSD: comment-line-end.0.stdout,v 1.3 2021/03/07 08:57:38 rillig Exp $ */
+/* $FreeBSD$ */
 
 /*
  * Demonstrates handling of line-end comments.
@@ -22,17 +22,12 @@ function(void)
 {
 }
 
-/*
- * FIXME: The '{' of main must be in column 1, not directly after the ')'.
- *
- * FIXME: The 'Note: removing' below gets "indented" to 'Note:removing'.
- *
- * FIXME: The 'line-end' gets "indented" to 'line - end'.
- */
-
+/* $ FIXME: The space between 'Note: removing' must be preserved. */
+/* $ FIXME: The spacing around the '-' in 'line-end' must be preserved. */
 //Note:removing one of these line - end comments affects the formatting
 // of the main function below.
 
 int
+/* $ FIXME: The '{' must be in column 1, not directly after the ')'. */
 main(void){
 }

Index: src/tests/usr.bin/indent/t_indent.sh
diff -u src/tests/usr.bin/indent/t_indent.sh:1.1 src/tests/usr.bin/indent/t_indent.sh:1.2
--- src/tests/usr.bin/indent/t_indent.sh:1.1	Thu Apr  4 15:27:35 2019
+++ src/tests/usr.bin/indent/t_indent.sh	Sun Mar  7 08:57:38 2021
@@ -1,3 +1,5 @@
+#! /bin/sh
+# $NetBSD: t_indent.sh,v 1.2 2021/03/07 08:57:38 rillig Exp $
 #
 # Copyright 2016 Dell EMC
 # All rights reserved.
@@ -38,13 +40,15 @@ check()
 	# to pass.
 	atf_check cp ${SRCDIR}/${tc}* .
 
-	# Remove $FreeBSD: head/usr.bin/indent/tests/functional_test.sh 314613 2017-03-03 20:15:22Z ngie $ RCS expansions because they get re-indented, which
-	# changes the output
+	# Remove single-line comments that start with '$'.  This removes RCS
+	# IDs, preventing them to be broken into several lines.  It also
+	# allows for remarks that are only needed in either the input or the
+	# output.  These removals affect the line numbers in the diffs.
 	local out_file="${tc}.stdout"
 	if [ -f "${out_file}" ]; then
 		parsed_file=output_file.parsed
 
-		atf_check -o save:$parsed_file sed -e '/\$NetBSD.*\$/,/\$FreeBSD.*\$/d' \
+		atf_check -o save:$parsed_file sed -e '/^\/\*[[:space:]]$.*/d' \
 		${tc}.stdout
 		out_flag="-o file:$parsed_file"
 	fi
@@ -56,7 +60,7 @@ check()
 		# host, for determinism purposes.
 		profile_flag="-npro"
 	fi
-	sed -e '/\$NetBSD.*\$/,/\$FreeBSD.*\$/d'  ${tc} > input_file.parsed
+	sed -e '/^\/\*[[:space:]]$.*/d'  ${tc} > input_file.parsed
 
 	atf_check -s exit:${tc##*.} ${out_flag} ${indent} ${profile_flag} < input_file.parsed
 }



CVS commit: src/tests/usr.bin/indent

2021-03-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar  7 10:12:19 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt-P.0 opt-P.0.stdout opt-T.0 opt-T.0.stdout
opt-U.0 opt-U.0.stdout opt-lpl.0 opt-lpl.0.stdout opt-nlpl.0
opt-nlpl.0.stdout opt-npcs.0 opt-npcs.0.stdout opt-npro.0
opt-npro.0.stdout opt-npsl.0 opt-npsl.0.stdout opt-nsc.0
opt-nsc.0.stdout opt-nsob.0 opt-nsob.0.stdout opt-nut.0
opt-nut.0.stdout opt-nv.0 opt-nv.0.stdout opt-pcs.0
opt-pcs.0.stdout opt-psl.0 opt-psl.0.stdout opt-sc.0
opt-sc.0.stdout opt-sob.0 opt-sob.0.stdout opt-ta.0 opt-ta.0.stdout
opt-ts.0 opt-ts.0.stdout opt-ut.0 opt-ut.0.stdout opt-v.0
opt-v.0.stdout

Log Message:
tests/indent: add tests for the remaining command line options


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/opt-P.0 \
src/tests/usr.bin/indent/opt-P.0.stdout src/tests/usr.bin/indent/opt-T.0 \
src/tests/usr.bin/indent/opt-T.0.stdout src/tests/usr.bin/indent/opt-U.0 \
src/tests/usr.bin/indent/opt-U.0.stdout \
src/tests/usr.bin/indent/opt-lpl.0 \
src/tests/usr.bin/indent/opt-lpl.0.stdout \
src/tests/usr.bin/indent/opt-nlpl.0 \
src/tests/usr.bin/indent/opt-nlpl.0.stdout \
src/tests/usr.bin/indent/opt-npcs.0 \
src/tests/usr.bin/indent/opt-npcs.0.stdout \
src/tests/usr.bin/indent/opt-npro.0 \
src/tests/usr.bin/indent/opt-npro.0.stdout \
src/tests/usr.bin/indent/opt-npsl.0 \
src/tests/usr.bin/indent/opt-npsl.0.stdout \
src/tests/usr.bin/indent/opt-nsc.0 \
src/tests/usr.bin/indent/opt-nsc.0.stdout \
src/tests/usr.bin/indent/opt-nsob.0 \
src/tests/usr.bin/indent/opt-nsob.0.stdout \
src/tests/usr.bin/indent/opt-nut.0 \
src/tests/usr.bin/indent/opt-nut.0.stdout \
src/tests/usr.bin/indent/opt-nv.0 \
src/tests/usr.bin/indent/opt-nv.0.stdout \
src/tests/usr.bin/indent/opt-pcs.0 \
src/tests/usr.bin/indent/opt-pcs.0.stdout \
src/tests/usr.bin/indent/opt-psl.0 \
src/tests/usr.bin/indent/opt-psl.0.stdout \
src/tests/usr.bin/indent/opt-sc.0 \
src/tests/usr.bin/indent/opt-sc.0.stdout \
src/tests/usr.bin/indent/opt-sob.0 \
src/tests/usr.bin/indent/opt-sob.0.stdout \
src/tests/usr.bin/indent/opt-ta.0 \
src/tests/usr.bin/indent/opt-ta.0.stdout \
src/tests/usr.bin/indent/opt-ts.0 \
src/tests/usr.bin/indent/opt-ts.0.stdout \
src/tests/usr.bin/indent/opt-ut.0 \
src/tests/usr.bin/indent/opt-ut.0.stdout src/tests/usr.bin/indent/opt-v.0 \
src/tests/usr.bin/indent/opt-v.0.stdout

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/opt-P.0
diff -u src/tests/usr.bin/indent/opt-P.0:1.1 src/tests/usr.bin/indent/opt-P.0:1.2
--- src/tests/usr.bin/indent/opt-P.0:1.1	Sat Mar  6 17:56:33 2021
+++ src/tests/usr.bin/indent/opt-P.0	Sun Mar  7 10:12:18 2021
@@ -1,4 +1,8 @@
-/* $NetBSD: opt-P.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-P.0,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/*
+ * Mentioning another profile via -P has no effect since only a single
+ * profile can be specified on the command line, and there is no 'include'
+ * option.
+ */
Index: src/tests/usr.bin/indent/opt-P.0.stdout
diff -u src/tests/usr.bin/indent/opt-P.0.stdout:1.1 src/tests/usr.bin/indent/opt-P.0.stdout:1.2
--- src/tests/usr.bin/indent/opt-P.0.stdout:1.1	Sat Mar  6 17:56:33 2021
+++ src/tests/usr.bin/indent/opt-P.0.stdout	Sun Mar  7 10:12:18 2021
@@ -1,4 +1,8 @@
-/* $NetBSD: opt-P.0.stdout,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-P.0.stdout,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+/*
+ * Mentioning another profile via -P has no effect since only a single
+ * profile can be specified on the command line, and there is no 'include'
+ * option.
+ */
Index: src/tests/usr.bin/indent/opt-T.0
diff -u src/tests/usr.bin/indent/opt-T.0:1.1 src/tests/usr.bin/indent/opt-T.0:1.2
--- src/tests/usr.bin/indent/opt-T.0:1.1	Sat Mar  6 17:56:33 2021
+++ src/tests/usr.bin/indent/opt-T.0	Sun Mar  7 10:12:18 2021
@@ -1,4 +1,13 @@
-/* $NetBSD: opt-T.0,v 1.1 2021/03/06 17:56:33 rillig Exp $ */
+/* $NetBSD: opt-T.0,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* TODO: implement the test */
+void
+example(void *arg)
+{
+	int cast = (custom_type_name)   *   arg;
+
+	int mult = (unknown_type_name)   *   arg;
+
+	/* See the option -ta for handling these types. */
+	int suff = (unknown_type_name_t)   *   arg;
+}
Index: src/tests/usr.bin/indent/opt-T.0.stdout
diff -u src/tests/usr.bin/indent/opt-T.0.stdout:1.1 src/tests/usr.bin/indent/opt-T.0.stdout:1.2
--- src/tests/usr.bin/indent/opt-T.0.stdout:1.1	Sat Mar  6 17:56:33 2021
+++ src/tests/usr.bin/indent/opt-T.0.stdout	Sun Mar  7 10:12:18 

CVS commit: src/tests/usr.bin/indent

2021-03-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Mar  8 20:01:16 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_indent.sh

Log Message:
tests/indent: allow golden stderr file, improve filenames, clean up code

When indent runs in filter mode, it may output messages to stderr.
Allow tests with non-empty expected stderr.

In the ATF output, the filename 'output_file.parsed' was not helpful for
casual readers of diff output since they expect the filenames to be
meaningful.  Embed the name of the test case in that filename.

Fix quoting of the shell variables.

Remove the repetition of the regular expression to clean up the test
files.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/t_indent.sh

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/t_indent.sh
diff -u src/tests/usr.bin/indent/t_indent.sh:1.2 src/tests/usr.bin/indent/t_indent.sh:1.3
--- src/tests/usr.bin/indent/t_indent.sh:1.2	Sun Mar  7 08:57:38 2021
+++ src/tests/usr.bin/indent/t_indent.sh	Mon Mar  8 20:01:16 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_indent.sh,v 1.2 2021/03/07 08:57:38 rillig Exp $
+# $NetBSD: t_indent.sh,v 1.3 2021/03/08 20:01:16 rillig Exp $
 #
 # Copyright 2016 Dell EMC
 # All rights reserved.
@@ -44,25 +44,32 @@ check()
 	# IDs, preventing them to be broken into several lines.  It also
 	# allows for remarks that are only needed in either the input or the
 	# output.  These removals affect the line numbers in the diffs.
-	local out_file="${tc}.stdout"
-	if [ -f "${out_file}" ]; then
-		parsed_file=output_file.parsed
-
-		atf_check -o save:$parsed_file sed -e '/^\/\*[[:space:]]$.*/d' \
-		${tc}.stdout
-		out_flag="-o file:$parsed_file"
+	for fname in "$tc" "$tc.stdout" "$tc.stderr"; do
+		if [ -f "$fname" ]; then
+			atf_check -o "save:$fname.clean" \
+			sed -e '/^\/\*[[:space:]]$.*/d' "$fname"
+		fi
+	done
+
+	local out_arg='empty'
+	if [ -f "$tc.stdout.clean" ]; then
+		out_arg="file:$tc.stdout.clean"
 	fi
-	local profile_file="${tc}.pro"
-	if [ -f "${profile_file}" ]; then
-		profile_flag="-P${profile_file}"
-	else
-		# Make sure we don't implicitly use ~/.indent.pro from the test
-		# host, for determinism purposes.
-		profile_flag="-npro"
+
+	local err_arg='empty'
+	if [ -f "$tc.stderr.clean" ]; then
+		err_arg="file:$tc.stderr.clean"
+	fi
+
+	# Make sure we don't implicitly use ~/.indent.pro from the test
+	# host, for determinism purposes.
+	local pro_arg='-npro'
+	if [ -f "$tc.pro" ]; then
+		pro_arg="-P$tc.pro"
 	fi
-	sed -e '/^\/\*[[:space:]]$.*/d'  ${tc} > input_file.parsed
 
-	atf_check -s exit:${tc##*.} ${out_flag} ${indent} ${profile_flag} < input_file.parsed
+	atf_check -s "exit:${tc##*.}" -o "$out_arg" -e "$err_arg" \
+	"$indent" "$pro_arg" < "$tc.clean"
 }
 
 add_testcase()



CVS commit: src/tests/usr.bin/indent

2021-03-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 12 17:41:11 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-binary_op.0 token-binary_op.0.pro
token-binary_op.0.stdout

Log Message:
tests/indent: test tokenization of punctuation, mainly operators


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token-binary_op.0 \
src/tests/usr.bin/indent/token-binary_op.0.pro \
src/tests/usr.bin/indent/token-binary_op.0.stdout

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/token-binary_op.0
diff -u src/tests/usr.bin/indent/token-binary_op.0:1.1 src/tests/usr.bin/indent/token-binary_op.0:1.2
--- src/tests/usr.bin/indent/token-binary_op.0:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-binary_op.0	Fri Mar 12 17:41:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-binary_op.0,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-binary_op.0,v 1.2 2021/03/12 17:41:10 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -9,4 +9,102 @@
  * multiplication, or pointer dereference, or pointer type declaration.
  */
 
-/* TODO: Add some code to be formatted. */
+/* See C99 6.4.6 */
+void
+punctuators(void)
+{
+	int brackets = array[subscript];
+	int parentheses = function(argument);
+	int braces = { initializer };
+	int period = structure.member;
+	int arrow = structure->member;
+
+	++prefix_increment;
+	postfix_increment++;
+	--prefix_decrement;
+	postfix_decrement--;
+	int *address = &lvalue;
+	int bitwise_and = value & mask;
+	int product = factor * factor;
+	int dereferenced = *address;
+	int positive = +number;
+	int sum = number + number;
+	int negative = -number;
+	int difference = number - number;
+	bool negated = !condition;
+
+	int quotient = number / number;
+	int modulo = number % number;
+	int shifted_left = number << number;
+	int shifted_right = number >> number;
+	bool less_than = number < number;
+	bool greater_than = number > number;
+	bool less_equal = number <= number;
+	bool greater_equal = number >= number;
+	bool equal = number == number;
+	bool unequal = number != number;
+	int bitwise_exclusive_or = number ^ number;
+	int bitwise_or = number | number;
+	bool logical_and = condition && condition;
+	bool logical_or = condition || condition;
+
+	int conditional = condition ? number : number;
+
+	/* combined assignment operators */
+	number = (expression);
+	number *= number;
+	number /= number;
+	number %= number;
+	number += number;
+	number -= number;
+	number <<= number;
+	number >>= number;
+	number &= number;
+	number ^= number;
+	number |= number;
+
+	number = function(argument1, argument2);
+	number = function(argument), number;
+
+	/* digraphs */
+	number = array<:subscript:>;
+	number = (int)<% initializer %>;
+}
+
+void
+peculiarities(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-binary_op.0.pro
diff -u src/tests/usr.bin/indent/token-binary_op.0.pro:1.1 src/tests/usr.bin/indent/token-binary_op.0.pro:1.2
--- src/tests/usr.bin/indent/token-binary_op.0.pro:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-binary_op.0.pro	Fri Mar 12 17:41:10 2021
@@ -1,8 +1,4 @@
-/* $NetBSD: token-binary_op.0.pro,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-binary_op.0.pro,v 1.2 2021/03/12 17:41:10 rillig Exp $ */
 /* $FreeBSD$ */
 
-/*
- * TODO: Explain the command line options of the test.
- */
-
-/* TODO: Add some command line options */
+-ldi0		/* do not align local variables in declarations */
Index: src/tests/usr.bin/indent/token-binary_op.0.stdout
diff -u src/tests/usr.bin/indent/token-binary_op.0.stdout:1.1 src/tests/usr.bin/indent/token-binary_op.0.stdout:1.2
--- src/tests/usr.bin/indent/token-binary_op.0.stdout:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-binary_op.0.stdout	Fri Mar 12 17:41:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-binary_op.0.stdout,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-binary_op.0.stdout,v 1.2 2021/03/12 17:41:10 rillig Exp $ */
 /*

CVS commit: src/tests/usr.bin/indent

2021-03-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 12 18:28:08 UTC 2021

Modified Files:
src/tests/usr.bin/indent: comment-line-end.0 comment-line-end.0.stdout

Log Message:
tests/indent: demonstrate stray empty line at end-of-file


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/comment-line-end.0 \
src/tests/usr.bin/indent/comment-line-end.0.stdout

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/comment-line-end.0
diff -u src/tests/usr.bin/indent/comment-line-end.0:1.4 src/tests/usr.bin/indent/comment-line-end.0:1.5
--- src/tests/usr.bin/indent/comment-line-end.0:1.4	Sun Mar  7 22:11:01 2021
+++ src/tests/usr.bin/indent/comment-line-end.0	Fri Mar 12 18:28:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: comment-line-end.0,v 1.4 2021/03/07 22:11:01 rillig Exp $ */
+/* $NetBSD: comment-line-end.0,v 1.5 2021/03/12 18:28:07 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -26,3 +26,5 @@ int
 main(void)
 {
 }
+
+// end-of-line comment at the end of the file
Index: src/tests/usr.bin/indent/comment-line-end.0.stdout
diff -u src/tests/usr.bin/indent/comment-line-end.0.stdout:1.4 src/tests/usr.bin/indent/comment-line-end.0.stdout:1.5
--- src/tests/usr.bin/indent/comment-line-end.0.stdout:1.4	Sun Mar  7 22:11:01 2021
+++ src/tests/usr.bin/indent/comment-line-end.0.stdout	Fri Mar 12 18:28:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: comment-line-end.0.stdout,v 1.4 2021/03/07 22:11:01 rillig Exp $ */
+/* $NetBSD: comment-line-end.0.stdout,v 1.5 2021/03/12 18:28:07 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -29,3 +29,6 @@ int
 main(void)
 {
 }
+
+// end-of-line comment at the end of the file
+



CVS commit: src/tests/usr.bin/indent

2021-03-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 12 22:53:18 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-preprocessing.0
token-preprocessing.0.stdout

Log Message:
tests/indent: add test for preprocessor lines


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token-preprocessing.0 \
src/tests/usr.bin/indent/token-preprocessing.0.stdout

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/token-preprocessing.0
diff -u src/tests/usr.bin/indent/token-preprocessing.0:1.1 src/tests/usr.bin/indent/token-preprocessing.0:1.2
--- src/tests/usr.bin/indent/token-preprocessing.0:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0	Fri Mar 12 22:53:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0,v 1.2 2021/03/12 22:53:18 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -10,4 +10,19 @@
  * #line
  */
 
-/* TODO: Add some code to be formatted. */
+#include 
+#include "local-header.h"
+
+#if 0
+#else
+#endif
+
+#if 0 /* if comment */
+#else /* else comment */
+#endif /* endif comment */
+
+#if 0 /* outer if comment */
+#  if nested /* inner if comment */
+#  else /* inner else comment */
+#  endif /* inner endif comment */
+#endif /* outer endif comment */
Index: src/tests/usr.bin/indent/token-preprocessing.0.stdout
diff -u src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.1 src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.2
--- src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0.stdout	Fri Mar 12 22:53:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0.stdout,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0.stdout,v 1.2 2021/03/12 22:53:18 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -10,4 +10,20 @@
  * #line
  */
 
-/* TODO: Add some code to be formatted. */
+#include 
+#include "local-header.h"
+
+#if 0
+#else
+#endif
+
+#if 0/* if comment */
+#else/* else comment */
+#endif/* endif comment */
+
+#if 0/* outer if comment */
+/* $ XXX: The indentation is removed, which can get confusing */
+#if nested			/* inner if comment */
+#else/* inner else comment */
+#endif/* inner endif comment */
+#endif/* outer endif comment */



CVS commit: src/tests/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:04:13 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-preprocessing.0
token-preprocessing.0.stdout

Log Message:
tests/indent: add another test case for preprocessing directives

In process_preprocessing, the variable 'quote' is not used, which makes
the code suspicious of not handling the combination of string literals
and comments properly.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/token-preprocessing.0 \
src/tests/usr.bin/indent/token-preprocessing.0.stdout

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/token-preprocessing.0
diff -u src/tests/usr.bin/indent/token-preprocessing.0:1.2 src/tests/usr.bin/indent/token-preprocessing.0:1.3
--- src/tests/usr.bin/indent/token-preprocessing.0:1.2	Fri Mar 12 22:53:18 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0	Sat Mar 13 13:04:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0,v 1.2 2021/03/12 22:53:18 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0,v 1.3 2021/03/13 13:04:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -26,3 +26,11 @@
 #  else /* inner else comment */
 #  endif /* inner endif comment */
 #endif /* outer endif comment */
+
+#define multi_line_definition /* first line
+ * middle
+ * final line
+ */ actual_value
+
+#define comment_in_string_literal "/* no comment "
+int this_is_an_ordinary_line_again;
Index: src/tests/usr.bin/indent/token-preprocessing.0.stdout
diff -u src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.2 src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.3
--- src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.2	Fri Mar 12 22:53:18 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0.stdout	Sat Mar 13 13:04:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0.stdout,v 1.2 2021/03/12 22:53:18 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0.stdout,v 1.3 2021/03/13 13:04:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -27,3 +27,13 @@
 #else/* inner else comment */
 #endif/* inner endif comment */
 #endif/* outer endif comment */
+
+#define multi_line_definition /* first line
+ * middle
+ * final line
+ */ actual_value
+
+#define comment_in_string_literal "/* no comment "
+int this_is_an_ordinary_line_again;
+
+/* $ FIXME: The above empty line is wrong. */



CVS commit: src/tests/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 00:50:39 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-comment.0 token-comment.0.stdout

Log Message:
tests/indent: demonstrate off-by-one error in comment processing


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token-comment.0 \
src/tests/usr.bin/indent/token-comment.0.stdout

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/token-comment.0
diff -u src/tests/usr.bin/indent/token-comment.0:1.1 src/tests/usr.bin/indent/token-comment.0:1.2
--- src/tests/usr.bin/indent/token-comment.0:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-comment.0	Sun Mar 14 00:50:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-comment.0,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-comment.0,v 1.2 2021/03/14 00:50:39 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -8,3 +8,9 @@
  */
 
 /* TODO: Add some code to be formatted. */
+
+/* 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 */
Index: src/tests/usr.bin/indent/token-comment.0.stdout
diff -u src/tests/usr.bin/indent/token-comment.0.stdout:1.1 src/tests/usr.bin/indent/token-comment.0.stdout:1.2
--- src/tests/usr.bin/indent/token-comment.0.stdout:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-comment.0.stdout	Sun Mar 14 00:50:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-comment.0.stdout,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-comment.0.stdout,v 1.2 2021/03/14 00:50:39 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -8,3 +8,18 @@
  */
 
 /* TODO: Add some code to be formatted. */
+
+/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345 */
+/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456 */
+/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567 */
+/* $ XXX: The '12345678' should be kept on the main line since it adds up */
+/* $ XXX: to a line length of exactly 78, which according to the manual */
+/* $ XXX: page should be ok. */
+/*
+ * 456789 123456789 123456789 123456789 123456789 123456789 123456789
+ * 12345678
+ */
+/*
+ * 456789 123456789 123456789 123456789 123456789 123456789 123456789
+ * 123456789
+ */