mirror of
https://github.com/pikami/st.git
synced 2024-11-29 07:15:43 +00:00
Simplify utf8decodebyte using some locals
These local variables help to make expressions simpler and avoid use a pointer as induction variable in a for loop.
This commit is contained in:
parent
c7a945c408
commit
23af75fc75
19
st.c
19
st.c
@ -453,7 +453,7 @@ static void getbuttoninfo(XEvent *);
|
||||
static void mousereport(XEvent *);
|
||||
|
||||
static size_t utf8decode(char *, long *, size_t);
|
||||
static long utf8decodebyte(char, size_t *);
|
||||
static long utf8decodebyte(uchar, size_t *);
|
||||
static size_t utf8encode(long, char *, size_t);
|
||||
static char utf8encodebyte(long, size_t);
|
||||
static size_t utf8len(char *);
|
||||
@ -590,11 +590,18 @@ utf8decode(char *c, long *u, size_t clen) {
|
||||
}
|
||||
|
||||
long
|
||||
utf8decodebyte(char c, size_t *i) {
|
||||
for(*i = 0; *i < LEN(utfmask); ++(*i))
|
||||
if(((uchar)c & utfmask[*i]) == utfbyte[*i])
|
||||
return (uchar)c & ~utfmask[*i];
|
||||
return 0;
|
||||
utf8decodebyte(uchar c, size_t *len) {
|
||||
size_t i;
|
||||
long ret = 0;
|
||||
|
||||
for(i = 0; i < LEN(utfmask); ++i) {
|
||||
if((c & utfmask[i]) == utfbyte[i]) {
|
||||
ret = c & ~utfmask[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
*len = i;
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t
|
||||
|
Loading…
Reference in New Issue
Block a user