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: use standard error handling for unter...



details:   https://anonhg.NetBSD.org/src/rev/20ff00179bd8
branches:  trunk
changeset: 1024066:20ff00179bd8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 08 22:27:52 2021 +0000

description:
indent: use standard error handling for unterminated comment

Just writing it to stdout is bad, especially when indent is used in
filter mode. Silently continuing after such an error is bad as well.

echo '/*' | indent

diffstat:

 usr.bin/indent/pr_comment.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 66201e9ead9f -r 20ff00179bd8 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c       Fri Oct 08 22:22:14 2021 +0000
+++ b/usr.bin/indent/pr_comment.c       Fri Oct 08 22:27:52 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pr_comment.c,v 1.66 2021/10/08 22:22:14 rillig Exp $   */
+/*     $NetBSD: pr_comment.c,v 1.67 2021/10/08 22:27:52 rillig Exp $   */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.66 2021/10/08 22:22:14 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.67 2021/10/08 22:27:52 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -226,7 +226,7 @@
                goto end_of_line_comment;
 
            if (had_eof) {
-               printf("Unterminated comment\n");
+               diag(1, "Unterminated comment");
                dump_line();
                return;
            }



Home | Main Index | Thread Index | Old Index