Module Name:    src
Committed By:   rillig
Date:           Sun Nov  7 14:00:35 UTC 2021

Modified Files:
        src/usr.bin/indent: indent.c indent.h

Log Message:
indent: reduce negations in process_else, clean up comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/indent/indent.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.213 src/usr.bin/indent/indent.c:1.214
--- src/usr.bin/indent/indent.c:1.213	Sun Nov  7 13:30:15 2021
+++ src/usr.bin/indent/indent.c	Sun Nov  7 14:00:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.213 2021/11/07 13:30:15 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.214 2021/11/07 14:00:35 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.213 2021/11/07 13:30:15 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.214 2021/11/07 14:00:35 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -484,7 +484,7 @@ search_stmt(lexer_symbol *lsym, bool *fo
 	    if (search_stmt_lbrace())
 		goto switch_buffer;
 	    /* FALLTHROUGH */
-	default:		/* it is the start of a normal statement */
+	default:
 	    if (!search_stmt_other(*lsym, force_nl, comment_buffered,
 		    *last_else))
 		return;
@@ -1105,7 +1105,7 @@ process_else(bool *force_nl, bool *last_
 {
     ps.in_stmt = false;
 
-    if (code.e > code.s && (!opt.cuddle_else || code.e[-1] != '}')) {
+    if (code.e > code.s && !(opt.cuddle_else && code.e[-1] == '}')) {
 	if (opt.verbose)
 	    diag(0, "Line broken");
 	dump_line();		/* make sure this starts a line */

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.83 src/usr.bin/indent/indent.h:1.84
--- src/usr.bin/indent/indent.h:1.83	Sun Nov  7 13:43:11 2021
+++ src/usr.bin/indent/indent.h	Sun Nov  7 14:00:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.83 2021/11/07 13:43:11 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.84 2021/11/07 14:00:35 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -263,7 +263,8 @@ extern bool inhibit_formatting;	/* true 
 #define	STACKSIZE 256
 
 extern struct parser_state {
-    lexer_symbol prev_token;
+    lexer_symbol prev_token;	/* the previous token, but never comment,
+				 * newline or preprocessing line */
     bool curr_col_1;		/* whether the current token started in column
 				 * 1 of the unformatted input */
     bool next_col_1;

Reply via email to