Introduction
Introduction Statistics Contact Development Disclaimer Help
tregex: use bit masks in uc_len() - neatvi - [fork] simple vi-type editor with …
git clone git://src.adamsgaard.dk/neatvi
Log
Files
Refs
README
---
commit 09ae245a5a3197522cab51d55914d331f8512de5
parent a2fe7e9ef29a43cf747296180156b2970b309a53
Author: Ali Gholami Rudi <[email protected]>
Date: Sun, 22 May 2016 12:37:13 +0430
regex: use bit masks in uc_len()
Diffstat:
M regex.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/regex.c b/regex.c
t@@ -96,19 +96,19 @@ static void rnode_free(struct rnode *rnode)
static int uc_len(char *s)
{
int c = (unsigned char) s[0];
- if (c > 0 && c <= 0x7f)
- return 1;
- if (c >= 0xfc)
- return 6;
- if (c >= 0xf8)
- return 5;
- if (c >= 0xf0)
- return 4;
- if (c >= 0xe0)
- return 3;
- if (c >= 0xc0)
+ if (~c & 0x80)
+ return c > 0;
+ if (~c & 0x20)
return 2;
- return c != 0;
+ if (~c & 0x10)
+ return 3;
+ if (~c & 0x08)
+ return 4;
+ if (~c & 0x04)
+ return 5;
+ if (~c & 0x02)
+ return 6;
+ return 1;
}
static int uc_dec(char *s)
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.