summaryrefslogtreecommitdiff
path: root/sys/src/libc/fmt
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-12-31 21:09:46 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2012-12-31 21:09:46 +0100
commit6cadd03bbeace1c256ba875c2e6a877f924877cd (patch)
tree8079ea6f6ccdb1c2cbb2b7813f618837617cb33e /sys/src/libc/fmt
parent6d99096136278f06f6333f927da34105a8dfe0bf (diff)
fix utf and rune handling in preparation for 32bit runes
Diffstat (limited to 'sys/src/libc/fmt')
-rw-r--r--sys/src/libc/fmt/dofmt.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/src/libc/fmt/dofmt.c b/sys/src/libc/fmt/dofmt.c
index 2a4b42959..95852f5c2 100644
--- a/sys/src/libc/fmt/dofmt.c
+++ b/sys/src/libc/fmt/dofmt.c
@@ -512,12 +512,15 @@ _flagfmt(Fmt *f)
int
_badfmt(Fmt *f)
{
- char x[3];
+ char x[2+UTFmax];
+ Rune r;
+ int n;
+ r = f->r;
x[0] = '%';
- x[1] = f->r;
- x[2] = '%';
- f->prec = 3;
- _fmtcpy(f, x, 3, 3);
+ n = 1+runetochar(x+1, &r);
+ x[n++] = '%';
+ f->prec = n;
+ _fmtcpy(f, x, n, n);
return 0;
}