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: fix type cast in function definition



details:   https://anonhg.NetBSD.org/src/rev/eaa5dd1a27d7
branches:  trunk
changeset: 375371:eaa5dd1a27d7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon May 15 20:50:37 2023 +0000

description:
indent: fix type cast in function definition

diffstat:

 tests/usr.bin/indent/fmt_decl.c |  8 ++++----
 tests/usr.bin/indent/opt_pcs.c  |  4 ++--
 tests/usr.bin/indent/opt_ta.c   |  4 ++--
 usr.bin/indent/indent.c         |  7 ++++---
 4 files changed, 12 insertions(+), 11 deletions(-)

diffs (92 lines):

diff -r cc8dc7a88578 -r eaa5dd1a27d7 tests/usr.bin/indent/fmt_decl.c
--- a/tests/usr.bin/indent/fmt_decl.c   Mon May 15 20:35:56 2023 +0000
+++ b/tests/usr.bin/indent/fmt_decl.c   Mon May 15 20:50:37 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fmt_decl.c,v 1.40 2023/05/15 15:04:48 rillig Exp $     */
+/*     $NetBSD: fmt_decl.c,v 1.41 2023/05/15 20:50:37 rillig Exp $     */
 
 /*
  * Tests for declarations of global variables, external functions, and local
@@ -890,8 +890,8 @@ char *(*fn)(int, int) = NULL;
 
 
 /*
- * Depending on the line break in the function header, the spaces around the
- * '||' operator were removed.
+ * Depending on whether there was a line break in the function header, the
+ * spaces around the '||' operator were erroneously removed.
  */
 //indent input
 bool is_identifier_start(char ch)
@@ -916,6 +916,6 @@ is_identifier_start(char ch)
 bool
 is_identifier_start(char ch)
 {
-       return ch_isalpha(ch)||ch == '_';
+       return ch_isalpha(ch) || ch == '_';
 }
 //indent end
diff -r cc8dc7a88578 -r eaa5dd1a27d7 tests/usr.bin/indent/opt_pcs.c
--- a/tests/usr.bin/indent/opt_pcs.c    Mon May 15 20:35:56 2023 +0000
+++ b/tests/usr.bin/indent/opt_pcs.c    Mon May 15 20:50:37 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_pcs.c,v 1.14 2023/05/15 14:55:47 rillig Exp $ */
+/* $NetBSD: opt_pcs.c,v 1.15 2023/05/15 20:50:37 rillig Exp $ */
 
 /*
  * Tests for the options '-pcs' and '-npcs'.
@@ -49,7 +49,7 @@ int var = (function)(arg);
 //indent run -di0 -pcs
 void (*signal (void (*handler) (int))) (int);
 // $ This may be a function call or a cast, depending on the context.
-int var = (function)(arg);
+int var = (function) (arg);
 //indent end
 
 //indent run -di0 -npcs
diff -r cc8dc7a88578 -r eaa5dd1a27d7 tests/usr.bin/indent/opt_ta.c
--- a/tests/usr.bin/indent/opt_ta.c     Mon May 15 20:35:56 2023 +0000
+++ b/tests/usr.bin/indent/opt_ta.c     Mon May 15 20:50:37 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_ta.c,v 1.5 2023/05/15 14:55:47 rillig Exp $ */
+/* $NetBSD: opt_ta.c,v 1.6 2023/05/15 20:50:37 rillig Exp $ */
 
 /*
  * Tests for the option '-ta', which assumes that all identifiers that end in
@@ -20,7 +20,7 @@ example(void *arg)
 void
 example(void *arg)
 {
-       int             mult = (unknown_type_name)*arg;
+       int             mult = (unknown_type_name) * arg;
 
        int             cast = (unknown_type_name_t)*arg;
 }
diff -r cc8dc7a88578 -r eaa5dd1a27d7 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Mon May 15 20:35:56 2023 +0000
+++ b/usr.bin/indent/indent.c   Mon May 15 20:50:37 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.282 2023/05/15 20:30:20 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.283 2023/05/15 20:50:37 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.282 2023/05/15 20:30:20 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.283 2023/05/15 20:50:37 rillig Exp $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -466,7 +466,8 @@ process_lparen_or_lbracket(void)
        ps.init_or_struct = false;
     }
 
-    if (ps.prev_token == lsym_offsetof || ps.prev_token == lsym_sizeof)
+    if (ps.prev_token == lsym_offsetof || ps.prev_token == lsym_sizeof
+           || ps.is_function_definition)
        ps.paren[ps.nparen - 1].no_cast = true;
 }
 



Home | Main Index | Thread Index | Old Index