Module Name: src Committed By: rillig Date: Fri Oct 8 16:20:33 UTC 2021
Modified Files: src/usr.bin/indent: indent.c indent.h lexi.c Log Message: indent: rename tokens lparen and rparen to be more precise No functional change. To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/usr.bin/indent/indent.c cvs rdiff -u -r1.31 -r1.32 src/usr.bin/indent/indent.h cvs rdiff -u -r1.78 -r1.79 src/usr.bin/indent/lexi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.125 src/usr.bin/indent/indent.c:1.126 --- src/usr.bin/indent/indent.c:1.125 Thu Oct 7 23:18:47 2021 +++ src/usr.bin/indent/indent.c Fri Oct 8 16:20:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.125 2021/10/07 23:18:47 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.126 2021/10/08 16:20:33 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c 5.1 #include <sys/cdefs.h> #if defined(__NetBSD__) -__RCSID("$NetBSD: indent.c,v 1.125 2021/10/07 23:18:47 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.126 2021/10/08 16:20:33 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); #endif @@ -621,7 +621,7 @@ want_blank_before_lparen(void) { if (!ps.want_blank) return false; - if (ps.last_token == rparen) + if (ps.last_token == rparen_or_rbracket) return false; if (ps.last_token != ident && ps.last_token != funcname) return true; @@ -803,7 +803,7 @@ process_semicolon(bool *seen_case, int * * structure declaration */ *seen_case = false; /* these will only need resetting in an error */ *seen_quest = 0; - if (ps.last_token == rparen) + if (ps.last_token == rparen_or_rbracket) ps.in_parameter_declaration = false; ps.cast_mask = 0; ps.not_cast_mask = 0; @@ -1000,7 +1000,7 @@ process_decl(int *out_decl_ind, bool *ou { parse(decl); /* let parser worry about indentation */ - if (ps.last_token == rparen && ps.tos <= 1) { + if (ps.last_token == rparen_or_rbracket && ps.tos <= 1) { if (code.s != code.e) { dump_line(); ps.want_blank = false; @@ -1316,11 +1316,11 @@ main_loop(void) process_newline(); break; - case lparen: /* got a '(' or '[' */ + case lparen_or_lbracket: process_lparen_or_lbracket(decl_ind, tabs_to_var, sp_sw); break; - case rparen: /* got a ')' or ']' */ + case rparen_or_rbracket: process_rparen_or_rbracket(&sp_sw, &force_nl, hd_type); break; Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.31 src/usr.bin/indent/indent.h:1.32 --- src/usr.bin/indent/indent.h:1.31 Fri Oct 8 16:16:54 2021 +++ src/usr.bin/indent/indent.h Fri Oct 8 16:20:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.31 2021/10/08 16:16:54 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.32 2021/10/08 16:20:33 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -73,8 +73,8 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/ typedef enum token_type { end_of_file, newline, - lparen, /* '(' or '[' */ - rparen, /* ')' or ']' */ + lparen_or_lbracket, + rparen_or_rbracket, unary_op, /* e.g. '+' or '&' */ binary_op, /* e.g. '<<' or '+' or '&&' or '/=' */ postfix_op, /* trailing '++' or '--' */ Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.78 src/usr.bin/indent/lexi.c:1.79 --- src/usr.bin/indent/lexi.c:1.78 Thu Oct 7 23:15:15 2021 +++ src/usr.bin/indent/lexi.c Fri Oct 8 16:20:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.78 2021/10/07 23:15:15 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.79 2021/10/08 16:20:33 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c 8.1 ( #include <sys/cdefs.h> #if defined(__NetBSD__) -__RCSID("$NetBSD: lexi.c,v 1.78 2021/10/07 23:15:15 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.79 2021/10/08 16:20:33 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $"); #endif @@ -222,8 +222,9 @@ const char * token_type_name(token_type ttype) { static const char *const name[] = { - "end_of_file", "newline", "lparen", "rparen", "unary_op", - "binary_op", "postfix_op", "question", "case_label", "colon", + "end_of_file", "newline", "lparen_or_lbracket", "rparen_or_rbracket", + "unary_op", "binary_op", "postfix_op", "question", + "case_label", "colon", "semicolon", "lbrace", "rbrace", "ident", "comma", "comment", "switch_expr", "preprocessing", "form_feed", "decl", "keyword_for_if_while", "keyword_do_else", @@ -525,12 +526,12 @@ lexi(struct parser_state *state) case '(': case '[': unary_delim = true; - ttype = lparen; + ttype = lparen_or_lbracket; break; case ')': case ']': - ttype = rparen; + ttype = rparen_or_rbracket; break; case '#': @@ -589,7 +590,8 @@ lexi(struct parser_state *state) /* check for doubled character */ *token.e++ = *inp.s++; /* buffer overflow will be checked at end of loop */ - if (state->last_token == ident || state->last_token == rparen) { + if (state->last_token == ident || + state->last_token == rparen_or_rbracket) { ttype = state->last_u_d ? unary_op : postfix_op; /* check for following ++ or -- */ unary_delim = false;