aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/fmt/dofmt.c
diff options
context:
space:
mode:
authorRuss Cox <russcox@gmail.com>2009-09-11 17:03:06 -0400
committerRuss Cox <russcox@gmail.com>2009-09-11 17:03:06 -0400
commit0cadb4301d18724e7513d7489cb5bebd262c82f1 (patch)
tree48209a4083885288eaa09178d4017769897107b3 /src/lib9/fmt/dofmt.c
parent4dbf255619efac4f0a00e4216d6c999128910df2 (diff)
downloadplan9port-0cadb4301d18724e7513d7489cb5bebd262c82f1.tar.gz
plan9port-0cadb4301d18724e7513d7489cb5bebd262c82f1.tar.bz2
plan9port-0cadb4301d18724e7513d7489cb5bebd262c82f1.zip
convert to 4-byte UTF-8 and 32-bit Rune
http://codereview.appspot.com/116075
Diffstat (limited to 'src/lib9/fmt/dofmt.c')
-rw-r--r--src/lib9/fmt/dofmt.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib9/fmt/dofmt.c b/src/lib9/fmt/dofmt.c
index 214b71db..353c76e3 100644
--- a/src/lib9/fmt/dofmt.c
+++ b/src/lib9/fmt/dofmt.c
@@ -605,12 +605,13 @@ __flagfmt(Fmt *f)
int
__badfmt(Fmt *f)
{
- char x[3];
+ char x[2+UTFmax];
+ int n;
x[0] = '%';
- x[1] = f->r;
- x[2] = '%';
- f->prec = 3;
- __fmtcpy(f, (const void*)x, 3, 3);
+ n = 1 + runetochar(x+1, &f->r);
+ x[n++] = '%';
+ f->prec = n;
+ __fmtcpy(f, (const void*)x, n, n);
return 0;
}