diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-12-31 21:09:46 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-12-31 21:09:46 +0100 |
commit | 6cadd03bbeace1c256ba875c2e6a877f924877cd (patch) | |
tree | 8079ea6f6ccdb1c2cbb2b7813f618837617cb33e /sys/src/cmd/vnc | |
parent | 6d99096136278f06f6333f927da34105a8dfe0bf (diff) |
fix utf and rune handling in preparation for 32bit runes
Diffstat (limited to 'sys/src/cmd/vnc')
-rw-r--r-- | sys/src/cmd/vnc/screen.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/sys/src/cmd/vnc/screen.c b/sys/src/cmd/vnc/screen.c index e11155ac9..ce8a7e818 100644 --- a/sys/src/cmd/vnc/screen.c +++ b/sys/src/cmd/vnc/screen.c @@ -335,6 +335,8 @@ screenputc(char *buf) addflush(r); curpos.x = *xp; break; + case '\0': + break; default: p = memsubfontwidth(memdefont, buf); w = p.x; @@ -354,23 +356,19 @@ screenputc(char *buf) void screenputs(char *s, int n) { - int i; - Rune r; - char buf[4]; + static char rb[UTFmax+1]; + static int nrb; + char *e; drawlock(); - while(n > 0){ - i = chartorune(&r, s); - if(i == 0){ - s++; - --n; - continue; + e = s + n; + while(s < e){ + rb[nrb++] = *s++; + if(nrb >= UTFmax || fullrune(rb, nrb)){ + rb[nrb] = 0; + screenputc(rb); + nrb = 0; } - memmove(buf, s, i); - buf[i] = 0; - n -= i; - s += i; - screenputc(buf); } screenflush(); drawunlock(); |