Module Name:    src
Committed By:   rillig
Date:           Sun Nov  7 11:30:45 UTC 2021

Modified Files:
        src/tests/usr.bin/indent: token_comment.c
        src/usr.bin/indent: pr_comment.c

Log Message:
indent: remove dead code in analyze_comment

The case of an otherwise empty line is already handled further above.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/tests/usr.bin/indent/token_comment.c
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/indent/pr_comment.c

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.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.20 src/tests/usr.bin/indent/token_comment.c:1.21
--- src/tests/usr.bin/indent/token_comment.c:1.20	Sun Nov  7 10:13:26 2021
+++ src/tests/usr.bin/indent/token_comment.c	Sun Nov  7 11:30:45 2021
@@ -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 @@ f(void)
 #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

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.111 src/usr.bin/indent/pr_comment.c:1.112
--- src/usr.bin/indent/pr_comment.c:1.111	Sun Nov  7 11:08:25 2021
+++ src/usr.bin/indent/pr_comment.c	Sun Nov  7 11:30:45 2021
@@ -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 @@ static char sccsid[] = "@(#)pr_comment.c
 
 #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 @@ analyze_comment(bool *p_may_wrap, bool *
 	} 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;

Reply via email to