indent: remove statistics

The numbers from the statistics were wrong.
This commit is contained in:
rillig 2023-05-12 10:53:33 +00:00
parent 350d0ac436
commit 0cdf93c9f3
6 changed files with 18 additions and 78 deletions

View File

@ -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

View File

@ -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

View File

@ -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.17 (Berkeley) 6/7/93";
#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);
}

View File

@ -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;

View File

@ -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 (Berkeley) 6/6/93";
#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_terminator)
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_terminator)
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)

View File

@ -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 8.1 (Berkeley) 6/6/93";
#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);