Module Name: src
Committed By: rillig
Date: Mon Jun 5 08:22:01 UTC 2023
Modified Files:
src/tests/usr.bin/indent: lsym_comment.c lsym_do.c t_errors.sh
src/usr.bin/indent: indent.c
Log Message:
indent: fix trailing whitespace after comment
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/lsym_comment.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/lsym_do.c
cvs rdiff -u -r1.32 -r1.33 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.329 -r1.330 src/usr.bin/indent/indent.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/lsym_comment.c
diff -u src/tests/usr.bin/indent/lsym_comment.c:1.15 src/tests/usr.bin/indent/lsym_comment.c:1.16
--- src/tests/usr.bin/indent/lsym_comment.c:1.15 Sun May 21 10:18:44 2023
+++ src/tests/usr.bin/indent/lsym_comment.c Mon Jun 5 08:22:00 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_comment.c,v 1.15 2023/05/21 10:18:44 rillig Exp $ */
+/* $NetBSD: lsym_comment.c,v 1.16 2023/06/05 08:22:00 rillig Exp $ */
/*
* Tests for the token lsym_comment, which starts a comment.
@@ -734,11 +734,10 @@ while(cond)/*comment*/;
void
loop(void)
{
- while (cond) /* comment */ ;
+ while (cond) /* comment */;
while (cond)
-/* $ XXX: The space after the comment looks unintentional. */
- /* comment */ ;
+ /* comment */;
}
//indent end
@@ -937,7 +936,7 @@ f(void)
/*
* 12 1234 123 123456 1234 1234567 123
* 1234.
- */ ;
+ */;
}
//indent end
@@ -947,7 +946,7 @@ int
f(void)
{
if (0)
- /* 12 1234 123 123456 1234 1234567 123 1234. */ ;
+ /* 12 1234 123 123456 1234 1234567 123 1234. */;
}
//indent end
Index: src/tests/usr.bin/indent/lsym_do.c
diff -u src/tests/usr.bin/indent/lsym_do.c:1.8 src/tests/usr.bin/indent/lsym_do.c:1.9
--- src/tests/usr.bin/indent/lsym_do.c:1.8 Mon Jun 5 08:10:25 2023
+++ src/tests/usr.bin/indent/lsym_do.c Mon Jun 5 08:22:00 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_do.c,v 1.8 2023/06/05 08:10:25 rillig Exp $ */
+/* $NetBSD: lsym_do.c,v 1.9 2023/06/05 08:22:00 rillig Exp $ */
/*
* Tests for the token lsym_do, which represents the keyword 'do' that starts
@@ -125,8 +125,7 @@ variants(void)
//indent run
{
-// $ FIXME: Trailing whitespace.
- /* */
+ /* */
do {
} while (false);
@@ -141,8 +140,7 @@ label: do {
//indent run -sob
{
-// $ FIXME: Trailing whitespace.
- /* */
+ /* */
do {
} while (false);
// $ FIXME: This blank line is not optional and must be preserved.
Index: src/tests/usr.bin/indent/t_errors.sh
diff -u src/tests/usr.bin/indent/t_errors.sh:1.32 src/tests/usr.bin/indent/t_errors.sh:1.33
--- src/tests/usr.bin/indent/t_errors.sh:1.32 Sun Jun 4 22:20:04 2023
+++ src/tests/usr.bin/indent/t_errors.sh Mon Jun 5 08:22:00 2023
@@ -1,5 +1,5 @@
#! /bin/sh
-# $NetBSD: t_errors.sh,v 1.32 2023/06/04 22:20:04 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.33 2023/06/05 08:22:00 rillig Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -468,7 +468,7 @@ crash_comment_after_controlling_expressi
cat <<\EOF > code.exp
{
if (expr
- ) /* c */ ;
+ ) /* c */;
}
EOF
@@ -499,7 +499,7 @@ f(void)
if (0)
/*
* 0123456789012345678901
- */ ;
+ */;
}
EOF
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.329 src/usr.bin/indent/indent.c:1.330
--- src/usr.bin/indent/indent.c:1.329 Mon Jun 5 07:35:05 2023
+++ src/usr.bin/indent/indent.c Mon Jun 5 08:22:00 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.329 2023/06/05 07:35:05 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.330 2023/06/05 08:22:00 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.329 2023/06/05 07:35:05 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.330 2023/06/05 08:22:00 rillig Exp $");
#include <sys/param.h>
#include <err.h>
@@ -423,10 +423,8 @@ move_com_to_code(lexer_symbol lsym)
if (ps.want_blank)
buf_add_char(&code, ' ');
buf_add_buf(&code, &com);
- if (lsym != lsym_rparen && lsym != lsym_rbracket)
- buf_add_char(&code, ' ');
com.len = 0;
- ps.want_blank = false;
+ ps.want_blank = lsym != lsym_rparen && lsym != lsym_rbracket;
}
static void