Module Name: src Committed By: rillig Date: Mon May 15 14:55:47 UTC 2023
Modified Files: src/tests/usr.bin/indent: fmt_decl.c opt_pcs.c opt_ta.c ps_ind_level.c src/usr.bin/indent: indent.c Log Message: indent: fix spacing between function prototype and attributes To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/indent/opt_pcs.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/opt_ta.c cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/ps_ind_level.c cvs rdiff -u -r1.278 -r1.279 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.38 src/tests/usr.bin/indent/fmt_decl.c:1.39 --- src/tests/usr.bin/indent/fmt_decl.c:1.38 Sat May 13 06:52:48 2023 +++ src/tests/usr.bin/indent/fmt_decl.c Mon May 15 14:55:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_decl.c,v 1.38 2023/05/13 06:52:48 rillig Exp $ */ +/* $NetBSD: fmt_decl.c,v 1.39 2023/05/15 14:55:47 rillig Exp $ */ /* * Tests for declarations of global variables, external functions, and local @@ -164,17 +164,18 @@ MAXALIGN(offsetof(int, test)) + MAXIMUM_ * sensible way. */ //indent input -void function(const char *, ...) __attribute__((format(printf, 1, 2))); +void single_param(int) __attribute__((__noreturn__)) ; +void function(const char *, ...) __attribute__((format(printf, 1, 2))) ; //indent end -/* FIXME: missing space before '__attribute__' */ //indent run -di0 -void function(const char *, ...)__attribute__((format(printf, 1, 2))); +void single_param(int) __attribute__((__noreturn__)); +void function(const char *, ...) __attribute__((format(printf, 1, 2))); //indent end -/* FIXME: missing space before '__attribute__' */ //indent run -void function(const char *, ...)__attribute__((format(printf, 1, 2))); +void single_param(int) __attribute__((__noreturn__)); +void function(const char *, ...) __attribute__((format(printf, 1, 2))); //indent end @@ -734,8 +735,7 @@ static void JobRestartJobs(void); //indent end //indent run -/* $ FIXME: Missing space before 'MAKE_ATTR_DEAD'. */ -static void JobInterrupt(bool, int)MAKE_ATTR_DEAD; +static void JobInterrupt(bool, int) MAKE_ATTR_DEAD; static void JobRestartJobs(void); //indent end Index: src/tests/usr.bin/indent/opt_pcs.c diff -u src/tests/usr.bin/indent/opt_pcs.c:1.13 src/tests/usr.bin/indent/opt_pcs.c:1.14 --- src/tests/usr.bin/indent/opt_pcs.c:1.13 Sun Apr 24 09:04:12 2022 +++ src/tests/usr.bin/indent/opt_pcs.c Mon May 15 14:55:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_pcs.c,v 1.13 2022/04/24 09:04:12 rillig Exp $ */ +/* $NetBSD: opt_pcs.c,v 1.14 2023/05/15 14:55:47 rillig Exp $ */ /* * Tests for the options '-pcs' and '-npcs'. @@ -48,7 +48,8 @@ int var = (function)(arg); //indent run -di0 -pcs void (*signal (void (*handler) (int))) (int); -int var = (function) (arg); +// $ This may be a function call or a cast, depending on the context. +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.4 src/tests/usr.bin/indent/opt_ta.c:1.5 --- src/tests/usr.bin/indent/opt_ta.c:1.4 Sun Apr 24 09:04:12 2022 +++ src/tests/usr.bin/indent/opt_ta.c Mon May 15 14:55:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_ta.c,v 1.4 2022/04/24 09:04:12 rillig Exp $ */ +/* $NetBSD: opt_ta.c,v 1.5 2023/05/15 14:55:47 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/tests/usr.bin/indent/ps_ind_level.c diff -u src/tests/usr.bin/indent/ps_ind_level.c:1.6 src/tests/usr.bin/indent/ps_ind_level.c:1.7 --- src/tests/usr.bin/indent/ps_ind_level.c:1.6 Sun Apr 24 09:04:12 2022 +++ src/tests/usr.bin/indent/ps_ind_level.c Mon May 15 14:55:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ps_ind_level.c,v 1.6 2022/04/24 09:04:12 rillig Exp $ */ +/* $NetBSD: ps_ind_level.c,v 1.7 2023/05/15 14:55:47 rillig Exp $ */ /* * The indentation of the very first line of a file determines the @@ -24,18 +24,9 @@ void function_in_column_1(void){} //indent run -i5 -ts8 int indented_by_24; - void function_in_column_1(void){ + void function_in_column_1(void) { } //indent end -/* - * In the above function declaration, the space between '){' is missing. This - * is because the tokenizer only recognizes function definitions if they start - * at indentation level 0, but this declaration starts at indentation level 4, - * due to the indentation in line 1. It's an edge case that is probably not - * worth fixing. - * - * See 'in_func_def_params = true'. - */ /* @@ -54,7 +45,7 @@ label:; //indent run -i8 -ts8 -di0 int indent_by_24; - void function(void){ + void function(void) { label: ; } //indent end Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.278 src/usr.bin/indent/indent.c:1.279 --- src/usr.bin/indent/indent.c:1.278 Mon May 15 14:12:03 2023 +++ src/usr.bin/indent/indent.c Mon May 15 14:55:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.278 2023/05/15 14:12:03 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.279 2023/05/15 14:55:47 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: indent.c,v 1.278 2023/05/15 14:12:03 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.279 2023/05/15 14:55:47 rillig Exp $"); #include <sys/param.h> #include <err.h> @@ -464,6 +464,9 @@ process_rparen_or_rbracket(void) goto unbalanced; /* TODO: better exit immediately */ } + if (ps.nparen > 0 && ps.decl_on_line && !ps.block_init) + ps.paren[ps.nparen - 1].no_cast = true; + if (ps.paren[ps.nparen - 1].maybe_cast && !ps.paren[ps.nparen - 1].no_cast) { ps.next_unary = true;