convert to 4-byte UTF-8 and 32-bit Rune
http://codereview.appspot.com/116075
This commit is contained in:
parent
4dbf255619
commit
0cadb4301d
14 changed files with 86 additions and 44 deletions
|
|
@ -193,7 +193,7 @@ winctl(void *arg)
|
|||
Rune *rp, *bp, *up, *kbdr;
|
||||
uint qh;
|
||||
int nr, nb, c, wid, i, npart, initial, lastb;
|
||||
char *s, *t, part[3];
|
||||
char *s, *t, part[UTFmax];
|
||||
Window *w;
|
||||
Mousestate *mp, m;
|
||||
enum { WKey, WMouse, WMouseread, WCtl, WCwrite, WCread, WWread, NWALT };
|
||||
|
|
|
|||
|
|
@ -488,7 +488,7 @@ bldcclass(void)
|
|||
exprp++; /* eat '-' */
|
||||
if((c2 = nextrec()) == ']')
|
||||
goto Error;
|
||||
classp[n+0] = 0xFFFF;
|
||||
classp[n+0] = Runemax;
|
||||
classp[n+1] = c1;
|
||||
classp[n+2] = c2;
|
||||
n += 3;
|
||||
|
|
@ -510,7 +510,7 @@ classmatch(int classno, int c, int negate)
|
|||
|
||||
p = class[classno];
|
||||
while(*p){
|
||||
if(*p == 0xFFFF){
|
||||
if(*p == Runemax){
|
||||
if(p[1]<=c && c<=p[2])
|
||||
return !negate;
|
||||
p += 3;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ int
|
|||
inputc(void)
|
||||
{
|
||||
int n, nbuf;
|
||||
char buf[3];
|
||||
char buf[UTFmax];
|
||||
Rune r;
|
||||
|
||||
Again:
|
||||
|
|
|
|||
|
|
@ -494,7 +494,7 @@ bldcclass(void)
|
|||
exprp++; /* eat '-' */
|
||||
if((c2 = nextrec()) == ']')
|
||||
goto Error;
|
||||
classp[n+0] = 0xFFFF;
|
||||
classp[n+0] = Runemax;
|
||||
classp[n+1] = c1;
|
||||
classp[n+2] = c2;
|
||||
n += 3;
|
||||
|
|
@ -516,7 +516,7 @@ classmatch(int classno, int c, int negate)
|
|||
|
||||
p = class[classno];
|
||||
while(*p){
|
||||
if(*p == 0xFFFF){
|
||||
if(*p == Runemax){
|
||||
if(p[1]<=c && c<=p[2])
|
||||
return !negate;
|
||||
p += 3;
|
||||
|
|
|
|||
|
|
@ -615,7 +615,7 @@ compsub(Rune *rhs, Rune *end)
|
|||
while ((r = *cp++) != '\0') {
|
||||
if(r == '\\') {
|
||||
if (rhs < end)
|
||||
*rhs++ = 0xFFFF;
|
||||
*rhs++ = Runemax;
|
||||
else
|
||||
return 0;
|
||||
r = *cp++;
|
||||
|
|
@ -1050,7 +1050,7 @@ dosub(Rune *rhsbuf)
|
|||
sp = place(sp, loc1, loc2);
|
||||
continue;
|
||||
}
|
||||
if (c == 0xFFFF && (c = *rp++) >= '1' && c < MAXSUB+'0') {
|
||||
if (c == Runemax && (c = *rp++) >= '1' && c < MAXSUB+'0') {
|
||||
n = c-'0';
|
||||
if (subexp[n].s.rsp && subexp[n].e.rep) {
|
||||
sp = place(sp, subexp[n].s.rsp, subexp[n].e.rep);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ uchar bits[] = { 1, 2, 4, 8, 16, 32, 64, 128 };
|
|||
#define CLEARBIT(a,c) ((a)[(c)/8] &= ~bits[(c)&07])
|
||||
#define BITSET(a,c) ((a)[(c)/8] & bits[(c)&07])
|
||||
|
||||
#define MAXRUNE 0xFFFF
|
||||
#define MAXRUNE Runemax
|
||||
|
||||
uchar f[(MAXRUNE+1)/8];
|
||||
uchar t[(MAXRUNE+1)/8];
|
||||
|
|
|
|||
|
|
@ -152,9 +152,9 @@ wcstombs(char *s, const wchar_t *pwcs, size_t n)
|
|||
if(p+d <= pe+3) {
|
||||
*p++ = buf[0];
|
||||
if(d > 1) {
|
||||
*p++ = buf[2];
|
||||
*p++ = buf[1];
|
||||
if(d > 2)
|
||||
*p++ = buf[3];
|
||||
*p++ = buf[2];
|
||||
}
|
||||
}
|
||||
if(c == 0)
|
||||
|
|
|
|||
|
|
@ -51,13 +51,13 @@ range(char *argv[])
|
|||
return "bad range";
|
||||
}
|
||||
min = strtoul(q, &q, 16);
|
||||
if(min<0 || min>0xFFFF || *q!='-')
|
||||
if(min<0 || min>Runemax || *q!='-')
|
||||
goto err;
|
||||
q++;
|
||||
if(strchr(hex, *q) == 0)
|
||||
goto err;
|
||||
max = strtoul(q, &q, 16);
|
||||
if(max<0 || max>0xFFFF || max<min || *q!=0)
|
||||
if(max<0 || max>Runemax || max<min || *q!=0)
|
||||
goto err;
|
||||
i = 0;
|
||||
do{
|
||||
|
|
@ -111,7 +111,7 @@ chars(char *argv[])
|
|||
return "bad char";
|
||||
}
|
||||
m = strtoul(q, &q, 16);
|
||||
if(m<0 || m>0xFFFF || *q!=0)
|
||||
if(m<0 || m>Runemax || *q!=0)
|
||||
goto err;
|
||||
Bprint(&bout, "%C", m);
|
||||
if(!text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue