summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/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/ape/lib/fmt
parent6d99096136278f06f6333f927da34105a8dfe0bf (diff)
fix utf and rune handling in preparation for 32bit runes
Diffstat (limited to 'sys/src/ape/lib/fmt')
-rw-r--r--sys/src/ape/lib/fmt/dofmt.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/src/ape/lib/fmt/dofmt.c b/sys/src/ape/lib/fmt/dofmt.c
index 014b66257..7f314e93e 100644
--- a/sys/src/ape/lib/fmt/dofmt.c
+++ b/sys/src/ape/lib/fmt/dofmt.c
@@ -546,12 +546,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, (const void*)x, 3, 3);
+ n = 1+runetochar(x+1, &r);
+ x[n++] = '%';
+ f->prec = n;
+ __fmtcpy(f, x, n, n);
return 0;
}