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: merge duplicate code in lexi_alnum



details:   https://anonhg.NetBSD.org/src/rev/49722397cae6
branches:  trunk
changeset: 990412:49722397cae6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Oct 26 18:36:25 2021 +0000

description:
indent: merge duplicate code in lexi_alnum

diffstat:

 usr.bin/indent/lexi.c |  16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diffs (41 lines):

diff -r c55f1c05689d -r 49722397cae6 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Tue Oct 26 17:33:18 2021 +0000
+++ b/usr.bin/indent/lexi.c     Tue Oct 26 18:36:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.101 2021/10/25 21:33:24 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.102 2021/10/26 18:36:25 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.101 2021/10/25 21:33:24 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.102 2021/10/26 18:36:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -434,17 +434,15 @@
 static lexer_symbol
 lexi_alnum(struct parser_state *state)
 {
-    if (!(isalnum((unsigned char)*inp.s) ||
-           *inp.s == '_' || *inp.s == '$' ||
-           (inp.s[0] == '.' && isdigit((unsigned char)inp.s[1]))))
-       return lsym_eof;        /* just as a placeholder */
-
     if (isdigit((unsigned char)*inp.s) ||
        (inp.s[0] == '.' && isdigit((unsigned char)inp.s[1]))) {
        lex_number();
-    } else {
+    } else if ((isalnum((unsigned char)*inp.s) ||
+               *inp.s == '_' || *inp.s == '$')) {
        lex_word();
-    }
+    } else
+       return lsym_eof;        /* just as a placeholder */
+
     *token.e = '\0';
 
     if (token.s[0] == 'L' && token.s[1] == '\0' &&



Home | Main Index | Thread Index | Old Index