Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/indent tests/indent: fix outdated or wrong comments



details:   https://anonhg.NetBSD.org/src/rev/d9ec916c2b86
branches:  trunk
changeset: 375913:d9ec916c2b86
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun May 21 10:18:44 2023 +0000

description:
tests/indent: fix outdated or wrong comments

diffstat:

 tests/usr.bin/indent/indent_off_on.c            |   4 +-
 tests/usr.bin/indent/lsym_comment.c             |  45 ++++++++++--------------
 tests/usr.bin/indent/lsym_form_feed.c           |   4 +-
 tests/usr.bin/indent/lsym_type_in_parentheses.c |   4 +-
 tests/usr.bin/indent/opt_bl_br.c                |   4 +-
 tests/usr.bin/indent/t_errors.sh                |  11 ++---
 tests/usr.bin/indent/t_options.lua              |   3 +-
 usr.bin/indent/pr_comment.c                     |   7 +--
 8 files changed, 35 insertions(+), 47 deletions(-)

diffs (292 lines):

diff -r ed423062b540 -r d9ec916c2b86 tests/usr.bin/indent/indent_off_on.c
--- a/tests/usr.bin/indent/indent_off_on.c      Sun May 21 10:05:20 2023 +0000
+++ b/tests/usr.bin/indent/indent_off_on.c      Sun May 21 10:18:44 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent_off_on.c,v 1.12 2023/05/20 10:25:47 rillig Exp $ */
+/* $NetBSD: indent_off_on.c,v 1.13 2023/05/21 10:18:44 rillig Exp $ */
 
 /*
  * Tests for the comments 'INDENT OFF' and 'INDENT ON', which temporarily
@@ -183,7 +183,7 @@ void                indent_on(void);
 /* INDENT: OFF */
 void           indent_still_on(void);  /* due to the colon in the middle */
 /* $ The extra comment got moved to a separate line, but indenting is still */
