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: clean up copy_comment_nowrap
details: https://anonhg.NetBSD.org/src/rev/36db9563b5c1
branches: trunk
changeset: 1024831:36db9563b5c1
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 07 10:17:39 2021 +0000
description:
indent: clean up copy_comment_nowrap
The action for '\f' was the same as the default action.
Replacing 'switch' with 'if' makes the code shorter.
No functional change.
diffstat:
usr.bin/indent/pr_comment.c | 23 +++++++----------------
1 files changed, 7 insertions(+), 16 deletions(-)
diffs (60 lines):
diff -r 854d832f943c -r 36db9563b5c1 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c Sun Nov 07 10:13:26 2021 +0000
+++ b/usr.bin/indent/pr_comment.c Sun Nov 07 10:17:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.103 2021/11/07 10:13:26 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.104 2021/11/07 10:17:39 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.103 2021/11/07 10:13:26 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.104 2021/11/07 10:17:39 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -333,13 +333,7 @@
copy_comment_nowrap(void)
{
for (;;) {
- switch (*inp.s) {
- case '\f':
- inp_skip();
- com_add_char('\f');
- break;
-
- case '\n':
+ if (*inp.s == '\n') {
if (token.e[-1] == '/')
goto end_of_line_comment;
@@ -354,9 +348,10 @@
dump_line();
++line_no;
inp_skip();
- break; /* end of case for newline */
+ continue;
+ }
- case '*':
+ if (*inp.s == '*') {
inp_skip();
if (*inp.s == '/' && token.e[-1] == '*') {
inp_skip();
@@ -372,12 +367,8 @@
} else /* handle isolated '*' */
com_add_char('*');
- break;
-
- default:
+ } else
com_add_char(inp_next());
- break;
- }
}
}
Home |
Main Index |
Thread Index |
Old Index