indent: rename ps.last_u_d to match its comment

No functional change.
This commit is contained in:
rillig 2021-10-20 05:37:21 +00:00
parent 68e14313bc
commit 5fb4571551
3 changed files with 25 additions and 26 deletions

View File

@ -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 @@ static char sccsid[] = "@(#)indent.c 5.17 (Berkeley) 6/7/93";
#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 @@ process_rparen_or_rbracket(bool *sp_sw, bool *force_nl,
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 @@ process_rparen_or_rbracket(bool *sp_sw, bool *force_nl,
* 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 @@ process_ident(token_type ttype, int decl_ind, bool tabs_to_var,
} 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);
}

View File

@ -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 @@ extern struct parser_state {
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 */

View File

@ -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 @@ static char sccsid[] = "@(#)lexi.c 8.1 (Berkeley) 6/6/93";
#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 @@ lexi_alnum(struct parser_state *state)
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 @@ not_proc:;
} 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 @@ lexi(struct parser_state *state)
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 @@ lexi(struct parser_state *state)
break;
case '#':
unary_delim = state->last_u_d;
unary_delim = state->next_unary;
ttype = preprocessing;
break;
@ -575,7 +575,7 @@ lexi(struct parser_state *state)
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 @@ lexi(struct parser_state *state)
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 @@ lexi(struct parser_state *state)
*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 @@ lexi(struct parser_state *state)
*token.e++ = inbuf_next();
ttype = comment;
unary_delim = state->last_u_d;
unary_delim = state->next_unary;
break;
}
@ -682,14 +682,14 @@ lexi(struct parser_state *state)
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';