Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/indent tests/indent: demonstrate bugs in comment pro...
details: https://anonhg.NetBSD.org/src/rev/4399766a6aa6
branches: trunk
changeset: 1026471:4399766a6aa6
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Nov 25 20:14:00 2021 +0000
description:
tests/indent: demonstrate bugs in comment processing
diffstat:
tests/usr.bin/indent/token_comment.c | 36 +++++++++++++++++++++++++++++++++++-
usr.bin/indent/pr_comment.c | 16 ++++++++++++++--
2 files changed, 49 insertions(+), 3 deletions(-)
diffs (91 lines):
diff -r a55eedf4a687 -r 4399766a6aa6 tests/usr.bin/indent/token_comment.c
--- a/tests/usr.bin/indent/token_comment.c Thu Nov 25 20:02:06 2021 +0000
+++ b/tests/usr.bin/indent/token_comment.c Thu Nov 25 20:14:00 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.24 2021/11/20 16:54:17 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.25 2021/11/25 20:14:00 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -1049,3 +1049,37 @@
#indent end
#indent run-equals-input
+
+
+/*
+ * The function analyze_comment wrongly joins the two comments.
+ */
+#indent input
+/*
+ *//*
+join*/
+#indent end
+
+#indent run -nfc1
+/*
+ *
+ * join
+ */
+#indent end
+
+
+/*
+ * The function analyze_comment generates malformed output.
+ */
+#indent input
+/*
+*//*
+error*/
+#indent end
+
+#indent run -nfc1
+/*
+ */
+ * error
+ */
+#indent end
diff -r a55eedf4a687 -r 4399766a6aa6 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c Thu Nov 25 20:02:06 2021 +0000
+++ b/usr.bin/indent/pr_comment.c Thu Nov 25 20:14:00 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.121 2021/11/19 20:23:17 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.122 2021/11/25 20:14:00 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.121 2021/11/19 20:23:17 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.122 2021/11/25 20:14:00 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -123,6 +123,12 @@
break_delim = false;
}
+ /*
+ * XXX: This condition looks suspicious since it ignores the case
+ * where the end of the previous comment is still in 'com'.
+ *
+ * See test token_comment.c, keyword 'analyze_comment'.
+ */
if (lab.s == lab.e && code.s == code.e) {
adj_max_line_length = opt.block_comment_max_line_length;
com_ind = (ps.ind_level - opt.unindent_displace) * opt.indent_size;
@@ -172,6 +178,12 @@
break_delim = false;
if (break_delim) {
+ /*
+ * FIXME: This code wrongly joins comments in '-nfc1' mode and
+ * generates malformed code.
+ *
+ * See test token_comment.c, keyword 'analyze_comment'.
+ */
com.e = com.s + 2;
*com.e = '\0';
if (opt.blanklines_before_block_comments &&
Home |
Main Index |
Thread Index |
Old Index