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: fix trailing whitespace after comment



details:   https://anonhg.NetBSD.org/src/rev/18e36b7b53d1
branches:  trunk
changeset: 376226:18e36b7b53d1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jun 05 08:22:00 2023 +0000

description:
indent: fix trailing whitespace after comment

diffstat:

 tests/usr.bin/indent/lsym_comment.c |  11 +++++------
 tests/usr.bin/indent/lsym_do.c      |   8 +++-----
 tests/usr.bin/indent/t_errors.sh    |   6 +++---
 usr.bin/indent/indent.c             |   8 +++-----
 4 files changed, 14 insertions(+), 19 deletions(-)

diffs (128 lines):

diff -r 6260c81a981b -r 18e36b7b53d1 tests/usr.bin/indent/lsym_comment.c
--- a/tests/usr.bin/indent/lsym_comment.c       Mon Jun 05 08:10:25 2023 +0000
+++ b/tests/usr.bin/indent/lsym_comment.c       Mon Jun 05 08:22:00 2023 +0000
@@ -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
 
diff -r 6260c81a981b -r 18e36b7b53d1 tests/usr.bin/indent/lsym_do.c
--- a/tests/usr.bin/indent/lsym_do.c    Mon Jun 05 08:10:25 2023 +0000
+++ b/tests/usr.bin/indent/lsym_do.c    Mon Jun 05 08:22:00 2023 +0000
@@ -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.
diff -r 6260c81a981b -r 18e36b7b53d1 tests/usr.bin/indent/t_errors.sh
--- a/tests/usr.bin/indent/t_errors.sh  Mon Jun 05 08:10:25 2023 +0000
+++ b/tests/usr.bin/indent/t_errors.sh  Mon Jun 05 08:22:00 2023 +0000
@@ -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
 
diff -r 6260c81a981b -r 18e36b7b53d1 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Mon Jun 05 08:10:25 2023 +0000
+++ b/usr.bin/indent/indent.c   Mon Jun 05 08:22:00 2023 +0000
@@ -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



Home | Main Index | Thread Index | Old Index