Module Name: src Committed By: rillig Date: Mon May 15 20:50:37 UTC 2023
Modified Files: src/tests/usr.bin/indent: fmt_decl.c opt_pcs.c opt_ta.c src/usr.bin/indent: indent.c Log Message: indent: fix type cast in function definition To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/indent/opt_pcs.c cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/opt_ta.c cvs rdiff -u -r1.282 -r1.283 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/fmt_decl.c diff -u src/tests/usr.bin/indent/fmt_decl.c:1.40 src/tests/usr.bin/indent/fmt_decl.c:1.41 --- src/tests/usr.bin/indent/fmt_decl.c:1.40 Mon May 15 15:04:48 2023 +++ src/tests/usr.bin/indent/fmt_decl.c Mon May 15 20:50:37 2023 @@ -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 Index: src/tests/usr.bin/indent/opt_pcs.c diff -u src/tests/usr.bin/indent/opt_pcs.c:1.14 src/tests/usr.bin/indent/opt_pcs.c:1.15 --- src/tests/usr.bin/indent/opt_pcs.c:1.14 Mon May 15 14:55:47 2023 +++ src/tests/usr.bin/indent/opt_pcs.c Mon May 15 20:50:37 2023 @@ -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 Index: src/tests/usr.bin/indent/opt_ta.c diff -u src/tests/usr.bin/indent/opt_ta.c:1.5 src/tests/usr.bin/indent/opt_ta.c:1.6 --- src/tests/usr.bin/indent/opt_ta.c:1.5 Mon May 15 14:55:47 2023 +++ src/tests/usr.bin/indent/opt_ta.c Mon May 15 20:50:37 2023 @@ -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; } Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.282 src/usr.bin/indent/indent.c:1.283 --- src/usr.bin/indent/indent.c:1.282 Mon May 15 20:30:20 2023 +++ src/usr.bin/indent/indent.c Mon May 15 20:50:37 2023 @@ -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; }