* [PATCH 1/2] cclass: char is wide enough
2017-09-19 2:55 [PATCH 0/2] cleanup of cclass[] Luc Van Oostenryck
@ 2017-09-19 2:55 ` Luc Van Oostenryck
2017-09-19 2:56 ` [PATCH 2/2] cclass: cleanup Luc Van Oostenryck
1 sibling, 0 replies; 3+ messages in thread
From: Luc Van Oostenryck @ 2017-09-19 2:55 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
The table for character classes is declared as 'long cclass[]'
but there is no more reasons for such a wide type, 'int', or even
'char' is enough here.
Change this to use 'char' instead of 'long'.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
tokenize.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tokenize.c b/tokenize.c
index 99b958035..7e68cf1ee 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -483,7 +483,7 @@ enum {
Quote = 64,
};
-static const long cclass[257] = {
+static const char cclass[257] = {
['0' + 1 ... '7' + 1] = Digit | Hex, /* \<octal> */
['8' + 1 ... '9' + 1] = Digit | Hex,
['A' + 1 ... 'D' + 1] = Letter | Hex,
--
2.14.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] cclass: cleanup
2017-09-19 2:55 [PATCH 0/2] cleanup of cclass[] Luc Van Oostenryck
2017-09-19 2:55 ` [PATCH 1/2] cclass: char is wide enough Luc Van Oostenryck
@ 2017-09-19 2:56 ` Luc Van Oostenryck
1 sibling, 0 replies; 3+ messages in thread
From: Luc Van Oostenryck @ 2017-09-19 2:56 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
The table of charatcer classes: cclass[] used to contain information
about escaped chars but this is no more the case.
Simplify the table by merging sequence of character of same classes
and remove old comment about the escape.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
tokenize.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/tokenize.c b/tokenize.c
index 7e68cf1ee..aa4dc1840 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -484,31 +484,19 @@ enum {
};
static const char cclass[257] = {
- ['0' + 1 ... '7' + 1] = Digit | Hex, /* \<octal> */
- ['8' + 1 ... '9' + 1] = Digit | Hex,
+ ['0' + 1 ... '9' + 1] = Digit | Hex,
['A' + 1 ... 'D' + 1] = Letter | Hex,
['E' + 1] = Letter | Hex | Exp, /* E<exp> */
['F' + 1] = Letter | Hex,
['G' + 1 ... 'O' + 1] = Letter,
['P' + 1] = Letter | Exp, /* P<exp> */
['Q' + 1 ... 'Z' + 1] = Letter,
- ['a' + 1 ... 'b' + 1] = Letter | Hex, /* \a, \b */
- ['c' + 1 ... 'd' + 1] = Letter | Hex,
- ['e' + 1] = Letter | Hex | Exp,/* \e, e<exp> */
- ['f' + 1] = Letter | Hex, /* \f */
- ['g' + 1 ... 'm' + 1] = Letter,
- ['n' + 1] = Letter, /* \n */
- ['o' + 1] = Letter,
+ ['a' + 1 ... 'd' + 1] = Letter | Hex,
+ ['e' + 1] = Letter | Hex | Exp, /* e<exp> */
+ ['f' + 1] = Letter | Hex,
+ ['g' + 1 ... 'o' + 1] = Letter,
['p' + 1] = Letter | Exp, /* p<exp> */
- ['q' + 1] = Letter,
- ['r' + 1] = Letter, /* \r */
- ['s' + 1] = Letter,
- ['t' + 1] = Letter, /* \t */
- ['u' + 1] = Letter,
- ['v' + 1] = Letter, /* \v */
- ['w' + 1] = Letter,
- ['x' + 1] = Letter, /* \x<hex> */
- ['y' + 1 ... 'z' + 1] = Letter,
+ ['q' + 1 ... 'z' + 1] = Letter,
['_' + 1] = Letter,
['.' + 1] = Dot | ValidSecond,
['=' + 1] = ValidSecond,
--
2.14.0
^ permalink raw reply related [flat|nested] 3+ messages in thread