Module Name: src
Committed By: rillig
Date: Fri Oct 8 16:47:42 UTC 2021
Modified Files:
src/usr.bin/indent: indent.c
Log Message:
indent: split process_keyword_do_else into separate functions
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/usr.bin/indent/indent.c
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.126 src/usr.bin/indent/indent.c:1.127
--- src/usr.bin/indent/indent.c:1.126 Fri Oct 8 16:20:33 2021
+++ src/usr.bin/indent/indent.c Fri Oct 8 16:47:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.126 2021/10/08 16:20:33 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.127 2021/10/08 16:47:42 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.126 2021/10/08 16:20:33 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.127 2021/10/08 16:47:42 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -965,34 +965,37 @@ process_rbrace(bool *sp_sw, int *decl_in
}
static void
-process_keyword_do_else(bool *force_nl, bool *last_else)
+process_keyword_do(bool *force_nl, bool *last_else)
{
ps.in_stmt = false;
- if (*token.s == 'e') {
- 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 */
- ps.want_blank = false;
- }
+ if (code.e != code.s) { /* make sure this starts a line */
+ if (opt.verbose)
+ diag(0, "Line broken");
+ dump_line();
+ ps.want_blank = false;
+ }
- *force_nl = true; /* following stuff must go onto new line */
- *last_else = true;
- parse(keyword_else);
+ *force_nl = true; /* following stuff must go onto new line */
+ *last_else = false;
+ parse(keyword_do);
+}
- } else {
- if (code.e != code.s) { /* make sure this starts a line */
- if (opt.verbose)
- diag(0, "Line broken");
- dump_line();
- ps.want_blank = false;
- }
+static void
+process_keyword_else(bool *force_nl, bool *last_else)
+{
+ ps.in_stmt = false;
- *force_nl = true; /* following stuff must go onto new line */
- *last_else = false;
- parse(keyword_do);
+ 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 */
+ ps.want_blank = false;
}
+
+ *force_nl = true; /* following stuff must go onto new line */
+ *last_else = true;
+ parse(keyword_else);
}
static void
@@ -1378,7 +1381,10 @@ main_loop(void)
goto copy_token;
case keyword_do_else:
- process_keyword_do_else(&force_nl, &last_else);
+ if (*token.s == 'd')
+ process_keyword_do(&force_nl, &last_else);
+ else
+ process_keyword_else(&force_nl, &last_else);
goto copy_token;
case type_def: