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: fix '*=' to be a binary operator, not...
details: https://anonhg.NetBSD.org/src/rev/e33753094ede
branches: trunk
changeset: 376216:e33753094ede
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jun 04 22:36:10 2023 +0000
description:
indent: fix '*=' to be a binary operator, not a unary one
diffstat:
tests/usr.bin/indent/lsym_binary_op.c | 7 +++++--
usr.bin/indent/lexi.c | 17 ++++++++---------
2 files changed, 13 insertions(+), 11 deletions(-)
diffs (65 lines):
diff -r 63c56118c7c5 -r e33753094ede tests/usr.bin/indent/lsym_binary_op.c
--- a/tests/usr.bin/indent/lsym_binary_op.c Sun Jun 04 22:20:04 2023 +0000
+++ b/tests/usr.bin/indent/lsym_binary_op.c Sun Jun 04 22:36:10 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_binary_op.c,v 1.9 2023/06/04 22:20:04 rillig Exp $ */
+/* $NetBSD: lsym_binary_op.c,v 1.10 2023/06/04 22:36:10 rillig Exp $ */
/*
* Tests for the token lsym_binary_op, which represents a binary operator in
@@ -183,10 +183,13 @@ int x = arr[3] * y;
//indent end
+/*
+ * Ensure that after an assignment, a '*=' operator is properly spaced, like
+ * any other binary operator.
+ */
//indent input
{
a = a;
-// $ FIXME: The first '*=' is categorized as 'unary_op token "*"'.
a *= b *= c;
}
//indent end
diff -r 63c56118c7c5 -r e33753094ede usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Sun Jun 04 22:20:04 2023 +0000
+++ b/usr.bin/indent/lexi.c Sun Jun 04 22:36:10 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.212 2023/06/04 20:51:19 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.213 2023/06/04 22:36:10 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.212 2023/06/04 20:51:19 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.213 2023/06/04 22:36:10 rillig Exp $");
#include <stdlib.h>
#include <string.h>
@@ -643,16 +643,15 @@ lexi(void)
break;
case '*':
- if (is_asterisk_unary()) {
+ if (inp_p[0] == '=') {
+ token_add_char(*inp_p++);
+ lsym = lsym_binary_op;
+ } else if (is_asterisk_unary()) {
lex_asterisk_unary();
lsym = lsym_unary_op;
- next_unary = true;
- } else {
- if (inp_p[0] == '=')
- token_add_char(*inp_p++);
+ } else
lsym = lsym_binary_op;
- next_unary = true;
- }
+ next_unary = true;
break;
default:
Home |
Main Index |
Thread Index |
Old Index