commit ab239cb5ba1e3e72d53a55ca2a2e97469c29e884
parent f3b8bf7f4ee326d9de31947584c6e9dbbfa75ce6
Author: rsc <devnull@localhost>
Date: Fri, 26 May 2006 00:53:07 +0000
oops
Diffstat:
4 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/lib9/fmt/dofmt.c b/src/lib9/fmt/dofmt.c
@@ -252,9 +252,17 @@ fmtstrcpy(Fmt *f, char *s)
return __fmtcpy(f, "<nil>", 5, 5);
/* if precision is specified, make sure we don't wander off the end */
if(f->flags & FmtPrec){
+#ifdef PLAN9PORT
i = 0;
for(j=0; j<f->prec && s[i]; j++)
i += chartorune(&r, s+i);
+#else
+ /* ANSI requires precision in bytes, not Runes */
+ for(i=0; i<f->prec; i++)
+ if(s[i] == 0)
+ break;
+ j = utfnlen(s, i); /* won't print partial at end */
+#endif
return __fmtcpy(f, s, j, i);
}
return __fmtcpy(f, s, utflen(s), strlen(s));
diff --git a/src/lib9/fmt/fmtquote.c b/src/lib9/fmt/fmtquote.c
@@ -91,6 +91,11 @@ __quotesetup(char *s, Rune *r, int nin, int nout, Quoteinfo *q, int sharp, int r
/* advance output */
q->nbytesout += w;
q->nrunesout++;
+
+#ifndef PLAN9PORT
+ /* ANSI requires precision in bytes, not Runes. */
+ nin-= w-1; /* and then n-- in the loop */
+#endif
}
}
diff --git a/src/lib9/fmt/runevseprint.c b/src/lib9/fmt/runevseprint.c
@@ -20,6 +20,7 @@ runevseprint(Rune *buf, Rune *e, char *fmt, va_list args)
f.farg = nil;
f.nfmt = 0;
VA_COPY(f.args,args);
+ fmtlocaleinit(&f, nil, nil, nil);
dofmt(&f, fmt);
VA_END(f.args);
*(Rune*)f.to = '\0';
diff --git a/src/lib9/fmt/vseprint.c b/src/lib9/fmt/vseprint.c
@@ -19,6 +19,7 @@ vseprint(char *buf, char *e, char *fmt, va_list args)
f.farg = nil;
f.nfmt = 0;
VA_COPY(f.args,args);
+ fmtlocaleinit(&f, nil, nil, nil);
dofmt(&f, fmt);
VA_END(f.args);
*(char*)f.to = '\0';