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: make reformatting of comments simpler
details: https://anonhg.NetBSD.org/src/rev/5c37897ae520
branches: trunk
changeset: 990419:5c37897ae520
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Oct 26 21:04:03 2021 +0000
description:
indent: make reformatting of comments simpler
No functional change.
diffstat:
usr.bin/indent/pr_comment.c | 26 ++++++--------------------
1 files changed, 6 insertions(+), 20 deletions(-)
diffs (52 lines):
diff -r c4f0863c4fbb -r 5c37897ae520 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c Tue Oct 26 20:44:45 2021 +0000
+++ b/usr.bin/indent/pr_comment.c Tue Oct 26 21:04:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.84 2021/10/25 00:54:37 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.85 2021/10/26 21:04:03 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.84 2021/10/25 00:54:37 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.85 2021/10/26 21:04:03 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -342,29 +342,15 @@
break;
}
- com_terminate(); /* mark the end of the last word */
+ const char *last_word_s = com.buf + last_blank + 1;
+ size_t last_word_len = (size_t)(com.e - last_word_s);
com.e = com.buf + last_blank;
dump_line();
-
com_add_delim();
- const char *p = com.buf + last_blank + 1;
- while (is_hspace(*p))
- p++;
+ memcpy(com.e, last_word_s, last_word_len);
+ com.e += last_word_len;
last_blank = -1;
-
- /*
- * p still points to the last word from the previous line, in
- * the same buffer that it is copied to, but to the right of
- * the writing region [com.s, com.e). Calling dump_line only
- * moved com.e back to com.s, it did not clear the contents of
- * the buffer. This ensures that the buffer is already large
- * enough.
- */
- while (*p != '\0') {
- assert(!is_hspace(*p));
- *com.e++ = *p++;
- }
}
break;
}
Home |
Main Index |
Thread Index |
Old Index