Module Name: src Committed By: rillig Date: Fri May 12 10:53:33 UTC 2023
Modified Files: src/tests/usr.bin/indent: opt_v.c t_misc.sh src/usr.bin/indent: indent.c indent.h io.c pr_comment.c Log Message: indent: remove statistics The numbers from the statistics were wrong. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/indent/opt_v.c cvs rdiff -u -r1.21 -r1.22 src/tests/usr.bin/indent/t_misc.sh cvs rdiff -u -r1.253 -r1.254 src/usr.bin/indent/indent.c cvs rdiff -u -r1.120 -r1.121 src/usr.bin/indent/indent.h cvs rdiff -u -r1.154 -r1.155 src/usr.bin/indent/io.c cvs rdiff -u -r1.129 -r1.130 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/opt_v.c diff -u src/tests/usr.bin/indent/opt_v.c:1.11 src/tests/usr.bin/indent/opt_v.c:1.12 --- src/tests/usr.bin/indent/opt_v.c:1.11 Thu May 11 19:01:35 2023 +++ src/tests/usr.bin/indent/opt_v.c Fri May 12 10:53:33 2023 @@ -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 Index: src/tests/usr.bin/indent/t_misc.sh diff -u src/tests/usr.bin/indent/t_misc.sh:1.21 src/tests/usr.bin/indent/t_misc.sh:1.22 --- src/tests/usr.bin/indent/t_misc.sh:1.21 Thu May 11 09:28:53 2023 +++ src/tests/usr.bin/indent/t_misc.sh Fri May 12 10:53:33 2023 @@ -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 Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.253 src/usr.bin/indent/indent.c:1.254 --- src/usr.bin/indent/indent.c:1.253 Fri May 12 08:40:54 2023 +++ src/usr.bin/indent/indent.c Fri May 12 10:53:33 2023 @@ -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); } Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.120 src/usr.bin/indent/indent.h:1.121 --- src/usr.bin/indent/indent.h:1.120 Fri May 12 08:40:54 2023 +++ src/usr.bin/indent/indent.h Fri May 12 10:53:33 2023 @@ -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; Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.154 src/usr.bin/indent/io.c:1.155 --- src/usr.bin/indent/io.c:1.154 Thu May 11 19:14:54 2023 +++ src/usr.bin/indent/io.c Fri May 12 10:53:33 2023 @@ -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) Index: src/usr.bin/indent/pr_comment.c diff -u src/usr.bin/indent/pr_comment.c:1.129 src/usr.bin/indent/pr_comment.c:1.130 --- src/usr.bin/indent/pr_comment.c:1.129 Thu May 11 18:13:55 2023 +++ src/usr.bin/indent/pr_comment.c Fri May 12 10:53:33 2023 @@ -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);