indent: fix '*=' to be a binary operator, not a unary one

This commit is contained in:
rillig 2023-06-04 22:36:10 +00:00
parent e071ed3c05
commit 6bf97c9eba
2 changed files with 13 additions and 11 deletions

View File

@ -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

View File

@ -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: