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: do not report broken lines, report co...



details:   https://anonhg.NetBSD.org/src/rev/bfbe023bf6d9
branches:  trunk
changeset: 376229:bfbe023bf6d9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jun 05 10:12:21 2023 +0000

description:
indent: do not report broken lines, report configuration on stderr

diffstat:

 tests/usr.bin/indent/opt_v.c   |  16 +++++-----------
 tests/usr.bin/indent/t_misc.sh |   8 ++++----
 usr.bin/indent/args.c          |   6 +++---
 usr.bin/indent/indent.1        |   6 +++---
 usr.bin/indent/indent.c        |  21 +++++----------------
 usr.bin/indent/indent.h        |   5 ++---
 6 files changed, 22 insertions(+), 40 deletions(-)

diffs (214 lines):

diff -r 7f586f741042 -r bfbe023bf6d9 tests/usr.bin/indent/opt_v.c
--- a/tests/usr.bin/indent/opt_v.c      Mon Jun 05 09:41:40 2023 +0000
+++ b/tests/usr.bin/indent/opt_v.c      Mon Jun 05 10:12:21 2023 +0000
@@ -1,18 +1,12 @@
-/* $NetBSD: opt_v.c,v 1.12 2023/05/12 10:53:33 rillig Exp $ */
+/* $NetBSD: opt_v.c,v 1.13 2023/06/05 10:12:21 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.
+ * The option '-v' enables verbose mode.
  *
  * 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.
+ * in this mode.
  */
 
 //indent input
@@ -25,10 +19,10 @@ example(void)
        printf("A very long message template with %d arguments: %s, %s, %s", 3, "first", "second", "third");
 }
 
-/* $ The below comment is neither counted nor formatted. */
+// $ Indent does not format comments in preprocessing lines.
 #define macro1 /* prefix */ suffix
 
-/* $ The below comment is formatted and counted. */
+// $ Indent does not format comments in preprocessing lines.
 #define macro2 prefix /* suffix */
 //indent end
 
diff -r 7f586f741042 -r bfbe023bf6d9 tests/usr.bin/indent/t_misc.sh
--- a/tests/usr.bin/indent/t_misc.sh    Mon Jun 05 09:41:40 2023 +0000
+++ b/tests/usr.bin/indent/t_misc.sh    Mon Jun 05 10:12:21 2023 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_misc.sh,v 1.26 2023/06/05 07:23:03 rillig Exp $
+# $NetBSD: t_misc.sh,v 1.27 2023/06/05 10:12:21 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -81,7 +81,7 @@ verbose_profile_body()
        cat <<-\EOF > after.c.exp
                int             decl;
        EOF
-       cat <<-\EOF > stdout.exp
+       cat <<-\EOF > stderr.exp
                profile: -fc1
                profile: -bacc
                profile: -v
@@ -96,7 +96,7 @@ verbose_profile_body()
        # is listed because when running ATF, $HOME equals $PWD.
 
        atf_check \
-           -o 'file:stdout.exp' \
+           -e 'file:stderr.exp' \
            "$indent" -v before.c after.c
        atf_check \
             -o 'file:after.c.exp' \
@@ -401,7 +401,7 @@ opt_v_break_line_body()
 {
        printf '%s\n' 'int *function(void)' '{}' > code.c
 
-       atf_check -o 'ignore' -e 'inline:warning: code.c:2: Line broken\n' \
+       atf_check -o 'ignore' \
            "$indent" -v code.c -st
 }
 
diff -r 7f586f741042 -r bfbe023bf6d9 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c     Mon Jun 05 09:41:40 2023 +0000
+++ b/usr.bin/indent/args.c     Mon Jun 05 10:12:21 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: args.c,v 1.81 2023/06/05 07:35:05 rillig Exp $ */
+/*     $NetBSD: args.c,v 1.82 2023/06/05 10:12:21 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: args.c,v 1.81 2023/06/05 07:35:05 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.82 2023/06/05 10:12:21 rillig Exp $");
 
 /* Read options from profile files and from the command line. */
 
