Module Name:    src
Committed By:   rillig
Date:           Fri Mar 12 17:46:49 UTC 2021

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

Log Message:
indent: move code for tokenizing numbers further up

Having it directly below the table makes it easier understandable.

I also tried to omit this function entirely by moving the code into the
initializer itself, but that made the code redundant and furthermore
increased the size of the resulting binary, probably because of the new
relocation records.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 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.35 src/usr.bin/indent/lexi.c:1.36
--- src/usr.bin/indent/lexi.c:1.35	Thu Mar 11 22:32:06 2021
+++ src/usr.bin/indent/lexi.c	Fri Mar 12 17:46:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.35 2021/03/11 22:32:06 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.36 2021/03/12 17:46:48 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 #include <sys/cdefs.h>
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.35 2021/03/11 22:32:06 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.36 2021/03/12 17:46:48 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -171,6 +171,22 @@ static char const *table[] = {
     [0]   = "uuiifuufiuuiiuiiiiiuiuuuuu",
 };
 
+/* Initialize constant transition table */
+void
+init_constant_tt(void)
+{
+    table['-'] = table['+'];
+    table['8'] = table['9'];
+    table['2'] = table['3'] = table['4'] = table['5'] = table['6'] = table['7'];
+    table['A'] = table['C'] = table['D'] = table['c'] = table['d'] = table['a'];
+    table['B'] = table['b'];
+    table['E'] = table['e'];
+    table['U'] = table['u'];
+    table['X'] = table['x'];
+    table['P'] = table['p'];
+    table['F'] = table['f'];
+}
+
 static char
 inbuf_peek(void)
 {
@@ -671,22 +687,6 @@ stop_lit:
     return lexi_end(code);
 }
 
-/* Initialize constant transition table */
-void
-init_constant_tt(void)
-{
-    table['-'] = table['+'];
-    table['8'] = table['9'];
-    table['2'] = table['3'] = table['4'] = table['5'] = table['6'] = table['7'];
-    table['A'] = table['C'] = table['D'] = table['c'] = table['d'] = table['a'];
-    table['B'] = table['b'];
-    table['E'] = table['e'];
-    table['U'] = table['u'];
-    table['X'] = table['x'];
-    table['P'] = table['p'];
-    table['F'] = table['f'];
-}
-
 void
 alloc_typenames(void)
 {

Reply via email to