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.last_u_d to match its comment



details:   https://anonhg.NetBSD.org/src/rev/66bb3bf5f5d0
branches:  trunk
changeset: 989919:66bb3bf5f5d0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Oct 20 05:37:21 2021 +0000

description:
indent: rename ps.last_u_d to match its comment

No functional change.

diffstat:

 usr.bin/indent/indent.c |  11 +++++------
 usr.bin/indent/indent.h |   4 ++--
 usr.bin/indent/lexi.c   |  36 ++++++++++++++++++------------------
 3 files changed, 25 insertions(+), 26 deletions(-)

diffs (214 lines):

diff -r e90897366afc -r 66bb3bf5f5d0 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Wed Oct 20 05:26:46 2021 +0000
+++ b/usr.bin/indent/indent.c   Wed Oct 20 05:37:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.143 2021/10/20 05:26:46 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.144 2021/10/20 05:37:21 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.143 2021/10/20 05:26:46 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.144 2021/10/20 05:37:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -748,7 +748,7 @@
     token_type hd_type)
 {
     if ((ps.cast_mask & (1 << ps.p_l_follow) & ~ps.not_cast_mask) != 0) {
-       ps.last_u_d = true;
+       ps.next_unary = true;
        ps.cast_mask &= (1 << ps.p_l_follow) - 1;
        ps.want_blank = opt.space_after_cast;
     } else
@@ -769,8 +769,7 @@
                                         * such */
        *sp_sw = false;
        *force_nl = true;       /* must force newline after if */
-       ps.last_u_d = true;     /* inform lexi that a following operator is
-                                * unary */
+       ps.next_unary = true;
        ps.in_stmt = false;     /* don't use stmt continuation indentation */
 
        parse(hd_type);         /* let parser worry about if, or whatever */
@@ -1116,7 +1115,7 @@
     } else if (*sp_sw && ps.p_l_follow == 0) {
        *sp_sw = false;
        *force_nl = true;
-       ps.last_u_d = true;
+       ps.next_unary = true;
        ps.in_stmt = false;
        parse(hd_type);
     }
diff -r e90897366afc -r 66bb3bf5f5d0 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Wed Oct 20 05:26:46 2021 +0000
+++ b/usr.bin/indent/indent.h   Wed Oct 20 05:37:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.41 2021/10/20 05:26:46 rillig Exp $       */
+/*     $NetBSD: indent.h,v 1.42 2021/10/20 05:37:21 rillig Exp $       */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -292,7 +292,7 @@
     bool ind_stmt;             /* whether the next line should have an extra
                                 * indentation level because we are in the
                                 * middle of a stmt */
-    bool last_u_d;             /* whether the following operator should be
+    bool next_unary;           /* whether the following operator should be
                                 * unary */
     int p_l_follow;            /* used to remember how to indent the
                                 * following statement */
diff -r e90897366afc -r 66bb3bf5f5d0 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Wed Oct 20 05:26:46 2021 +0000
+++ b/usr.bin/indent/lexi.c     Wed Oct 20 05:37:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.91 2021/10/11 20:31:06 rillig Exp $ */
+/*     $NetBSD: lexi.c,v 1.92 2021/10/20 05:37:21 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.91 2021/10/11 20:31:06 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.92 2021/10/20 05:37:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -404,25 +404,25 @@
 
     if (state->last_token == keyword_struct_union_enum &&
            state->p_l_follow == 0) {
-       state->last_u_d = true;
+       state->next_unary = true;
        return decl;
     }
 
     /* Operator after identifier is binary unless last token was 'struct'. */
-    state->last_u_d = (state->last_token == keyword_struct_union_enum);
+    state->next_unary = state->last_token == keyword_struct_union_enum;
 
     const struct keyword *kw = bsearch(token.s, keywords,
        nitems(keywords), sizeof(keywords[0]), cmp_keyword_by_name);
     if (kw == NULL) {
        if (is_typename()) {
            state->keyword = kw_type;
-           state->last_u_d = true;
+           state->next_unary = true;
            goto found_typename;
        }
 
     } else {                   /* we have a keyword */
        state->keyword = kw->kind;
-       state->last_u_d = true;
+       state->next_unary = true;
 
        switch (kw->kind) {
        case kw_switch:
@@ -481,13 +481,13 @@
 
     } else if (probably_typename(state)) {
        state->keyword = kw_type;
-       state->last_u_d = true;
+       state->next_unary = true;
        return decl;
     }
 
     if (state->last_token == decl)     /* if this is a declared variable,
                                         * then following sign is unary */
-       state->last_u_d = true; /* will make "int a -1" work */
+       state->next_unary = true;       /* will make "int a -1" work */
 
     return ident;              /* the ident is not in the list */
 }
@@ -521,7 +521,7 @@
 
     switch (*token.s) {
     case '\n':
-       unary_delim = state->last_u_d;
+       unary_delim = state->next_unary;
        state->last_nl = true;  /* remember that we just had a newline */
        /* if data has been exhausted, the newline is a dummy. */
        ttype = had_eof ? end_of_file : newline;
@@ -545,7 +545,7 @@
        break;
 
     case '#':
-       unary_delim = state->last_u_d;
+       unary_delim = state->next_unary;
        ttype = preprocessing;
        break;
 
@@ -575,7 +575,7 @@
        break;
 
     case '\f':
-       unary_delim = state->last_u_d;
+       unary_delim = state->next_unary;
        state->last_nl = true;  /* remember this, so we can set 'state->col_1'
                                 * right */
        ttype = form_feed;
@@ -593,14 +593,14 @@
 
     case '-':
     case '+':
-       ttype = state->last_u_d ? unary_op : binary_op;
+       ttype = state->next_unary ? unary_op : binary_op;
        unary_delim = true;
 
        if (*inp.s == token.s[0]) {     /* ++, -- */
            *token.e++ = *inp.s++;
            if (state->last_token == ident ||
                    state->last_token == rparen_or_rbracket) {
-               ttype = state->last_u_d ? unary_op : postfix_op;
+               ttype = state->next_unary ? unary_op : postfix_op;
                unary_delim = false;
            }
 
@@ -633,13 +633,13 @@
            *token.e++ = inbuf_next();
        if (*inp.s == '=')
            *token.e++ = *inp.s++;
-       ttype = state->last_u_d ? unary_op : binary_op;
+       ttype = state->next_unary ? unary_op : binary_op;
        unary_delim = true;
        break;
 
     case '*':
        unary_delim = true;
-       if (!state->last_u_d) {
+       if (!state->next_unary) {
            if (*inp.s == '=')
                *token.e++ = *inp.s++;
            ttype = binary_op;
@@ -673,7 +673,7 @@
            *token.e++ = inbuf_next();
 
            ttype = comment;
-           unary_delim = state->last_u_d;
+           unary_delim = state->next_unary;
            break;
        }
 
@@ -682,14 +682,14 @@
            token_add_char(inbuf_next());
        }
 
-       ttype = state->last_u_d ? unary_op : binary_op;
+       ttype = state->next_unary ? unary_op : binary_op;
        unary_delim = true;
     }
 
     if (inp.s >= inp.e)        /* check for input buffer empty */
        inbuf_read_line();
 
-    state->last_u_d = unary_delim;
+    state->next_unary = unary_delim;
 
     check_size_token(1);
     *token.e = '\0';



Home | Main Index | Thread Index | Old Index