Fix warnings (and sanity-check for 0-bytes in utf8-strings
This commit is contained in:
parent
9d4d62f6a8
commit
e4e26de687
|
@ -141,24 +141,23 @@ int DoChar(int sx, int sy, int c){
|
||||||
|
|
||||||
#define UTF8
|
#define UTF8
|
||||||
// decode 2 and 4-byte utf-8 strings.
|
// decode 2 and 4-byte utf-8 strings.
|
||||||
#define UT2(a,b) ( ((a&31)<<6) + (b&63) )
|
#define UT2(a) ( ((a[0]&31)<<6) + (a[1]&63) )
|
||||||
#define UT3(a,b,c) ( ((a&15)<<12) + ((b&63)<<6) + (c&63) )
|
#define UT3(a) ( ((a[0]&15)<<12) + ((a[1]&63)<<6) + (a[2]&63) )
|
||||||
|
|
||||||
int DoString(int sx, int sy, char *s){
|
int DoString(int sx, int sy, const char *s){
|
||||||
char *c;
|
const char *c;
|
||||||
int uc;
|
int uc;
|
||||||
for(c=s;*c!=0;c++){
|
for(c=s;*c!=0;c++){
|
||||||
#ifdef UTF8
|
#ifdef UTF8
|
||||||
/* will b0rk on non-utf8 */
|
/* will b0rk on non-utf8 */
|
||||||
if((*c&(128+64+32))==(128+64)){
|
if((*c&(128+64+32))==(128+64) && c[1]!=0){
|
||||||
uc=UT2(*c,*(++c));
|
uc=UT2(c); c+=1;
|
||||||
sx=DoChar(sx,sy,uc);
|
sx=DoChar(sx,sy,uc);
|
||||||
}else if( (*c&(128+64+32+16))==(128+64+32)){
|
}else if( (*c&(128+64+32+16))==(128+64+32) && c[1]!=0 && c[2] !=0){
|
||||||
uc=UT3(*c,*(++c),*(++c));
|
uc=UT3(c); c+=2;
|
||||||
sx=DoChar(sx,sy,uc);
|
sx=DoChar(sx,sy,uc);
|
||||||
}else
|
}else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sx=DoChar(sx,sy,*c);
|
sx=DoChar(sx,sy,*c);
|
||||||
};
|
};
|
||||||
return sx;
|
return sx;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int DoChar(int sx, int sy, int c);
|
int DoChar(int sx, int sy, int c);
|
||||||
int DoString(int sx, int sy, char *s);
|
int DoString(int sx, int sy, const char *s);
|
||||||
int DoInt(int sx, int sy, int num);
|
int DoInt(int sx, int sy, int num);
|
||||||
int DoIntX(int sx, int sy, unsigned int num);
|
int DoIntX(int sx, int sy, unsigned int num);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue