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: move code for tokenizing numbers furt...



details:   https://anonhg.NetBSD.org/src/rev/a05afe58ac52
branches:  trunk
changeset: 960238:a05afe58ac52
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Mar 12 17:46:48 2021 +0000

description:
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.

diffstat:

 usr.bin/indent/lexi.c |  36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)

diffs (64 lines):

diff -r 2ef4c7eec1ef -r a05afe58ac52 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Fri Mar 12 17:41:10 2021 +0000
+++ b/usr.bin/indent/lexi.c     Fri Mar 12 17:46:48 2021 +0000
@@ -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 @@
 #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 @@
     [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 @@
     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)
 {



Home | Main Index | Thread Index | Old Index