diff options
author | rsc <devnull@localhost> | 2006-05-26 00:53:07 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-05-26 00:53:07 +0000 |
commit | ab239cb5ba1e3e72d53a55ca2a2e97469c29e884 (patch) | |
tree | 688432115f6e76cbf2d03fc7dee59bc5a0b35680 /src/lib9 | |
parent | f3b8bf7f4ee326d9de31947584c6e9dbbfa75ce6 (diff) | |
download | plan9port-ab239cb5ba1e3e72d53a55ca2a2e97469c29e884.tar.gz plan9port-ab239cb5ba1e3e72d53a55ca2a2e97469c29e884.tar.bz2 plan9port-ab239cb5ba1e3e72d53a55ca2a2e97469c29e884.zip |
oops
Diffstat (limited to 'src/lib9')
-rw-r--r-- | src/lib9/fmt/dofmt.c | 8 | ||||
-rw-r--r-- | src/lib9/fmt/fmtquote.c | 5 | ||||
-rw-r--r-- | src/lib9/fmt/runevseprint.c | 1 | ||||
-rw-r--r-- | src/lib9/fmt/vseprint.c | 1 |
4 files changed, 15 insertions, 0 deletions
diff --git a/src/lib9/fmt/dofmt.c b/src/lib9/fmt/dofmt.c index 74697eb5..e4e32bf4 100644 --- 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 index 5b8f9fd4..8c8daaee 100644 --- 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 index d789cbe7..24e2f178 100644 --- 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 index 0f7ba9db..1b92d2a9 100644 --- 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'; |