Module Name: src
Committed By: rillig
Date: Sun Oct 31 21:43:43 UTC 2021
Modified Files:
src/tests/usr.bin/indent: opt_pcs.c
src/usr.bin/indent: indent.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/opt_pcs.c
cvs rdiff -u -r1.201 -r1.202 src/usr.bin/indent/indent.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/opt_pcs.c
diff -u src/tests/usr.bin/indent/opt_pcs.c:1.7 src/tests/usr.bin/indent/opt_pcs.c:1.8
--- src/tests/usr.bin/indent/opt_pcs.c:1.7 Sun Oct 31 21:31:55 2021
+++ src/tests/usr.bin/indent/opt_pcs.c Sun Oct 31 21:43:43 2021
@@ -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$ */
/*
@@ -47,15 +47,16 @@ void ( * signal ( void ( * handler ) ( i
int var = (function)(arg);
#indent end
-/* TODO: add a blank between ')' and '('. */
#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);
int var = (function)(arg);
#indent end
-#indent run-equals-prev-output -npsl -di0 -npcs
-
-
/*
* The option '-pcs' also applies to 'sizeof' and 'offsetof', even though
* these are not functions.
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.201 src/usr.bin/indent/indent.c:1.202
--- src/usr.bin/indent/indent.c:1.201 Sun Oct 31 20:40:42 2021
+++ src/usr.bin/indent/indent.c Sun Oct 31 21:43:43 2021
@@ -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
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c 5.1
#include <sys/cdefs.h>
#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__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -739,17 +739,17 @@ want_blank_before_lparen(void)
{
if (!ps.want_blank)
return false;
+ if (opt.proc_calls_space)
+ return true;
if (ps.prev_token == lsym_rparen_or_rbracket)
return false;
if (ps.prev_token == lsym_offsetof)
- return opt.proc_calls_space;
+ return false;
if (ps.prev_token == lsym_sizeof)
- return opt.proc_calls_space || opt.blank_after_sizeof;
- if (ps.prev_token != lsym_ident && ps.prev_token != lsym_funcname)
- return true;
- if (opt.proc_calls_space)
- return true;
- return ps.prev_is_type;
+ return opt.blank_after_sizeof;
+ if (ps.prev_token == lsym_ident || ps.prev_token == lsym_funcname)
+ return ps.prev_is_type;
+ return true;
}
static void