All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alecs King <alecsk@gmail.com>
To: linux-sparse <linux-sparse@vger.kernel.org>
Subject: [RFC] [PATCH] clean up cclass
Date: Sat, 31 Dec 2005 15:20:55 +0800	[thread overview]
Message-ID: <20051231072055.GA2323@localhost> (raw)

Is there a good reason to always add that '+ 1' in both initialization
and dereference of cclass?

This patch just remove that unnecessary '+ 1'.

Signed-off-by: Alecs King <alecsk@gmail.com>


diff --git a/tokenize.c b/tokenize.c
index 497da13..7464b5a 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -347,30 +347,30 @@ enum {
 	ValidSecond = 32,
 };
 
-static const long cclass[257] = {
-	['0' + 1 ... '9' + 1] = Digit | Hex,
-	['A' + 1 ... 'D' + 1] = Letter | Hex,
-	['E' + 1] = Letter | Hex | Exp,
-	['F' + 1] = Letter | Hex,
-	['G' + 1 ... 'O' + 1] = Letter,
-	['P' + 1] = Letter | Exp,
-	['Q' + 1 ... 'Z' + 1] = Letter,
-	['a' + 1 ... 'd' + 1] = Letter | Hex,
-	['e' + 1] = Letter | Hex | Exp,
-	['f' + 1] = Letter | Hex,
-	['g' + 1 ... 'o' + 1] = Letter,
-	['p' + 1] = Letter | Exp,
-	['q' + 1 ... 'z' + 1] = Letter,
-	['_' + 1] = Letter,
-	['.' + 1] = Dot | ValidSecond,
-	['=' + 1] = ValidSecond,
-	['+' + 1] = ValidSecond,
-	['-' + 1] = ValidSecond,
-	['>' + 1] = ValidSecond,
-	['<' + 1] = ValidSecond,
-	['&' + 1] = ValidSecond,
-	['|' + 1] = ValidSecond,
-	['#' + 1] = ValidSecond,
+static const long cclass[256] = {
+	['0' ... '9'] = Digit | Hex,
+	['A' ... 'D'] = Letter | Hex,
+	['E'] = Letter | Hex | Exp,
+	['F'] = Letter | Hex,
+	['G' ... 'O'] = Letter,
+	['P'] = Letter | Exp,
+	['Q' ... 'Z'] = Letter,
+	['a' ... 'd'] = Letter | Hex,
+	['e'] = Letter | Hex | Exp,
+	['f'] = Letter | Hex,
+	['g' ... 'o'] = Letter,
+	['p'] = Letter | Exp,
+	['q' ... 'z'] = Letter,
+	['_'] = Letter,
+	['.'] = Dot | ValidSecond,
+	['='] = ValidSecond,
+	['+'] = ValidSecond,
+	['-'] = ValidSecond,
+	['>'] = ValidSecond,
+	['<'] = ValidSecond,
+	['&'] = ValidSecond,
+	['|'] = ValidSecond,
+	['#'] = ValidSecond,
 };
 
 /*
@@ -394,7 +394,7 @@ static int get_one_number(int c, int nex
 
 	*p++ = c;
 	for (;;) {
-		long class =  cclass[next + 1];
+		long class =  cclass[next];
 		if (!(class & (Dot | Digit | Letter)))
 			break;
 		if (p != buffer_end)
@@ -647,7 +647,7 @@ static int get_one_special(int c, stream
 	 * Check for combinations
 	 */
 	value = c;
-	if (cclass[next + 1] & ValidSecond) {
+	if (cclass[next] & ValidSecond) {
 		comb = combinations[0];
 		c1 = c; c2 = next; c3 = 0;
 		for (i = 0; i < NR_COMBINATIONS; i++) {
@@ -810,7 +810,7 @@ static int get_one_identifier(int c, str
 	buf[0] = c;
 	for (;;) {
 		next = nextchar(stream);
-		if (!(cclass[next + 1] & (Letter | Digit)))
+		if (!(cclass[next] & (Letter | Digit)))
 			break;
 		if (len >= sizeof(buf))
 			break;
@@ -832,7 +832,7 @@ static int get_one_identifier(int c, str
 
 static int get_one_token(int c, stream_t *stream)
 {
-	long class = cclass[c + 1];
+	long class = cclass[c];
 	if (class & Digit)
 		return get_one_number(c, nextchar(stream), stream);
 	if (class & Letter)

-- 
Alecs King

             reply	other threads:[~2005-12-31  7:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-31  7:20 Alecs King [this message]
2005-12-31 21:26 ` [RFC] [PATCH] clean up cclass Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051231072055.GA2323@localhost \
    --to=alecsk@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.