Module Name: src Committed By: rillig Date: Fri Oct 8 20:04:26 UTC 2021
Modified Files: src/tests/usr.bin/indent: token-preprocessing.0 token-preprocessing.0.stdout Log Message: indent: demonstrate bug in parsing preprocessor lines To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/token-preprocessing.0 cvs rdiff -u -r1.4 -r1.5 \ 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.3 src/tests/usr.bin/indent/token-preprocessing.0:1.4 --- src/tests/usr.bin/indent/token-preprocessing.0:1.3 Sat Mar 13 13:04:13 2021 +++ src/tests/usr.bin/indent/token-preprocessing.0 Fri Oct 8 20:04:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: token-preprocessing.0,v 1.3 2021/03/13 13:04:13 rillig Exp $ */ +/* $NetBSD: token-preprocessing.0,v 1.4 2021/10/08 20:04:26 rillig Exp $ */ /* $FreeBSD$ */ /*- @@ -34,3 +34,26 @@ #define comment_in_string_literal "/* no comment " int this_is_an_ordinary_line_again; + +/* + * Before indent.c 1.129 from 2021-10-08, indent mistakenly interpreted quotes + * in comments as starting a string literal. The '"' in the comment started a + * string, the next '"' finished the string, and the following '/' '*' was + * interpreted as the beginning of a comment. This comment lasted until the + * next '*' '/', which in this test is another preprocessor directive, solely + * for symmetry. + * + * The effect was that the extra space after d2 was not formatted, as that + * line was considered part of the comment. + */ +int d1 ; +#define confuse_d /*"*/ "/*" +int d2 ; +#define resolve_d "*/" +int d3 ; + +int s1 ; +#define confuse_s /*'*/ '/*' +int s2 ; +#define resolve_s '*/' +int s3 ; Index: src/tests/usr.bin/indent/token-preprocessing.0.stdout diff -u src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.4 src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.5 --- src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.4 Sat Mar 13 13:14:14 2021 +++ src/tests/usr.bin/indent/token-preprocessing.0.stdout Fri Oct 8 20:04:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: token-preprocessing.0.stdout,v 1.4 2021/03/13 13:14:14 rillig Exp $ */ +/* $NetBSD: token-preprocessing.0.stdout,v 1.5 2021/10/08 20:04:26 rillig Exp $ */ /* $FreeBSD$ */ /*- @@ -35,3 +35,26 @@ #define comment_in_string_literal "/* no comment " int this_is_an_ordinary_line_again; + +/* + * Before indent.c 1.129 from 2021-10-08, indent mistakenly interpreted quotes + * in comments as starting a string literal. The '"' in the comment started a + * string, the next '"' finished the string, and the following '/' '*' was + * interpreted as the beginning of a comment. This comment lasted until the + * next '*' '/', which in this test is another preprocessor directive, solely + * for symmetry. + * + * The effect was that the extra space after d2 was not formatted, as that + * line was considered part of the comment. + */ +int d1; +#define confuse_d /*"*/ "/*" +int d2 ; +#define resolve_d "*/" +int d3; + +int s1; +#define confuse_s /*'*/ '/*' +int s2 ; +#define resolve_s '*/' +int s3;