Module Name:    src
Committed By:   rillig
Date:           Wed Oct 20 05:14:21 UTC 2021

Modified Files:
        src/tests/usr.bin/indent: opt_bacc.c
        src/usr.bin/indent: indent.c indent.h io.c pr_comment.c

Log Message:
indent: rename blankline_requested variables

The words 'prefix' and 'postfix' sounded too much like horizontal
concepts, like in operators. The actual purpose of these variables is to
add blank lines before and after the current line, so use the same
wording as in the command line options.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/opt_bacc.c
cvs rdiff -u -r1.141 -r1.142 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/indent/io.c
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/indent/pr_comment.c

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_bacc.c
diff -u src/tests/usr.bin/indent/opt_bacc.c:1.3 src/tests/usr.bin/indent/opt_bacc.c:1.4
--- src/tests/usr.bin/indent/opt_bacc.c:1.3	Mon Oct 18 07:11:31 2021
+++ src/tests/usr.bin/indent/opt_bacc.c	Wed Oct 20 05:14:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bacc.c,v 1.3 2021/10/18 07:11:31 rillig Exp $ */
+/* $NetBSD: opt_bacc.c,v 1.4 2021/10/20 05:14:21 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -23,7 +23,7 @@ int		c;
 
 /*
  * XXX: As of 2021-10-05, the option -bacc has no effect on declarations since
- * process_decl resets prefix_blankline_requested unconditionally.
+ * process_decl resets blank_line_before unconditionally.
  */
 #indent run -bacc
 int		a;

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.141 src/usr.bin/indent/indent.c:1.142
--- src/usr.bin/indent/indent.c:1.141	Wed Oct 20 05:07:08 2021
+++ src/usr.bin/indent/indent.c	Wed Oct 20 05:14:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.141 2021/10/20 05:07:08 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.142 2021/10/20 05:14:21 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.141 2021/10/20 05:07:08 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.142 2021/10/20 05:14:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -103,8 +103,8 @@ char *saved_inp_e;
 
 bool found_err;
 int blank_lines_to_output;
-bool prefix_blankline_requested;
-bool postfix_blankline_requested;
+bool blank_line_before;
+bool blank_line_after;
 bool break_comma;
 float case_ind;
 bool had_eof;
@@ -939,7 +939,7 @@ process_lbrace(bool *force_nl, bool *sp_
     }
 
     if (ps.in_parameter_declaration)
-	prefix_blankline_requested = false;
+	blank_line_before = false;
 
     if (ps.p_l_follow > 0) {	/* check for preceding unbalanced parens */
 	diag(1, "Unbalanced parens");
@@ -965,7 +965,7 @@ process_lbrace(bool *force_nl, bool *sp_
 					 * declaration, so don't do special
 					 * indentation of comments */
 	if (opt.blanklines_after_decl_at_top && ps.in_parameter_declaration)
-	    postfix_blankline_requested = true;
+	    blank_line_after = true;
 	ps.in_parameter_declaration = false;
 	ps.in_decl = false;
     }
@@ -1013,14 +1013,14 @@ process_rbrace(bool *sp_sw, int *decl_in
 	ps.in_decl = true;
     }
 
-    prefix_blankline_requested = false;
+    blank_line_before = false;
     parse(rbrace);		/* let parser know about this */
     ps.search_brace = opt.cuddle_else
 	&& ps.p_stack[ps.tos] == if_expr_stmt
 	&& ps.il[ps.tos] >= ps.ind_level;
 
     if (ps.tos <= 1 && opt.blanklines_after_procs && ps.decl_nest <= 0)
-	postfix_blankline_requested = true;
+	blank_line_after = true;
 }
 
 static void
