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: rename ps.in_function_parameters to m...



details:   https://anonhg.NetBSD.org/src/rev/401388d0527c
branches:  trunk
changeset: 1026465:401388d0527c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Nov 25 18:48:37 2021 +0000

description:
indent: rename ps.in_function_parameters to match reality

This flag is only set while parsing the parameters of a function
definition, but not for a function declaration. See buffer_add in the
test fmt_decl.

No functional change.

diffstat:

 usr.bin/indent/indent.c |  18 +++++++++---------
 usr.bin/indent/indent.h |   4 ++--
 usr.bin/indent/lexi.c   |  12 ++++++------
 3 files changed, 17 insertions(+), 17 deletions(-)

diffs (144 lines):

diff -r a869300b0f13 -r 401388d0527c usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Thu Nov 25 18:36:30 2021 +0000
+++ b/usr.bin/indent/indent.c   Thu Nov 25 18:48:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.231 2021/11/25 07:45:32 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.232 2021/11/25 18:48:37 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.231 2021/11/25 07:45:32 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.232 2021/11/25 18:48:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -834,7 +834,7 @@
     *seen_case = false;                /* these will only need resetting in an error */
     *quest_level = 0;
     if (ps.prev_token == lsym_rparen_or_rbracket)
-       ps.in_parameter_declaration = false;
+       ps.in_func_def_params = false;
     ps.cast_mask = 0;
     ps.not_cast_mask = 0;
     ps.block_init = false;
@@ -893,7 +893,7 @@
        if (!opt.brace_same_line) {
            dump_line();
            ps.want_blank = false;
-       } else if (ps.in_parameter_declaration && !ps.init_or_struct) {
+       } else if (ps.in_func_def_params && !ps.init_or_struct) {
            ps.ind_level_follow = 0;
            if (opt.function_brace_split) {     /* dump the line prior to the
                                                 * brace ... */
@@ -904,7 +904,7 @@
        }
     }
 
-    if (ps.in_parameter_declaration)
+    if (ps.in_func_def_params)
        blank_line_before = false;
 
     if (ps.p_l_follow > 0) {
@@ -930,9 +930,9 @@
        ps.decl_on_line = false;        /* we can't be in the middle of a
                                         * declaration, so don't do special
                                         * indentation of comments */
-       if (opt.blanklines_after_decl_at_top && ps.in_parameter_declaration)
+       if (opt.blanklines_after_decl_at_top && ps.in_func_def_params)
            blank_line_after = true;
-       ps.in_parameter_declaration = false;
+       ps.in_func_def_params = false;
        ps.in_decl = false;
     }
 
@@ -975,7 +975,7 @@
 
     if (ps.decl_level > 0) { /* we are in multi-level structure declaration */
        *decl_ind = di_stack[--ps.decl_level];
-       if (ps.decl_level == 0 && !ps.in_parameter_declaration) {
+       if (ps.decl_level == 0 && !ps.in_func_def_params) {
            ps.just_saw_decl = 2;
            *decl_ind = ps.ind_level == 0
                ? opt.decl_indent : opt.local_decl_indent;
@@ -1039,7 +1039,7 @@
        }
     }
 
-    if (ps.in_parameter_declaration && opt.indent_parameters &&
+    if (ps.in_func_def_params && opt.indent_parameters &&
            ps.decl_level == 0) {
        ps.ind_level = ps.ind_level_follow = 1;
        ps.in_stmt_cont = false;
diff -r a869300b0f13 -r 401388d0527c usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Thu Nov 25 18:36:30 2021 +0000
+++ b/usr.bin/indent/indent.h   Thu Nov 25 18:48:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.101 2021/11/25 07:47:55 rillig Exp $      */
+/*     $NetBSD: indent.h,v 1.102 2021/11/25 18:48:37 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -309,7 +309,7 @@
                                 * processing of braces is then slightly
                                 * different */
     int just_saw_decl;
-    bool in_parameter_declaration;
+    bool in_func_def_params;
     bool decl_indent_done;     /* whether the indentation for a declaration
                                 * has been added to the code buffer. */
 
diff -r a869300b0f13 -r 401388d0527c usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Thu Nov 25 18:36:30 2021 +0000
+++ b/usr.bin/indent/lexi.c     Thu Nov 25 18:48:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.163 2021/11/25 18:36:30 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.164 2021/11/25 18:48:37 rillig Exp $        */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.163 2021/11/25 18:36:30 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.164 2021/11/25 18:48:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -301,7 +301,7 @@
     debug_ps_bool(decl_on_line);
     debug_ps_bool(in_decl);
     debug_ps_int(just_saw_decl);
-    debug_ps_bool(in_parameter_declaration);
+    debug_ps_bool(in_func_def_params);
     debug_ps_bool(decl_indent_done);
 
     debug_ps_bool(in_stmt_or_decl);
@@ -535,12 +535,12 @@
     }
 
     if (inp_peek() == '(' && ps.tos <= 1 && ps.ind_level == 0 &&
-       !ps.in_parameter_declaration && !ps.block_init) {
+       !ps.in_func_def_params && !ps.block_init) {
 
        if (ps.p_l_follow == 0 && probably_looking_at_definition()) {
            ps.is_function_definition = true;
            if (ps.in_decl)
-               ps.in_parameter_declaration = true;
+               ps.in_func_def_params = true;
            return lsym_funcname;
        }
 
@@ -555,7 +555,7 @@
 static bool
 is_asterisk_unary(void)
 {
-    if (ps.next_unary || ps.in_parameter_declaration)
+    if (ps.next_unary || ps.in_func_def_params)
        return true;
     if (ps.prev_token == lsym_word ||
            ps.prev_token == lsym_rparen_or_rbracket)



Home | Main Index | Thread Index | Old Index