Module Name:    src
Committed By:   rillig
Date:           Sun Jun  4 22:36:11 UTC 2023

Modified Files:
        src/tests/usr.bin/indent: lsym_binary_op.c
        src/usr.bin/indent: lexi.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/lsym_binary_op.c
cvs rdiff -u -r1.212 -r1.213 src/usr.bin/indent/lexi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/lsym_binary_op.c
diff -u src/tests/usr.bin/indent/lsym_binary_op.c:1.9 src/tests/usr.bin/indent/lsym_binary_op.c:1.10
--- src/tests/usr.bin/indent/lsym_binary_op.c:1.9	Sun Jun  4 22:20:04 2023
+++ src/tests/usr.bin/indent/lsym_binary_op.c	Sun Jun  4 22:36:10 2023
@@ -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

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.212 src/usr.bin/indent/lexi.c:1.213
--- src/usr.bin/indent/lexi.c:1.212	Sun Jun  4 20:51:19 2023
+++ src/usr.bin/indent/lexi.c	Sun Jun  4 22:36:10 2023
@@ -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:

Reply via email to