Module Name:    src
Committed By:   rillig
Date:           Tue Oct  5 22:09:05 UTC 2021

Modified Files:
        src/usr.bin/indent: .indent.pro lexi.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/indent/.indent.pro
cvs rdiff -u -r1.70 -r1.71 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.pro
diff -u src/usr.bin/indent/.indent.pro:1.1 src/usr.bin/indent/.indent.pro:1.2
--- src/usr.bin/indent/.indent.pro:1.1	Sun Sep 26 19:02:35 2021
+++ src/usr.bin/indent/.indent.pro	Tue Oct  5 22:09:05 2021
@@ -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. */

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.70 src/usr.bin/indent/lexi.c:1.71
--- src/usr.bin/indent/lexi.c:1.70	Tue Oct  5 21:55:22 2021
+++ src/usr.bin/indent/lexi.c	Tue Oct  5 22:09:05 2021
@@ -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 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #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 @@ struct {
  * 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 @@ static const char num_lex_state[][26] = 
     [15] =  "B EE    EE   T      W     ",
     /*       ABCDEFGHIJKLMNOPQRSTUVWXYZ */
 };
+/* INDENT ON */
 
 static const uint8_t num_lex_row[] = {
     ['0'] = 1,
@@ -259,19 +261,19 @@ lexi_end(token_type ttype)
     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 @@ probably_typedef(const struct parser_sta
     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 @@ lexi(struct parser_state *state)
 		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 @@ lexi(struct parser_state *state)
 }
 
 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;
 

Reply via email to