Module Name:    src
Committed By:   rillig
Date:           Sun May 14 16:47:06 UTC 2023

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

Log Message:
indent: fix vertical spacing after declarations

A comment is not supposed to change the state of the 'blank line after
declaration', but it did.  The initialization of saved_just_saw_decl was
wrong though since it tried to capture the previous value after it had
already been overwritten.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/opt_bad.c
cvs rdiff -u -r1.134 -r1.135 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/opt_bad.c
diff -u src/tests/usr.bin/indent/opt_bad.c:1.9 src/tests/usr.bin/indent/opt_bad.c:1.10
--- src/tests/usr.bin/indent/opt_bad.c:1.9	Sat May 13 15:34:22 2023
+++ src/tests/usr.bin/indent/opt_bad.c	Sun May 14 16:47:06 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bad.c,v 1.9 2023/05/13 15:34:22 rillig Exp $ */
+/* $NetBSD: opt_bad.c,v 1.10 2023/05/14 16:47:06 rillig Exp $ */
 
 /*
  * Tests for the options '-bad' and '-nbad'.
@@ -110,8 +110,8 @@ comments(void)
 {
 	int local_var_1;	/* comment */
 	int local_var_2;	/* comment */
+
 	/* comment line */
-	/* $ TODO: Add blank line here. */
 	function_call();
 }
 //indent end

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.134 src/usr.bin/indent/pr_comment.c:1.135
--- src/usr.bin/indent/pr_comment.c:1.134	Sun May 14 14:14:07 2023
+++ src/usr.bin/indent/pr_comment.c	Sun May 14 16:47:06 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.134 2023/05/14 14:14:07 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.135 2023/05/14 16:47:06 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pr_comment.c,v 1.134 2023/05/14 14:14:07 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.135 2023/05/14 16:47:06 rillig Exp $");
 
 #include <string.h>
 
@@ -111,7 +111,7 @@ analyze_comment(bool *p_may_wrap, bool *
 	 * 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'.
+	 * See test lsym_comment.c, keyword 'analyze_comment'.
 	 */
 	if (lab.s == lab.e && code.s == code.e) {
 	    adj_max_line_length = opt.block_comment_max_line_length;
@@ -340,13 +340,9 @@ process_comment(void)
     int adj_max_line_length;
     bool may_wrap, break_delim;
 
-    ps.declaration = decl_no;
-
-    enum declaration saved_just_saw_decl = ps.declaration;
     analyze_comment(&may_wrap, &break_delim, &adj_max_line_length);
     if (may_wrap)
 	copy_comment_wrap(adj_max_line_length, break_delim);
     else
 	copy_comment_nowrap();
-    ps.declaration = saved_just_saw_decl;
 }

Reply via email to