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: improve heuristics for '*' as pointer...
details: https://anonhg.NetBSD.org/src/rev/e24af97cf7cd
branches: trunk
changeset: 376635:e24af97cf7cd
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Jun 26 20:23:40 2023 +0000
description:
indent: improve heuristics for '*' as pointer in for loops
diffstat:
tests/usr.bin/indent/lsym_for.c | 17 ++---------------
usr.bin/indent/lexi.c | 10 ++++++++--
2 files changed, 10 insertions(+), 17 deletions(-)
diffs (59 lines):
diff -r 50b898ef947b -r e24af97cf7cd tests/usr.bin/indent/lsym_for.c
--- a/tests/usr.bin/indent/lsym_for.c Mon Jun 26 20:10:23 2023 +0000
+++ b/tests/usr.bin/indent/lsym_for.c Mon Jun 26 20:23:40 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_for.c,v 1.8 2023/06/26 20:10:23 rillig Exp $ */
+/* $NetBSD: lsym_for.c,v 1.9 2023/06/26 20:23:40 rillig Exp $ */
/*
* Tests for the token lsym_for, which represents the keyword 'for' that
@@ -103,17 +103,4 @@ function(void)
}
//indent end
-//indent run
-{
- for (const list_item *i = first; i != NULL; i = i->next) {
- }
-// $ FIXME: There should be no space after the '*'.
- for (list_item * *i = first; i != NULL; i = i->next) {
- }
-// $ FIXME: There should be no space after the '*'.
- for (list_item * const *i = first; i != NULL; i = i->next) {
- }
- for (const char *const *i = first; i != NULL; i = i->next) {
- }
-}
-//indent end
+//indent run-equals-input
diff -r 50b898ef947b -r e24af97cf7cd usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Mon Jun 26 20:10:23 2023 +0000
+++ b/usr.bin/indent/lexi.c Mon Jun 26 20:23:40 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.238 2023/06/26 20:10:23 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.239 2023/06/26 20:23:40 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.238 2023/06/26 20:10:23 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.239 2023/06/26 20:23:40 rillig Exp $");
#include <stdlib.h>
#include <string.h>
@@ -406,6 +406,12 @@ lexi_alnum(void)
if (ps.prev_lsym == lsym_tag && ps.paren.len == 0)
return lsym_type;
+ if (ps.spaced_expr_psym == psym_for_exprs
+ && ps.prev_lsym == lsym_lparen && ps.paren.len == 1
+ && *inp_p == '*') {
+ ps.next_unary = true;
+ return lsym_type;
+ }
token_add_char('\0'); // Terminate in non-debug mode as well.
token.len--;
Home |
Main Index |
Thread Index |
Old Index