-/* $ off because the 'INDENT OFF' comment was not in a line of its own. */
+/* $ on because the 'INDENT OFF' comment was not in a line of its own. */
 /* INDENT OFF */
 /* extra comment */
 void           indent_still_on(void);  /* due to the extra comment to the
diff -r ed423062b540 -r d9ec916c2b86 tests/usr.bin/indent/lsym_comment.c
--- a/tests/usr.bin/indent/lsym_comment.c       Sun May 21 10:05:20 2023 +0000
+++ b/tests/usr.bin/indent/lsym_comment.c       Sun May 21 10:18:44 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_comment.c,v 1.14 2023/05/20 11:19:17 rillig Exp $ */
+/* $NetBSD: lsym_comment.c,v 1.15 2023/05/21 10:18:44 rillig Exp $ */
 
 /*
  * Tests for the token lsym_comment, which starts a comment.
@@ -8,7 +8,7 @@
  *
  * See also:
  *     opt_fc1.c
- *     token_comment.c
+ *     lsym_comment.c
  */
 
 /*-
@@ -138,16 +138,13 @@ t(void)
  *
  * The other Christmas tree is a standalone block comment, therefore the
  * comment starts in the code column.
- *
- * Since the comments occur between psym_if_expr and the following statement,
- * they are handled by search_stmt_comment.
  */
 //indent input
 {
-       if (1) /*- a Christmas tree  *  search_stmt_comment
+       if (1) /*- a Christmas tree  *
                                    ***
                                   ***** */
-                   /*- another one *  search_stmt_comment
+                   /*- another one *
                                   ***
                                  ***** */
                1;
@@ -156,10 +153,10 @@ t(void)
 
 //indent run -bbb
 {
-       if (1)                  /*- a Christmas tree  *  search_stmt_comment
+       if (1)                  /*- a Christmas tree  *
                                                     ***
                                                    ***** */
-               /*- another one *  search_stmt_comment
+               /*- another one *
                               ***
                              ***** */
                1;
@@ -219,16 +216,16 @@ int decl;                 /*-fixed comment
 
 //indent input
 {
-       if (0)/*-search_stmt_comment   |
-          search_stmt_comment         |*/
+       if (0)/*-first line            |
+          second line                 |*/
                ;
 }
 //indent end
 
 //indent run -di0
 {
-       if (0)                  /*-search_stmt_comment   |
-                            search_stmt_comment         |*/
+       if (0)                  /*-first line            |
+                            second line                 |*/
                ;
 }
 //indent end
@@ -252,21 +249,19 @@ int decl;                 /*-fixed comment
 /*
  * Ensure that all text of the comment is preserved when the comment is moved
  * to the right.
- *
- * This comment is handled by search_stmt_comment.
  */
 //indent input
 {
-       if(0)/*-search_stmt_comment
-123456789ab search_stmt_comment   |*/
+       if(0)/*-first line
+123456789ab second line           |*/
            ;
 }
 //indent end
 
 //indent run -di0
 {
-       if (0)                  /*-search_stmt_comment
-                  123456789ab search_stmt_comment   |*/
+       if (0)                  /*-first line
+                  123456789ab second line           |*/
                ;
 }
 //indent end
@@ -300,12 +295,10 @@ tab1+++   tab2--- tab3+++ tab4--- tab5+++ 
  * Ensure that all text of the comment is preserved when the comment is moved
  * to the left. In this case, the internal layout of the comment cannot be
  * preserved since the second line already starts in column 1.
- *
- * This comment is processed by search_stmt_comment.
  */
 //indent input
 {
-       if(0)                                       /*-|search_stmt_comment
+       if(0)                                       /*-|first line
                                        | minus 12     |
                | tabs inside           |
            |---|
@@ -317,7 +310,7 @@ tab1+++     tab2--- tab3+++ tab4--- tab5+++ 
 
 //indent run -di0
 {
-       if (0)                  /*-|search_stmt_comment
+       if (0)                  /*-|first line
                    | minus 12     |
 | tabs inside          |
 |---|
@@ -329,7 +322,7 @@ tab1+++     tab2--- tab3+++ tab4--- tab5+++ 
 
 
 /*
- * Ensure that '{' after a search_stmt_comment is preserved.
+ * Ensure that '{' after a comment is preserved.
  */
 //indent input
 {
@@ -338,7 +331,7 @@ tab1+++     tab2--- tab3+++ tab4--- tab5+++ 
 }
 //indent end
 
-/* Before 2023-05-11, the comment moved to the right of the '{'. */
+/* Before 2023-05-11, the comment and the '{' swapped places. */
 //indent run
 {
        if (0) /* comment */ {
@@ -902,7 +895,7 @@ int         decl;
 /*
  * A completely empty line in a box comment must be copied unmodified to the
  * output. This is done in process_comment by adding a space to the end of an
- * otherwise empty comment. This space forces output_complete_line to add some output,
+ * otherwise empty comment. This space forces output_line to add some output,
  * but the trailing space is discarded, resulting in an empty line.
  */
 //indent input
diff -r ed423062b540 -r d9ec916c2b86 tests/usr.bin/indent/lsym_form_feed.c
--- a/tests/usr.bin/indent/lsym_form_feed.c     Sun May 21 10:05:20 2023 +0000
+++ b/tests/usr.bin/indent/lsym_form_feed.c     Sun May 21 10:18:44 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_form_feed.c,v 1.7 2023/05/16 11:32:02 rillig Exp $ */
+/* $NetBSD: lsym_form_feed.c,v 1.8 2023/05/21 10:18:44 rillig Exp $ */
 
 /*
  * Tests for the token lsym_form_feed, which represents a form feed, a special
@@ -17,7 +17,7 @@ void function_2(void);
 
 
 /*
- * Test form feed after 'if (expr)', which is handled in search_stmt.
+ * Test form feed after 'if (expr)', even though it does not occur in practice.
  */
 //indent input
 void function(void)
diff -r ed423062b540 -r d9ec916c2b86 tests/usr.bin/indent/lsym_type_in_parentheses.c
--- a/tests/usr.bin/indent/lsym_type_in_parentheses.c   Sun May 21 10:05:20 2023 +0000
+++ b/tests/usr.bin/indent/lsym_type_in_parentheses.c   Sun May 21 10:18:44 2023 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: lsym_type_in_parentheses.c,v 1.3 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: lsym_type_in_parentheses.c,v 1.4 2023/05/21 10:18:44 rillig Exp $ */
 
 /*
- * Tests for the token lsym_token_in_parentheses, which represents a type name
+ * Tests for the token lsym_type_in_parentheses, which represents a type name
  * inside parentheses in the following contexts:
  *
  * As part of a parameter list of a function prototype.
diff -r ed423062b540 -r d9ec916c2b86 tests/usr.bin/indent/opt_bl_br.c
--- a/tests/usr.bin/indent/opt_bl_br.c  Sun May 21 10:05:20 2023 +0000
+++ b/tests/usr.bin/indent/opt_bl_br.c  Sun May 21 10:18:44 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bl_br.c,v 1.8 2023/05/11 17:22:56 rillig Exp $ */
+/* $NetBSD: opt_bl_br.c,v 1.9 2023/05/21 10:18:44 rillig Exp $ */
 
 //indent input
 void
@@ -156,7 +156,7 @@ function(void)
 
 /*
  * The combination of the options '-br' and '-ei' (both active by default)
- * remove extra newlines between the tokens '}', 'else' and 'if'.
+ * removes extra newlines between the tokens '}', 'else' and 'if'.
  */
 //indent input
 void
diff -r ed423062b540 -r d9ec916c2b86 tests/usr.bin/indent/t_errors.sh
--- a/tests/usr.bin/indent/t_errors.sh  Sun May 21 10:05:20 2023 +0000
+++ b/tests/usr.bin/indent/t_errors.sh  Sun May 21 10:18:44 2023 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_errors.sh,v 1.29 2023/05/21 09:48:22 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.30 2023/05/21 10:18:44 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -100,7 +100,6 @@ option_tabsize_zero_body()
 atf_test_case 'option_tabsize_large'
 option_tabsize_large_body()
 {
-       # Integer overflow, on both ILP32 and LP64 platforms.
        expect_error \
            'indent: Command line: argument "81" to option "-ts" must be between 1 and 80' \
            -ts81
@@ -458,11 +457,9 @@ EOF
 atf_test_case 'comment_fits_in_one_line'
 comment_fits_in_one_line_body()
 {
-       # The comment is placed after 'if (0) ...', where it is processed
-       # by search_stmt_comment. That function redirects the input buffer to
-       # a temporary buffer that is not guaranteed to be terminated by '\n'.
-       # Before NetBSD pr_comment.c 1.91 from 2021-10-30, this produced an
-       # assertion failure in fits_in_one_line.
+       # The comment is placed after 'if (0) ...'. Before NetBSD pr_comment.c
+       # 1.91 from 2021-10-30, this produced an assertion failure in
+       # fits_in_one_line.
        cat <<EOF > code.c
 int f(void)
 {
diff -r ed423062b540 -r d9ec916c2b86 tests/usr.bin/indent/t_options.lua
--- a/tests/usr.bin/indent/t_options.lua        Sun May 21 10:05:20 2023 +0000
+++ b/tests/usr.bin/indent/t_options.lua        Sun May 21 10:18:44 2023 +0000
@@ -1,4 +1,4 @@
--- $NetBSD: t_options.lua,v 1.2 2023/05/20 22:08:07 rillig Exp $
+-- $NetBSD: t_options.lua,v 1.3 2023/05/21 10:18:44 rillig Exp $
 --
 -- Copyright (c) 2023 The NetBSD Foundation, Inc.
 -- All rights reserved.
@@ -293,7 +293,6 @@ local function handle_line(line)
 
        if section == ""
            and line ~= ""
-           and line:sub(1, 1) ~= "#"
            and line:sub(1, 1) ~= "/"
            and line:sub(1, 2) ~= " *" then
                warn(lineno, "non-comment line outside 'input' or 'run' "
diff -r ed423062b540 -r d9ec916c2b86 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c       Sun May 21 10:05:20 2023 +0000
+++ b/usr.bin/indent/pr_comment.c       Sun May 21 10:18:44 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pr_comment.c,v 1.148 2023/05/20 11:53:53 rillig Exp $  */
+/*     $NetBSD: pr_comment.c,v 1.149 2023/05/21 10:18:44 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pr_comment.c,v 1.148 2023/05/20 11:53:53 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.149 2023/05/21 10:18:44 rillig Exp $");
 
 #include <string.h>
 
@@ -124,8 +124,7 @@ analyze_comment(bool *p_may_wrap, bool *
 
        if (!may_wrap) {
                /* Find out how much indentation there was originally, because
-                * that much will have to be ignored by output_complete_line.
-                */
+                * that much will have to be ignored by output_line. */
                size_t len = (size_t)(inp.st - 2 - inp.mem);
                ps.n_comment_delta = -ind_add(0, inp.mem, len);
        } else {



Home | Main Index | Thread Index | Old Index