Module Name: src Committed By: rillig Date: Sun May 21 10:18:44 UTC 2023
Modified Files: src/tests/usr.bin/indent: indent_off_on.c lsym_comment.c lsym_form_feed.c lsym_type_in_parentheses.c opt_bl_br.c t_errors.sh t_options.lua src/usr.bin/indent: pr_comment.c Log Message: tests/indent: fix outdated or wrong comments To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/indent_off_on.c cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/indent/lsym_comment.c cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/lsym_form_feed.c cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/lsym_type_in_parentheses.c cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/opt_bl_br.c cvs rdiff -u -r1.29 -r1.30 src/tests/usr.bin/indent/t_errors.sh cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/t_options.lua cvs rdiff -u -r1.148 -r1.149 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/indent_off_on.c diff -u src/tests/usr.bin/indent/indent_off_on.c:1.12 src/tests/usr.bin/indent/indent_off_on.c:1.13 --- src/tests/usr.bin/indent/indent_off_on.c:1.12 Sat May 20 10:25:47 2023 +++ src/tests/usr.bin/indent/indent_off_on.c Sun May 21 10:18:44 2023 @@ -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 Index: src/tests/usr.bin/indent/lsym_comment.c diff -u src/tests/usr.bin/indent/lsym_comment.c:1.14 src/tests/usr.bin/indent/lsym_comment.c:1.15 --- src/tests/usr.bin/indent/lsym_comment.c:1.14 Sat May 20 11:19:17 2023 +++ src/tests/usr.bin/indent/lsym_comment.c Sun May 21 10:18:44 2023 @@ -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 Index: src/tests/usr.bin/indent/lsym_form_feed.c diff -u src/tests/usr.bin/indent/lsym_form_feed.c:1.7 src/tests/usr.bin/indent/lsym_form_feed.c:1.8 --- src/tests/usr.bin/indent/lsym_form_feed.c:1.7 Tue May 16 11:32:02 2023 +++ src/tests/usr.bin/indent/lsym_form_feed.c Sun May 21 10:18:44 2023 @@ -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) Index: src/tests/usr.bin/indent/lsym_type_in_parentheses.c diff -u src/tests/usr.bin/indent/lsym_type_in_parentheses.c:1.3 src/tests/usr.bin/indent/lsym_type_in_parentheses.c:1.4 --- src/tests/usr.bin/indent/lsym_type_in_parentheses.c:1.3 Sun Apr 24 09:04:12 2022 +++ src/tests/usr.bin/indent/lsym_type_in_parentheses.c Sun May 21 10:18:44 2023 @@ -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. Index: src/tests/usr.bin/indent/opt_bl_br.c diff -u src/tests/usr.bin/indent/opt_bl_br.c:1.8 src/tests/usr.bin/indent/opt_bl_br.c:1.9 --- src/tests/usr.bin/indent/opt_bl_br.c:1.8 Thu May 11 17:22:56 2023 +++ src/tests/usr.bin/indent/opt_bl_br.c Sun May 21 10:18:44 2023 @@ -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 Index: src/tests/usr.bin/indent/t_errors.sh diff -u src/tests/usr.bin/indent/t_errors.sh:1.29 src/tests/usr.bin/indent/t_errors.sh:1.30 --- src/tests/usr.bin/indent/t_errors.sh:1.29 Sun May 21 09:48:22 2023 +++ src/tests/usr.bin/indent/t_errors.sh Sun May 21 10:18:44 2023 @@ -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) { Index: src/tests/usr.bin/indent/t_options.lua diff -u src/tests/usr.bin/indent/t_options.lua:1.2 src/tests/usr.bin/indent/t_options.lua:1.3 --- src/tests/usr.bin/indent/t_options.lua:1.2 Sat May 20 22:08:07 2023 +++ src/tests/usr.bin/indent/t_options.lua Sun May 21 10:18:44 2023 @@ -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' " Index: src/usr.bin/indent/pr_comment.c diff -u src/usr.bin/indent/pr_comment.c:1.148 src/usr.bin/indent/pr_comment.c:1.149 --- src/usr.bin/indent/pr_comment.c:1.148 Sat May 20 11:53:53 2023 +++ src/usr.bin/indent/pr_comment.c Sun May 21 10:18:44 2023 @@ -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 {