oops
This commit is contained in:
parent
f3b8bf7f4e
commit
ab239cb5ba
4 changed files with 15 additions and 0 deletions
|
|
@ -252,9 +252,17 @@ fmtstrcpy(Fmt *f, char *s)
|
||||||
return __fmtcpy(f, "<nil>", 5, 5);
|
return __fmtcpy(f, "<nil>", 5, 5);
|
||||||
/* if precision is specified, make sure we don't wander off the end */
|
/* if precision is specified, make sure we don't wander off the end */
|
||||||
if(f->flags & FmtPrec){
|
if(f->flags & FmtPrec){
|
||||||
|
#ifdef PLAN9PORT
|
||||||
i = 0;
|
i = 0;
|
||||||
for(j=0; j<f->prec && s[i]; j++)
|
for(j=0; j<f->prec && s[i]; j++)
|
||||||
i += chartorune(&r, s+i);
|
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, j, i);
|
||||||
}
|
}
|
||||||
return __fmtcpy(f, s, utflen(s), strlen(s));
|
return __fmtcpy(f, s, utflen(s), strlen(s));
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,11 @@ __quotesetup(char *s, Rune *r, int nin, int nout, Quoteinfo *q, int sharp, int r
|
||||||
/* advance output */
|
/* advance output */
|
||||||
q->nbytesout += w;
|
q->nbytesout += w;
|
||||||
q->nrunesout++;
|
q->nrunesout++;
|
||||||
|
|
||||||
|
#ifndef PLAN9PORT
|
||||||
|
/* ANSI requires precision in bytes, not Runes. */
|
||||||
|
nin-= w-1; /* and then n-- in the loop */
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ runevseprint(Rune *buf, Rune *e, char *fmt, va_list args)
|
||||||
f.farg = nil;
|
f.farg = nil;
|
||||||
f.nfmt = 0;
|
f.nfmt = 0;
|
||||||
VA_COPY(f.args,args);
|
VA_COPY(f.args,args);
|
||||||
|
fmtlocaleinit(&f, nil, nil, nil);
|
||||||
dofmt(&f, fmt);
|
dofmt(&f, fmt);
|
||||||
VA_END(f.args);
|
VA_END(f.args);
|
||||||
*(Rune*)f.to = '\0';
|
*(Rune*)f.to = '\0';
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ vseprint(char *buf, char *e, char *fmt, va_list args)
|
||||||
f.farg = nil;
|
f.farg = nil;
|
||||||
f.nfmt = 0;
|
f.nfmt = 0;
|
||||||
VA_COPY(f.args,args);
|
VA_COPY(f.args,args);
|
||||||
|
fmtlocaleinit(&f, nil, nil, nil);
|
||||||
dofmt(&f, fmt);
|
dofmt(&f, fmt);
|
||||||
VA_END(f.args);
|
VA_END(f.args);
|
||||||
*(char*)f.to = '\0';
|
*(char*)f.to = '\0';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue