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: remove statistics
details: https://anonhg.NetBSD.org/src/rev/0e167f025d17
branches: trunk
changeset: 374779:0e167f025d17
user: rillig <rillig%NetBSD.org@localhost>
date: Fri May 12 10:53:33 2023 +0000
description:
indent: remove statistics
The numbers from the statistics were wrong.
diffstat:
tests/usr.bin/indent/opt_v.c | 57 +++++++----------------------------------
tests/usr.bin/indent/t_misc.sh | 4 +--
usr.bin/indent/indent.c | 11 +------
usr.bin/indent/indent.h | 9 +-----
usr.bin/indent/io.c | 10 +-----
usr.bin/indent/pr_comment.c | 5 +--
6 files changed, 18 insertions(+), 78 deletions(-)
diffs (245 lines):
diff -r c22183b553b4 -r 0e167f025d17 tests/usr.bin/indent/opt_v.c
--- a/tests/usr.bin/indent/opt_v.c Fri May 12 10:13:37 2023 +0000
+++ b/tests/usr.bin/indent/opt_v.c Fri May 12 10:53:33 2023 +0000
@@ -1,16 +1,20 @@
-/* $NetBSD: opt_v.c,v 1.11 2023/05/11 19:01:35 rillig Exp $ */
+/* $NetBSD: opt_v.c,v 1.12 2023/05/12 10:53:33 rillig Exp $ */
/*
* Tests for the options '-v' and '-nv'.
*
* The option '-v' enables verbose mode. It outputs some information about
- * what's going on under the hood, especially when lines are broken. It also
- * outputs a few statistics about line counts and comments at the end.
+ * what's going on under the hood, especially when lines are broken.
*
* The option '-nv' disables verbose mode. Only errors and warnings are output
* in this mode, but no progress messages.
*/
+/*
+ * XXX: It's rather strange that -v writes to stdout, even in filter mode.
+ * This output belongs on stderr instead.
+ */
+
//indent input
/*
* A block comment.
@@ -41,8 +45,6 @@ example(void)
#define macro1 /* prefix */ suffix
#define macro2 prefix /* suffix */
-There were 12 output lines and 1 comments
-(Lines with comments)/(Lines with code): 0.429
//indent end
@@ -67,34 +69,9 @@ example(void)
//indent end
-//indent input
-/* Demonstrates line number counting in verbose mode. */
-
-int *function(void)
-{
-}
-//indent end
-
-//indent run -v
-/* Demonstrates line number counting in verbose mode. */
-
-int *
-function(void)
-{
-}
-There were 6 output lines and 1 comments
-(Lines with comments)/(Lines with code): 0.250
-//indent end
-/* In the above output, the '5' means 5 non-empty lines. */
-
/*
- * XXX: It's rather strange that -v writes to stdout, even in filter mode.
- * This output belongs on stderr instead.
- */
-
-
-/*
- * Test line counting in preprocessor directives.
+ * Before 2023-05-12, indent wrote some wrong statistics to stdout, in which
+ * the line numbers were counted wrong.
*/
//indent input
#if 0
@@ -106,18 +83,4 @@ int line = 5;
#endif
//indent end
-//indent run -v -di0
-#if 0
-int line = 1;
-int line = 2;
-int line = 3;
-#else
-int line = 5;
-#endif
-There were 3 output lines and 0 comments
-(Lines with comments)/(Lines with code): 0.000
-//indent end
-/*
- * FIXME: The lines within the conditional compilation directives must be
- * counted as well. TODO: Move stats out of parser_state.
- */
+//indent run-equals-input -v -di0
diff -r c22183b553b4 -r 0e167f025d17 tests/usr.bin/indent/t_misc.sh
--- a/tests/usr.bin/indent/t_misc.sh Fri May 12 10:13:37 2023 +0000
+++ b/tests/usr.bin/indent/t_misc.sh Fri May 12 10:53:33 2023 +0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# $NetBSD: t_misc.sh,v 1.21 2023/05/11 09:28:53 rillig Exp $
+# $NetBSD: t_misc.sh,v 1.22 2023/05/12 10:53:33 rillig Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -86,8 +86,6 @@ verbose_profile_body()
profile: -bacc
profile: -v
profile: -fc1
- There were 1 output lines and 0 comments
- (Lines with comments)/(Lines with code): 0.000
EOF
# The code in args.c function set_profile suggests that options from
diff -r c22183b553b4 -r 0e167f025d17 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Fri May 12 10:13:37 2023 +0000
+++ b/usr.bin/indent/indent.c Fri May 12 10:53:33 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.253 2023/05/12 08:40:54 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.254 2023/05/12 10:53:33 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c 5.1
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.253 2023/05/12 08:40:54 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.254 2023/05/12 10:53:33 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -389,13 +389,6 @@ process_eof(void)
if (ps.tos > 1) /* check for balanced braces */
diag(1, "Stuff missing from end of file");
- if (opt.verbose) {
- printf("There were %d output lines and %d comments\n",
- ps.stats.lines, ps.stats.comments);
- printf("(Lines with comments)/(Lines with code): %6.3f\n",
- (1.0 * ps.stats.comment_lines) / ps.stats.code_lines);
- }
-
fflush(output);
exit(found_err ? EXIT_FAILURE : EXIT_SUCCESS);
}
diff -r c22183b553b4 -r 0e167f025d17 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Fri May 12 10:13:37 2023 +0000
+++ b/usr.bin/indent/indent.h Fri May 12 10:53:33 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.120 2023/05/12 08:40:54 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.121 2023/05/12 10:53:33 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -342,13 +342,6 @@ extern struct parser_state {
int quest_level; /* when this is positive, we have seen a '?'
* without the matching ':' in a '?:'
* expression */
-
- struct {
- int comments;
- int lines;
- int code_lines;
- int comment_lines;
- } stats;
} ps;
diff -r c22183b553b4 -r 0e167f025d17 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c Fri May 12 10:13:37 2023 +0000
+++ b/usr.bin/indent/io.c Fri May 12 10:53:33 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.154 2023/05/11 19:14:54 rillig Exp $ */
+/* $NetBSD: io.c,v 1.155 2023/05/12 10:53:33 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c 8.1 (Be
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.154 2023/05/11 19:14:54 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.155 2023/05/12 10:53:33 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -263,7 +263,6 @@ output_line_comment(int ind)
if (ind > target_ind) {
output_char('\n');
ind = 0;
- ps.stats.lines++;
}
while (com.e > p && ch_isspace(com.e[-1]))
@@ -273,7 +272,6 @@ output_line_comment(int ind)
output_range(p, com.e);
ps.comment_delta = ps.n_comment_delta;
- ps.stats.comment_lines++;
}
/*
@@ -289,9 +287,6 @@ output_complete_line(char line_terminato
if (ps.ind_level == 0)
ps.in_stmt_cont = false; /* this is a class A kludge */
- if (lab.e != lab.s || code.e != code.s)
- ps.stats.code_lines++;
-
int ind = 0;
if (lab.e != lab.s)
ind = output_line_label();
@@ -301,7 +296,6 @@ output_complete_line(char line_terminato
output_line_comment(ind);
output_char(line_terminator);
- ps.stats.lines++;
/* TODO: rename to blank_line_after_decl */
if (ps.just_saw_decl == 1 && opt.blanklines_after_decl)
diff -r c22183b553b4 -r 0e167f025d17 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c Fri May 12 10:13:37 2023 +0000
+++ b/usr.bin/indent/pr_comment.c Fri May 12 10:53:33 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.129 2023/05/11 18:13:55 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.130 2023/05/12 10:53:33 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.129 2023/05/11 18:13:55 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.130 2023/05/12 10:53:33 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -355,7 +355,6 @@ process_comment(void)
bool may_wrap, break_delim;
ps.just_saw_decl = 0;
- ps.stats.comments++;
int saved_just_saw_decl = ps.just_saw_decl;
analyze_comment(&may_wrap, &break_delim, &adj_max_line_length);
Home |
Main Index |
Thread Index |
Old Index