@@ -1080,7 +1080,7 @@ process_decl(int *decl_ind, bool *tabs_t
     if (ps.decl_nest <= 0)
 	ps.just_saw_decl = 2;
 
-    prefix_blankline_requested = false;
+    blank_line_before = false;
 
     int len = (int)buf_len(&token) + 1;
     int ind = ps.ind_level == 0 || ps.decl_nest > 0
@@ -1298,11 +1298,11 @@ process_preprocessing(void)
     }
 
     if (opt.blanklines_around_conditional_compilation) {
-	postfix_blankline_requested = true;
+	blank_line_after = true;
 	blank_lines_to_output = 0;
     } else {
-	postfix_blankline_requested = false;
-	prefix_blankline_requested = false;
+	blank_line_after = false;
+	blank_line_before = false;
     }
 
     /*
@@ -1444,7 +1444,7 @@ main_loop(void)
 
 	case type_def:
 	case storage_class:
-	    prefix_blankline_requested = false;
+	    blank_line_before = false;
 	    goto copy_token;
 
 	case keyword_struct_union_enum:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.39 src/usr.bin/indent/indent.h:1.40
--- src/usr.bin/indent/indent.h:1.39	Wed Oct 20 05:00:37 2021
+++ src/usr.bin/indent/indent.h	Wed Oct 20 05:14:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.39 2021/10/20 05:00:37 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.40 2021/10/20 05:14:21 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -237,8 +237,8 @@ enum keyword_kind {
 
 extern bool found_err;
 extern int blank_lines_to_output;
-extern bool prefix_blankline_requested;
-extern bool postfix_blankline_requested;
+extern bool blank_line_before;
+extern bool blank_line_after;
 extern bool break_comma;	/* when true and not in parens, break after a
 				 * comma */
 extern float case_ind;		/* indentation level to be used for a "case

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.98 src/usr.bin/indent/io.c:1.99
--- src/usr.bin/indent/io.c:1.98	Wed Oct 20 05:00:37 2021
+++ src/usr.bin/indent/io.c	Wed Oct 20 05:14:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.98 2021/10/20 05:00:37 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.99 2021/10/20 05:14:21 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.98 2021/10/20 05:00:37 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.99 2021/10/20 05:14:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -225,7 +225,7 @@ dump_line(void)
 
     } else if (!inhibit_formatting) {
 	suppress_blanklines = false;
-	if (prefix_blankline_requested && !first_line) {
+	if (blank_line_before && !first_line) {
 	    if (opt.swallow_optional_blanklines) {
 		if (blank_lines_to_output == 1)
 		    blank_lines_to_output = 0;
@@ -261,11 +261,11 @@ dump_line(void)
 	ps.stats.lines++;
 
 	if (ps.just_saw_decl == 1 && opt.blanklines_after_decl) {
-	    prefix_blankline_requested = true;
+	    blank_line_before = true;
 	    ps.just_saw_decl = 0;
 	} else
-	    prefix_blankline_requested = postfix_blankline_requested;
-	postfix_blankline_requested = false;
+	    blank_line_before = blank_line_after;
+	blank_line_after = false;
     }
 
     ps.decl_on_line = ps.in_decl;	/* for proper comment indentation */
@@ -388,8 +388,8 @@ parse_indent_comment(void)
     inhibit_formatting = !on;
     if (on) {
 	blank_lines_to_output = 0;
-	postfix_blankline_requested = false;
-	prefix_blankline_requested = false;
+	blank_line_after = false;
+	blank_line_before = false;
 	suppress_blanklines = true;
     }
 }

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.79 src/usr.bin/indent/pr_comment.c:1.80
--- src/usr.bin/indent/pr_comment.c:1.79	Thu Oct 14 20:23:43 2021
+++ src/usr.bin/indent/pr_comment.c	Wed Oct 20 05:14:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.79 2021/10/14 20:23:43 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.80 2021/10/20 05:14:21 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.79 2021/10/14 20:23:43 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.80 2021/10/20 05:14:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -213,7 +213,7 @@ process_comment(void)
 	com.e = com.s + 2;
 	*com.e = '\0';
 	if (opt.blanklines_before_block_comments && ps.last_token != lbrace)
-	    prefix_blankline_requested = true;
+	    blank_line_before = true;
 	dump_line();
 	com.e = com.s = t;
 	com_add_delim();

Reply via email to