Module Name: src
Committed By: rillig
Date: Tue Oct 5 17:09:45 UTC 2021
Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/indent: Makefile
Added Files:
src/tests/usr.bin/indent: ps_ind_level.0 ps_ind_level.0.pro
ps_ind_level.0.stdout
Log Message:
tests/indent: demonstrate off-by-one error in edge case
To generate a diff of this commit:
cvs rdiff -u -r1.1131 -r1.1132 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/indent/ps_ind_level.0 \
src/tests/usr.bin/indent/ps_ind_level.0.pro \
src/tests/usr.bin/indent/ps_ind_level.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/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1131 src/distrib/sets/lists/tests/mi:1.1132
--- src/distrib/sets/lists/tests/mi:1.1131 Thu Sep 30 02:00:19 2021
+++ src/distrib/sets/lists/tests/mi Tue Oct 5 17:09:45 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1131 2021/09/30 02:00:19 yamaguchi Exp $
+# $NetBSD: mi,v 1.1132 2021/10/05 17:09:45 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4991,6 +4991,9 @@
./usr/tests/usr.bin/indent/pcs.0 tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/pcs.0.pro tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/pcs.0.stdout tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/ps_ind_level.0 tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/ps_ind_level.0.pro tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/ps_ind_level.0.stdout tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/struct.0 tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/struct.0.stdout tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/surplusbad.0 tests-usr.bin-tests compattestfile,atf
Index: src/tests/usr.bin/indent/Makefile
diff -u src/tests/usr.bin/indent/Makefile:1.11 src/tests/usr.bin/indent/Makefile:1.12
--- src/tests/usr.bin/indent/Makefile:1.11 Sat Sep 25 13:04:55 2021
+++ src/tests/usr.bin/indent/Makefile Tue Oct 5 17:09:45 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.11 2021/09/25 13:04:55 rillig Exp $
+# $NetBSD: Makefile,v 1.12 2021/10/05 17:09:45 rillig Exp $
.include <bsd.own.mk>
@@ -267,6 +267,9 @@ FILES+= parens.0.pro
FILES+= pcs.0
FILES+= pcs.0.stdout
FILES+= pcs.0.pro
+FILES+= ps_ind_level.0
+FILES+= ps_ind_level.0.pro
+FILES+= ps_ind_level.0.stdout
FILES+= cs.0
FILES+= cs.0.stdout
FILES+= cs.0.pro
Added files:
Index: src/tests/usr.bin/indent/ps_ind_level.0
diff -u /dev/null src/tests/usr.bin/indent/ps_ind_level.0:1.1
--- /dev/null Tue Oct 5 17:09:45 2021
+++ src/tests/usr.bin/indent/ps_ind_level.0 Tue Oct 5 17:09:45 2021
@@ -0,0 +1,17 @@
+/* $NetBSD: ps_ind_level.0,v 1.1 2021/10/05 17:09:45 rillig Exp $ */
+/* $FreeBSD$ */
+/* $ */
+/* $ The leading indentation in the first line determines the indentation */
+/* $ of the remaining code. In this particular test, the indentation is set */
+/* $ to 5 and the tabulator is set to 8, to demonstrate an off-by-one error */
+/* $ in main_prepare_parsing that has been fixed in indent.c 1.106 from */
+/* $ 2021-10-05. */
+/* $ */
+/* $ The declaration in the below line is indented by 3 tabs, amounting to */
+/* $ 24 spaces. The initial indentation of the code is intended to be */
+/* $ rounded down, to 4 levels of indentation, amounting to 20 spaces. */
+ int declaration_in_column_25;
+
+/* $ Even if later code has a smaller indentation, it is nevertheless */
+/* $ indented to the level given by the first line of code. */
+void function_in_column_1(void){}
Index: src/tests/usr.bin/indent/ps_ind_level.0.pro
diff -u /dev/null src/tests/usr.bin/indent/ps_ind_level.0.pro:1.1
--- /dev/null Tue Oct 5 17:09:45 2021
+++ src/tests/usr.bin/indent/ps_ind_level.0.pro Tue Oct 5 17:09:45 2021
@@ -0,0 +1,5 @@
+/* $NetBSD: ps_ind_level.0.pro,v 1.1 2021/10/05 17:09:45 rillig Exp $ */
+/* $FreeBSD$ */
+
+-i5 /* 5 spaces indentation */
+-ts8 /* 8 spaces per tabulator */
Index: src/tests/usr.bin/indent/ps_ind_level.0.stdout
diff -u /dev/null src/tests/usr.bin/indent/ps_ind_level.0.stdout:1.1
--- /dev/null Tue Oct 5 17:09:45 2021
+++ src/tests/usr.bin/indent/ps_ind_level.0.stdout Tue Oct 5 17:09:45 2021
@@ -0,0 +1,9 @@
+/* $NetBSD: ps_ind_level.0.stdout,v 1.1 2021/10/05 17:09:45 rillig Exp $ */
+/* $FreeBSD$ */
+/* $ */
+/* $ FIXME: indentation should be 20 instead of 25. */
+ int declaration_in_column_25;
+
+/* $ FIXME: The space between '){' is missing. */
+ void function_in_column_1(void){
+ }