Tue Oct 19 21:39:19 2021 UTC ()
indent: always keep next_blank_lines >= 0

No functional change.


(rillig)
diff -r1.96 -r1.97 src/usr.bin/indent/io.c

cvs diff -r1.96 -r1.97 src/usr.bin/indent/io.c (expand / switch to unified diff)

--- src/usr.bin/indent/io.c 2021/10/19 21:21:07 1.96
+++ src/usr.bin/indent/io.c 2021/10/19 21:39:19 1.97
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: io.c,v 1.96 2021/10/19 21:21:07 rillig Exp $ */ 1/* $NetBSD: io.c,v 1.97 2021/10/19 21:39:19 rillig Exp $ */
2 2
3/*- 3/*-
4 * SPDX-License-Identifier: BSD-4-Clause 4 * SPDX-License-Identifier: BSD-4-Clause
5 * 5 *
6 * Copyright (c) 1985 Sun Microsystems, Inc. 6 * Copyright (c) 1985 Sun Microsystems, Inc.
7 * Copyright (c) 1980, 1993 7 * Copyright (c) 1980, 1993
8 * The Regents of the University of California. All rights reserved. 8 * The Regents of the University of California. All rights reserved.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -33,27 +33,27 @@ @@ -33,27 +33,27 @@
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE. 37 * SUCH DAMAGE.
38 */ 38 */
39 39
40#if 0 40#if 0
41static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93"; 41static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93";
42#endif 42#endif
43 43
44#include <sys/cdefs.h> 44#include <sys/cdefs.h>
45#if defined(__NetBSD__) 45#if defined(__NetBSD__)
46__RCSID("$NetBSD: io.c,v 1.96 2021/10/19 21:21:07 rillig Exp $"); 46__RCSID("$NetBSD: io.c,v 1.97 2021/10/19 21:39:19 rillig Exp $");
47#elif defined(__FreeBSD__) 47#elif defined(__FreeBSD__)
48__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $"); 48__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
49#endif 49#endif
50 50
51#include <ctype.h> 51#include <ctype.h>
52#include <stdio.h> 52#include <stdio.h>
53#include <string.h> 53#include <string.h>
54#include <stdarg.h> 54#include <stdarg.h>
55 55
56#include "indent.h" 56#include "indent.h"
57 57
58static int paren_indent; 58static int paren_indent;
59static bool suppress_blanklines; 59static bool suppress_blanklines;
@@ -225,29 +225,28 @@ dump_line(void) @@ -225,29 +225,28 @@ dump_line(void)
225 225
226 } else if (!inhibit_formatting) { 226 } else if (!inhibit_formatting) {
227 suppress_blanklines = false; 227 suppress_blanklines = false;
228 if (prefix_blankline_requested && !first_line) { 228 if (prefix_blankline_requested && !first_line) {
229 if (opt.swallow_optional_blanklines) { 229 if (opt.swallow_optional_blanklines) {
230 if (next_blank_lines == 1) 230 if (next_blank_lines == 1)
231 next_blank_lines = 0; 231 next_blank_lines = 0;
232 } else { 232 } else {
233 if (next_blank_lines == 0) 233 if (next_blank_lines == 0)
234 next_blank_lines = 1; 234 next_blank_lines = 1;
235 } 235 }
236 } 236 }
237 237
238 while (--next_blank_lines >= 0) 238 for (; next_blank_lines > 0; next_blank_lines--)
239 output_char('\n'); 239 output_char('\n');
240 next_blank_lines = 0; 
241 240
242 if (ps.ind_level == 0) 241 if (ps.ind_level == 0)
243 ps.ind_stmt = false; /* this is a class A kludge. don't do 242 ps.ind_stmt = false; /* this is a class A kludge. don't do
244 * additional statement indentation if 243 * additional statement indentation if
245 * we are at bracket level 0 */ 244 * we are at bracket level 0 */
246 245
247 if (lab.e != lab.s || code.e != code.s) 246 if (lab.e != lab.s || code.e != code.s)
248 ps.stats.code_lines++; 247 ps.stats.code_lines++;
249 248
250 int ind = 0; 249 int ind = 0;
251 if (lab.e != lab.s) 250 if (lab.e != lab.s)
252 ind = dump_line_label(); 251 ind = dump_line_label();
253 if (code.e != code.s) 252 if (code.e != code.s)