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: run indent on lexi.c, with manual cor...
details: https://anonhg.NetBSD.org/src/rev/02e0585e8207
branches: trunk
changeset: 988262:02e0585e8207
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Oct 05 22:09:05 2021 +0000
description:
indent: run indent on lexi.c, with manual corrections
The variables 'keywords' and 'typenames' were indented using 8 spaces,
even though -di0 was in effect, which should result in a single space,
and -ut was in effect, which should result in a single tab instead of 8
spaces.
The option -eei does not work as advertised, the controlling expressions
are only indented by the normal amount, which easily leads to confusion
as to whether the code belongs to the condition or the following
statement.
diffstat:
usr.bin/indent/.indent.pro | 4 +++-
usr.bin/indent/lexi.c | 21 ++++++++++++---------
2 files changed, 15 insertions(+), 10 deletions(-)
diffs (100 lines):
diff -r 98c2959269b9 -r 02e0585e8207 usr.bin/indent/.indent.pro
--- a/usr.bin/indent/.indent.pro Tue Oct 05 21:55:22 2021 +0000
+++ b/usr.bin/indent/.indent.pro Tue Oct 05 22:09:05 2021 +0000
@@ -1,6 +1,8 @@
-/* $NetBSD: .indent.pro,v 1.1 2021/09/26 19:02:35 rillig Exp $ */
+/* $NetBSD: .indent.pro,v 1.2 2021/10/05 22:09:05 rillig Exp $ */
-di0 /* Do not indent variable names in global declarations. */
+/* XXX: -eei does not work; the expressions are indented only a single level. */
+-eei /* Indent expressions in 'if' and 'while' once more. */
-nfc1 /* Do not format CVS Id comments. */
-i4 /* Indent by 4 spaces, for traditional reasons. */
-ldi0 /* Do not indent variable names in local declarations. */
diff -r 98c2959269b9 -r 02e0585e8207 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Tue Oct 05 21:55:22 2021 +0000
+++ b/usr.bin/indent/lexi.c Tue Oct 05 22:09:05 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.70 2021/10/05 21:55:22 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.71 2021/10/05 22:09:05 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.70 2021/10/05 21:55:22 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.71 2021/10/05 22:09:05 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -128,6 +128,7 @@
* HP H* "." H+ P FS? -> $float; "0" O* IS? -> $int;
* HP H+ "." P FS -> $float; BP B+ IS? -> $int;
*/
+/* INDENT OFF */
static const char num_lex_state[][26] = {
/* examples:
00
@@ -155,6 +156,7 @@
[15] = "B EE EE T W ",
/* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
};
+/* INDENT ON */
static const uint8_t num_lex_row[] = {
['0'] = 1,
@@ -259,19 +261,19 @@
return ttype;
}
#else
-# define lexi_end(tk) (tk)
+#define lexi_end(tk) (tk)
#endif
static void
lex_number(void)
{
- for (uint8_t s = 'A'; s != 'f' && s != 'i' && s != 'u'; ) {
+ for (uint8_t s = 'A'; s != 'f' && s != 'i' && s != 'u';) {
uint8_t ch = (uint8_t)*buf_ptr;
if (ch >= nitems(num_lex_row) || num_lex_row[ch] == 0)
break;
uint8_t row = num_lex_row[ch];
if (num_lex_state[row][s - 'A'] == ' ') {
- /*
+ /*-
* num_lex_state[0][s - 'A'] now indicates the type:
* f = floating, ch = integer, u = unknown
*/
@@ -341,8 +343,8 @@
return false;
maybe:
return state->last_token == semicolon ||
- state->last_token == lbrace ||
- state->last_token == rbrace;
+ state->last_token == lbrace ||
+ state->last_token == rbrace;
}
static bool
@@ -430,7 +432,7 @@
return lexi_end(case_label);
case kw_struct_or_union_or_enum:
case kw_type:
- found_typename:
+ found_typename:
if (state->p_l_follow != 0) {
/* inside parens: cast, param list, offsetof or sizeof */
state->cast_mask |= (1 << state->p_l_follow) & ~state->not_cast_mask;
@@ -672,7 +674,8 @@
}
static int
-insert_pos(const char *key, const char **arr, unsigned int len) {
+insert_pos(const char *key, const char **arr, unsigned int len)
+{
int lo = 0;
int hi = (int)len - 1;
Home |
Main Index |
Thread Index |
Old Index