indent: for '-pcs', add blank between function and '('

Before indent-2021.09.30.21.48.12, the blank had always been added, even
in '-npcs' mode. Since then, the blank had never been added.

Now, add the blank in '-pcs' mode and omit it in '-npcs' mode.
This commit is contained in:
rillig 2021-10-31 21:43:43 +00:00
parent 38900ecc98
commit 47ec159eb4
2 changed files with 15 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: opt_pcs.c,v 1.7 2021/10/31 21:31:55 rillig Exp $ */ /* $NetBSD: opt_pcs.c,v 1.8 2021/10/31 21:43:43 rillig Exp $ */
/* $FreeBSD$ */ /* $FreeBSD$ */
/* /*
@ -47,15 +47,16 @@ void ( * signal ( void ( * handler ) ( int ) ) ) ( int ) ;
int var = (function)(arg); int var = (function)(arg);
#indent end #indent end
/* TODO: add a blank between ')' and '('. */
#indent run -npsl -di0 -pcs #indent run -npsl -di0 -pcs
void (*signal(void (*handler) (int))) (int);
int var = (function) (arg);
#indent end
#indent run -npsl -di0 -npcs
void (*signal(void (*handler)(int)))(int); void (*signal(void (*handler)(int)))(int);
int var = (function)(arg); int var = (function)(arg);
#indent end #indent end
#indent run-equals-prev-output -npsl -di0 -npcs
/* /*
* The option '-pcs' also applies to 'sizeof' and 'offsetof', even though * The option '-pcs' also applies to 'sizeof' and 'offsetof', even though
* these are not functions. * these are not functions.

View File

@ -1,4 +1,4 @@
/* $NetBSD: indent.c,v 1.201 2021/10/31 20:40:42 rillig Exp $ */ /* $NetBSD: indent.c,v 1.202 2021/10/31 21:43:43 rillig Exp $ */
/*- /*-
* SPDX-License-Identifier: BSD-4-Clause * SPDX-License-Identifier: BSD-4-Clause
@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c 5.17 (Berkeley) 6/7/93";
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if defined(__NetBSD__) #if defined(__NetBSD__)
__RCSID("$NetBSD: indent.c,v 1.201 2021/10/31 20:40:42 rillig Exp $"); __RCSID("$NetBSD: indent.c,v 1.202 2021/10/31 21:43:43 rillig Exp $");
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif #endif
@ -739,17 +739,17 @@ want_blank_before_lparen(void)
{ {
if (!ps.want_blank) if (!ps.want_blank)
return false; return false;
if (opt.proc_calls_space)
return true;
if (ps.prev_token == lsym_rparen_or_rbracket) if (ps.prev_token == lsym_rparen_or_rbracket)
return false; return false;
if (ps.prev_token == lsym_offsetof) if (ps.prev_token == lsym_offsetof)
return opt.proc_calls_space; return false;
if (ps.prev_token == lsym_sizeof) if (ps.prev_token == lsym_sizeof)
return opt.proc_calls_space || opt.blank_after_sizeof; return opt.blank_after_sizeof;
if (ps.prev_token != lsym_ident && ps.prev_token != lsym_funcname) if (ps.prev_token == lsym_ident || ps.prev_token == lsym_funcname)
return true; return ps.prev_is_type;
if (opt.proc_calls_space) return true;
return true;
return ps.prev_is_type;
} }
static void static void