Module Name:    src
Committed By:   rillig
Date:           Mon Jun  5 10:12:21 UTC 2023

Modified Files:
        src/tests/usr.bin/indent: opt_v.c t_misc.sh
        src/usr.bin/indent: args.c indent.1 indent.c indent.h

Log Message:
indent: do not report broken lines, report configuration on stderr


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/opt_v.c
cvs rdiff -u -r1.26 -r1.27 src/tests/usr.bin/indent/t_misc.sh
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/indent/args.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/indent/indent.1
cvs rdiff -u -r1.332 -r1.333 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.172 -r1.173 src/usr.bin/indent/indent.h

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.12 src/tests/usr.bin/indent/opt_v.c:1.13
--- src/tests/usr.bin/indent/opt_v.c:1.12	Fri May 12 10:53:33 2023
+++ src/tests/usr.bin/indent/opt_v.c	Mon Jun  5 10:12:21 2023
@@ -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
 

Index: src/tests/usr.bin/indent/t_misc.sh
diff -u src/tests/usr.bin/indent/t_misc.sh:1.26 src/tests/usr.bin/indent/t_misc.sh:1.27
--- src/tests/usr.bin/indent/t_misc.sh:1.26	Mon Jun  5 07:23:03 2023
+++ src/tests/usr.bin/indent/t_misc.sh	Mon Jun  5 10:12:21 2023
@@ -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
 }
 

Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.81 src/usr.bin/indent/args.c:1.82
--- src/usr.bin/indent/args.c:1.81	Mon Jun  5 07:35:05 2023
+++ src/usr.bin/indent/args.c	Mon Jun  5 10:12:21 2023
@@ -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;

Index: src/usr.bin/indent/indent.1
diff -u src/usr.bin/indent/indent.1:1.31 src/usr.bin/indent/indent.1:1.32
--- src/usr.bin/indent/indent.1:1.31	Fri May 12 11:01:11 2023
+++ src/usr.bin/indent/indent.1	Mon Jun  5 10:12:21 2023
@@ -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

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.332 src/usr.bin/indent/indent.c:1.333
--- src/usr.bin/indent/indent.c:1.332	Mon Jun  5 09:41:40 2023
+++ src/usr.bin/indent/indent.c	Mon Jun  5 10:12:21 2023
@@ -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);

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.172 src/usr.bin/indent/indent.h:1.173
--- src/usr.bin/indent/indent.h:1.172	Mon Jun  5 07:35:05 2023
+++ src/usr.bin/indent/indent.h	Mon Jun  5 10:12:21 2023
@@ -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;

Reply via email to