Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/indent indent: for '-pcs', add blank between functio...



details:   https://anonhg.NetBSD.org/src/rev/3a777adf60a9
branches:  trunk
changeset: 990643:3a777adf60a9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 31 21:43:43 2021 +0000

description:
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.

diffstat:

 tests/usr.bin/indent/opt_pcs.c |  11 ++++++-----
 usr.bin/indent/indent.c        |  18 +++++++++---------
 2 files changed, 15 insertions(+), 14 deletions(-)

diffs (73 lines):

diff -r 4f838582acbd -r 3a777adf60a9 tests/usr.bin/indent/opt_pcs.c
--- a/tests/usr.bin/indent/opt_pcs.c    Sun Oct 31 21:31:55 2021 +0000
+++ b/tests/usr.bin/indent/opt_pcs.c    Sun Oct 31 21:43:43 2021 +0000
@@ -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 @@
 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.
diff -r 4f838582acbd -r 3a777adf60a9 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sun Oct 31 21:31:55 2021 +0000
+++ b/usr.bin/indent/indent.c   Sun Oct 31 21:43:43 2021 +0000
@@ -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 @@
 
 #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 @@
 {
     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



Home | Main Index | Thread Index | Old Index