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: replace global variable use_ff with f...



details:   https://anonhg.NetBSD.org/src/rev/f1f962eacbee
branches:  trunk
changeset: 990028:f1f962eacbee
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 24 11:17:05 2021 +0000

description:
indent: replace global variable use_ff with function parameter

diffstat:

 usr.bin/indent/indent.c     |   7 +++----
 usr.bin/indent/indent.h     |   5 ++---
 usr.bin/indent/io.c         |  26 +++++++++++++++++---------
 usr.bin/indent/pr_comment.c |   7 +++----
 4 files changed, 25 insertions(+), 20 deletions(-)

diffs (150 lines):

diff -r 0502d588c0f1 -r f1f962eacbee usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sun Oct 24 11:08:46 2021 +0000
+++ b/usr.bin/indent/indent.c   Sun Oct 24 11:17:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.144 2021/10/20 05:37:21 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.145 2021/10/24 11:17:05 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.144 2021/10/20 05:37:21 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.145 2021/10/24 11:17:05 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -662,8 +662,7 @@
 static void
 process_form_feed(void)
 {
-    ps.use_ff = true;
-    dump_line();
+    dump_line_ff();
     ps.want_blank = false;
 }
 
diff -r 0502d588c0f1 -r f1f962eacbee usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Sun Oct 24 11:08:46 2021 +0000
+++ b/usr.bin/indent/indent.h   Sun Oct 24 11:17:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.43 2021/10/20 05:41:57 rillig Exp $       */
+/*     $NetBSD: indent.h,v 1.44 2021/10/24 11:17:05 rillig Exp $       */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -307,8 +307,6 @@
     bool search_brace;         /* whether it is necessary to buffer up all
                                 * info up to the start of a stmt after an if,
                                 * while, etc */
-    bool use_ff;               /* whether the current line should be
-                                * terminated with a form feed */
     bool want_blank;           /* whether the following token should be
                                 * prefixed by a blank. (Said prefixing is
                                 * ignored in some cases.) */
@@ -353,6 +351,7 @@
 token_type lexi(struct parser_state *);
 void diag(int, const char *, ...)__printflike(2, 3);
 void dump_line(void);
+void dump_line_ff(void);
 void inbuf_read_line(void);
 void parse(token_type);
 void process_comment(void);
diff -r 0502d588c0f1 -r f1f962eacbee usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Sun Oct 24 11:08:46 2021 +0000
+++ b/usr.bin/indent/io.c       Sun Oct 24 11:17:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.100 2021/10/24 10:54:12 rillig Exp $  */
+/*     $NetBSD: io.c,v 1.101 2021/10/24 11:17:05 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.100 2021/10/24 10:54:12 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.101 2021/10/24 11:17:05 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -207,8 +207,8 @@
  * Write a line of formatted source to the output file. The line consists of a
  * label, the code and the comment.
  */
-void
-dump_line(void)
+static void
+output_line(char line_terminator)
 {
     static bool first_line = true;
 
@@ -254,10 +254,7 @@
        if (com.e != com.s)
            dump_line_comment(ind);
 
-       if (ps.use_ff)
-           output_char('\f');
-       else
-           output_char('\n');
+       output_char(line_terminator);
        ps.stats.lines++;
 
        if (ps.just_saw_decl == 1 && opt.blanklines_after_decl) {
@@ -270,7 +267,6 @@
 
     ps.decl_on_line = ps.in_decl;      /* for proper comment indentation */
     ps.ind_stmt = ps.in_stmt && !ps.in_decl;
-    ps.use_ff = false;
     ps.dumped_decl_indent = false;
 
     *(lab.e = lab.s) = '\0';   /* reset buffers */
@@ -289,6 +285,18 @@
     first_line = false;
 }
 
+void
+dump_line(void)
+{
+    output_line('\n');
+}
+
+void
+dump_line_ff(void)
+{
+    output_line('\f');
+}
+
 int
 compute_code_indent(void)
 {
diff -r 0502d588c0f1 -r f1f962eacbee usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c       Sun Oct 24 11:08:46 2021 +0000
+++ b/usr.bin/indent/pr_comment.c       Sun Oct 24 11:17:05 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pr_comment.c,v 1.81 2021/10/24 11:08:46 rillig Exp $   */
+/*     $NetBSD: pr_comment.c,v 1.82 2021/10/24 11:17:05 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.81 2021/10/24 11:08:46 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.82 2021/10/24 11:17:05 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -225,8 +225,7 @@
        switch (*inp.s) {
        case '\f':
            if (may_wrap) {     /* in a text comment, break the line here */
-               ps.use_ff = true;
-               dump_line();
+               dump_line_ff();
                last_blank = -1;
                com_add_delim();
                inp.s++;



Home | Main Index | Thread Index | Old Index