Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/indent indent: remove dead code in analyze_comment
details: https://anonhg.NetBSD.org/src/rev/743939d36dc4
branches: trunk
changeset: 1024839:743939d36dc4
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 07 11:30:45 2021 +0000
description:
indent: remove dead code in analyze_comment
The case of an otherwise empty line is already handled further above.
diffstat:
tests/usr.bin/indent/token_comment.c | 37 +++++++++++++++++++++++++++++++++++-
usr.bin/indent/pr_comment.c | 14 ++++--------
2 files changed, 41 insertions(+), 10 deletions(-)
diffs (83 lines):
diff -r 4ebaf33b1e93 -r 743939d36dc4 tests/usr.bin/indent/token_comment.c
--- a/tests/usr.bin/indent/token_comment.c Sun Nov 07 11:08:25 2021 +0000
+++ b/tests/usr.bin/indent/token_comment.c Sun Nov 07 11:30:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.20 2021/11/07 10:13:26 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.21 2021/11/07 11:30:45 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -986,3 +986,38 @@
#indent end
#indent run-equals-input
+
+
+/*
+ * Test two completely empty lines in a wrap comment. The second empty line
+ * covers the condition ps.next_col_1 in copy_comment_wrap.
+ */
+#indent input
+/* line 1
+
+
+line 4 */
+#indent end
+
+#indent run
+/*
+ * line 1
+ *
+ *
+ * line 4
+ */
+#indent end
+
+#indent run-equals-input -nfc1
+#indent run-equals-input -nfc1 -nsc
+
+#indent run -nsc
+/*
+line 1
+
+
+line 4
+ */
+#indent end
+
+#indent run-equals-input -nsc -ncdb
diff -r 4ebaf33b1e93 -r 743939d36dc4 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c Sun Nov 07 11:08:25 2021 +0000
+++ b/usr.bin/indent/pr_comment.c Sun Nov 07 11:30:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.111 2021/11/07 11:08:25 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.112 2021/11/07 11:30:45 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.111 2021/11/07 11:08:25 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.112 2021/11/07 11:30:45 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -132,13 +132,9 @@
} else {
break_delim = false;
- int target_ind;
- if (code.s != code.e)
- target_ind = ind_add(compute_code_indent(), code.s, code.e);
- else if (lab.s != lab.e)
- target_ind = ind_add(compute_label_indent(), lab.s, lab.e);
- else
- target_ind = 0;
+ int target_ind = code.s != code.e
+ ? ind_add(compute_code_indent(), code.s, code.e)
+ : ind_add(compute_label_indent(), lab.s, lab.e);
com_ind = ps.decl_on_line || ps.ind_level == 0
? opt.decl_comment_column - 1 : opt.comment_column - 1;
Home |
Main Index |
Thread Index |
Old Index