@@ -290,7 +290,7 @@ load_profile(const char *fname, bool mus
                if (n > 0) {
                        buf[n] = '\0';
                        if (opt.verbose)
-                               printf("profile: %s\n", buf);
+                               fprintf(stderr, "profile: %s\n", buf);
                        set_option(buf, fname);
                } else if (ch == EOF)
                        break;
diff -r 7f586f741042 -r bfbe023bf6d9 usr.bin/indent/indent.1
--- a/usr.bin/indent/indent.1   Mon Jun 05 09:41:40 2023 +0000
+++ b/usr.bin/indent/indent.1   Mon Jun 05 10:12:21 2023 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: indent.1,v 1.31 2023/05/12 11:01:11 rillig Exp $
+.\"    $NetBSD: indent.1,v 1.32 2023/06/05 10:12:21 rillig Exp $
 .\"
 .\" Copyright (c) 1980, 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"    @(#)indent.1    8.1 (Berkeley) 7/1/93
 .\" $FreeBSD: head/usr.bin/indent/indent.1 334944 2018-06-11 05:35:57Z pstef $
 .\"
-.Dd May 12, 2023
+.Dd June 5, 2023
 .Dt INDENT 1
 .Os
 .Sh NAME
@@ -491,7 +491,7 @@ turns on `verbose' mode;
 turns it off.
 When in verbose mode,
 .Nm
-reports when it splits one line of input into two or more lines of output.
+reports its configuration on the standard error output.
 The default is
 .Fl \&nv .
 .It Fl -version
diff -r 7f586f741042 -r bfbe023bf6d9 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Mon Jun 05 09:41:40 2023 +0000
+++ b/usr.bin/indent/indent.c   Mon Jun 05 10:12:21 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.332 2023/06/05 09:41:40 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.333 2023/06/05 10:12:21 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.332 2023/06/05 09:41:40 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.333 2023/06/05 10:12:21 rillig Exp $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -393,8 +393,6 @@ maybe_break_line(lexer_symbol lsym)
            && ps.prev_lsym != lsym_lbrace)
                return;
 
-       if (opt.verbose)
-               diag(0, "Line broken");
        output_line();
        ps.force_nl = false;
 }
@@ -810,11 +808,8 @@ process_rbrace(void)
        if (ps.block_init_level > 0)
                ps.block_init_level--;
 
-       if (code.len > 0 && !ps.block_init) {
-               if (opt.verbose)
-                       diag(0, "Line broken");
+       if (code.len > 0 && !ps.block_init)
                output_line();
-       }
 
        buf_add_char(&code, '}');
        ps.want_blank = true;
@@ -848,11 +843,8 @@ process_do(void)
        ps.in_stmt_or_decl = false;
        ps.in_decl = false;
 
-       if (code.len > 0) {     /* make sure this starts a line */
-               if (opt.verbose)
-                       diag(0, "Line broken");
+       if (code.len > 0)
                output_line();
-       }
 
        ps.force_nl = true;
        parse(psym_do);
@@ -864,11 +856,8 @@ process_else(void)
        ps.in_stmt_or_decl = false;
 
        if (code.len > 0
-           && !(opt.cuddle_else && code.s[code.len - 1] == '}')) {
-               if (opt.verbose)
-                       diag(0, "Line broken");
+           && !(opt.cuddle_else && code.s[code.len - 1] == '}'))
                output_line();
-       }
 
        ps.force_nl = true;
        parse(psym_else);
diff -r 7f586f741042 -r bfbe023bf6d9 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Mon Jun 05 09:41:40 2023 +0000
+++ b/usr.bin/indent/indent.h   Mon Jun 05 10:12:21 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.172 2023/06/05 07:35:05 rillig Exp $      */
+/*     $NetBSD: indent.h,v 1.173 2023/06/05 10:12:21 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -243,8 +243,7 @@ extern struct options {
        int max_line_length;
        bool use_tabs;          /* set true to use tabs for spacing, false uses
                                 * all spaces */
-       bool verbose;           /* whether non-essential error messages are
-                                * printed */
+       bool verbose;           /* print configuration to stderr */
 } opt;
 
 extern bool found_err;



Home | Main Index | Thread Index | Old Index