Module Name: src
Committed By: rillig
Date: Fri Sep 24 16:29:31 UTC 2021
Modified Files:
src/tests/usr.bin/indent: comment-line-end.0 comment-line-end.0.stdout
src/usr.bin/indent: io.c
Log Message:
indent: fix token duplication after C99 comment
The code that keeps blank lines after C99 comments still looks wrong,
but at least it's better than before.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/comment-line-end.0 \
src/tests/usr.bin/indent/comment-line-end.0.stdout
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/indent/io.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/comment-line-end.0
diff -u src/tests/usr.bin/indent/comment-line-end.0:1.6 src/tests/usr.bin/indent/comment-line-end.0:1.7
--- src/tests/usr.bin/indent/comment-line-end.0:1.6 Fri Sep 24 06:30:02 2021
+++ src/tests/usr.bin/indent/comment-line-end.0 Fri Sep 24 16:29:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: comment-line-end.0,v 1.6 2021/09/24 06:30:02 rillig Exp $ */
+/* $NetBSD: comment-line-end.0,v 1.7 2021/09/24 16:29:31 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -27,7 +27,6 @@ main(void)
{
}
-/* FIXME: in the formatted output, the word 'bar' is repeated. */
void c99_comment(void)
{
foo(); // C++ comment
Index: src/tests/usr.bin/indent/comment-line-end.0.stdout
diff -u src/tests/usr.bin/indent/comment-line-end.0.stdout:1.6 src/tests/usr.bin/indent/comment-line-end.0.stdout:1.7
--- src/tests/usr.bin/indent/comment-line-end.0.stdout:1.6 Fri Sep 24 06:30:02 2021
+++ src/tests/usr.bin/indent/comment-line-end.0.stdout Fri Sep 24 16:29:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: comment-line-end.0.stdout,v 1.6 2021/09/24 06:30:02 rillig Exp $ */
+/* $NetBSD: comment-line-end.0.stdout,v 1.7 2021/09/24 16:29:31 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -30,12 +30,11 @@ main(void)
{
}
-/* FIXME: in the formatted output, the word 'bar' is repeated. */
void
c99_comment(void)
{
foo(); // C++ comment
-bar bar();
+ bar();
}
// end-of-line comment at the end of the file
Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.49 src/usr.bin/indent/io.c:1.50
--- src/usr.bin/indent/io.c:1.49 Sun Mar 14 01:44:37 2021
+++ src/usr.bin/indent/io.c Fri Sep 24 16:29:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.49 2021/03/14 01:44:37 rillig Exp $ */
+/* $NetBSD: io.c,v 1.50 2021/09/24 16:29:31 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c 8.1 (Be
#include <sys/cdefs.h>
#ifndef lint
#if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.49 2021/03/14 01:44:37 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.50 2021/09/24 16:29:31 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -260,7 +260,8 @@ dump_line(void)
}
/* keep blank lines after '//' comments */
- if (e_com - s_com > 1 && s_com[1] == '/')
+ if (e_com - s_com > 1 && s_com[1] == '/'
+ && s_token < e_token && isspace((unsigned char)s_token[0]))
output_range(s_token, e_token);
ps.decl_on_line = ps.in_decl; /* if we are in the middle of a declaration,