indent: fix duplicate space between comment and binary operator
This commit is contained in:
parent
9b57bdf0e0
commit
a59ea3192b
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lsym_comment.c,v 1.11 2023/05/15 19:55:51 rillig Exp $ */
|
||||
/* $NetBSD: lsym_comment.c,v 1.12 2023/05/15 20:30:20 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Tests for the token lsym_comment, which starts a comment.
|
||||
|
@ -1078,3 +1078,22 @@ error*/
|
|||
* error
|
||||
*/
|
||||
//indent end
|
||||
|
||||
|
||||
/*
|
||||
* Ensure that there is exactly one space between the comment and the
|
||||
* following binary operator.
|
||||
*/
|
||||
//indent input
|
||||
{
|
||||
a /* */ > b;
|
||||
a>b;
|
||||
}
|
||||
//indent end
|
||||
|
||||
//indent run
|
||||
{
|
||||
a /* */ > b;
|
||||
a > b;
|
||||
}
|
||||
//indent end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: indent.c,v 1.281 2023/05/15 20:12:28 rillig Exp $ */
|
||||
/* $NetBSD: indent.c,v 1.282 2023/05/15 20:30:20 rillig Exp $ */
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-4-Clause
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: indent.c,v 1.281 2023/05/15 20:12:28 rillig Exp $");
|
||||
__RCSID("$NetBSD: indent.c,v 1.282 2023/05/15 20:30:20 rillig Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <err.h>
|
||||
|
@ -539,7 +539,7 @@ process_unary_op(void)
|
|||
static void
|
||||
process_binary_op(void)
|
||||
{
|
||||
if (code.len > 0)
|
||||
if (code.len > 0 && ps.want_blank)
|
||||
buf_add_char(&code, ' ');
|
||||
buf_add_buf(&code, &token);
|
||||
ps.want_blank = true;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: indent.h,v 1.140 2023/05/15 20:12:28 rillig Exp $ */
|
||||
/* $NetBSD: indent.h,v 1.141 2023/05/15 20:30:20 rillig Exp $ */
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
|
@ -358,8 +358,8 @@ extern struct parser_state {
|
|||
|
||||
/* Vertical spacing */
|
||||
|
||||
bool force_nl; /* whether the next token is forced to go to
|
||||
* a new line; used after 'if (expr)' and
|
||||
bool force_nl; /* whether the next token is forced to go to a
|
||||
* new line; used after 'if (expr)' and in
|
||||
* similar situations; tokens like '{' may
|
||||
* ignore this */
|
||||
|
||||
|
|
Loading…
Reference in New Issue