Module Name: src
Committed By: rillig
Date: Tue Oct 5 21:55:22 UTC 2021
Modified Files:
src/usr.bin/indent: lexi.c
Log Message:
indent: untangle complicated condition in probably_typedef
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 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/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.69 src/usr.bin/indent/lexi.c:1.70
--- src/usr.bin/indent/lexi.c:1.69 Tue Oct 5 06:15:24 2021
+++ src/usr.bin/indent/lexi.c Tue Oct 5 21:55:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.69 2021/10/05 06:15:24 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.70 2021/10/05 21:55:22 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.69 2021/10/05 06:15:24 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.70 2021/10/05 21:55:22 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -330,11 +330,19 @@ lex_char_or_string(void)
static bool
probably_typedef(const struct parser_state *state)
{
- return state->p_l_follow == 0 && !state->block_init && !state->in_stmt &&
- ((*buf_ptr == '*' && buf_ptr[1] != '=') ||
- isalpha((unsigned char)*buf_ptr)) &&
- (state->last_token == semicolon || state->last_token == lbrace ||
- state->last_token == rbrace);
+ if (state->p_l_follow != 0)
+ return false;
+ if (state->block_init || state->in_stmt)
+ return false;
+ if (buf_ptr[0] == '*' && buf_ptr[1] != '=')
+ goto maybe;
+ if (isalpha((unsigned char)*buf_ptr))
+ goto maybe;
+ return false;
+maybe:
+ return state->last_token == semicolon ||
+ state->last_token == lbrace ||
+ state->last_token == rbrace;
}
static bool