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 simpler code for copying the inpu...



details:   https://anonhg.NetBSD.org/src/rev/2b4acdf434e8
branches:  trunk
changeset: 1024340:2b4acdf434e8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Oct 19 21:21:07 2021 +0000

description:
indent: use simpler code for copying the input buffer

In debug mode, this reduces the amount of debug output lines.

No functional change in default mode.

diffstat:

 tests/usr.bin/indent/indent_off_on.c |  20 +++++++++++++++++++-
 usr.bin/indent/io.c                  |  10 ++++------
 2 files changed, 23 insertions(+), 7 deletions(-)

diffs (65 lines):

diff -r db638b7d9603 -r 2b4acdf434e8 tests/usr.bin/indent/indent_off_on.c
--- a/tests/usr.bin/indent/indent_off_on.c      Tue Oct 19 20:41:42 2021 +0000
+++ b/tests/usr.bin/indent/indent_off_on.c      Tue Oct 19 21:21:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent_off_on.c,v 1.2 2021/10/19 20:41:42 rillig Exp $ */
+/* $NetBSD: indent_off_on.c,v 1.3 2021/10/19 21:21:07 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -33,6 +33,24 @@
 
 #indent input
 {}
+
+
+/*INDENT OFF*/
+/*INDENT ON*/
+#indent end
+
+#indent run
+{
+}
+/* $ FIXME: This empty line must stay. */
+/* $ FIXME: This empty line must stay. */
+/*INDENT OFF*/
+/* INDENT ON */
+#indent end
+
+
+#indent input
+{}
  /* INDENT OFF */
  /* INDENT ON */
 {}
diff -r db638b7d9603 -r 2b4acdf434e8 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Tue Oct 19 20:41:42 2021 +0000
+++ b/usr.bin/indent/io.c       Tue Oct 19 21:21:07 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.95 2021/10/19 18:29:59 rillig Exp $   */
+/*     $NetBSD: io.c,v 1.96 2021/10/19 21:21:07 rillig Exp $   */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.95 2021/10/19 18:29:59 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.96 2021/10/19 21:21:07 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -451,10 +451,8 @@
            parse_indent_comment();
     }
 
-    if (inhibit_formatting) {
-       for (p = inp.s; p < inp.e; p++)
-           output_char(*p);
-    }
+    if (inhibit_formatting)
+       output_range(inp.s, inp.e);
 }
 
 int



Home | Main Index | Thread Index | Old Index