diff options
author | rsc <devnull@localhost> | 2004-12-26 23:07:37 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-12-26 23:07:37 +0000 |
commit | df121a0027e6dc08abe6fc907c9af2593a263c17 (patch) | |
tree | 46d2da9546978f65073bab77217e3ce5d2dff544 /src/lib9/fmt/fmtquote.c | |
parent | a76c0fd4a9a9a9a64893db614dd146a5819a6e0c (diff) | |
download | plan9port-df121a0027e6dc08abe6fc907c9af2593a263c17.tar.gz plan9port-df121a0027e6dc08abe6fc907c9af2593a263c17.tar.bz2 plan9port-df121a0027e6dc08abe6fc907c9af2593a263c17.zip |
import changes from plan 9
Diffstat (limited to 'src/lib9/fmt/fmtquote.c')
-rw-r--r-- | src/lib9/fmt/fmtquote.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib9/fmt/fmtquote.c b/src/lib9/fmt/fmtquote.c index b8f00c18..7d659a5a 100644 --- a/src/lib9/fmt/fmtquote.c +++ b/src/lib9/fmt/fmtquote.c @@ -48,7 +48,7 @@ __quotesetup(char *s, Rune *r, int nin, int nout, Quoteinfo *q, int sharp, int r q->nbytesout = 2; q->nrunesout = 2; } - for(; nin!=0; nin-=w){ + for(; nin!=0; nin--){ if(s) w = chartorune(&c, s); else{ @@ -183,12 +183,14 @@ qstrfmt(char *sin, Rune *rin, Quoteinfo *q, Fmt *f) int __quotestrfmt(int runesin, Fmt *f) { - int outlen; + int nin, outlen; Rune *r; char *s; Quoteinfo q; - f->flags &= ~FmtPrec; /* ignored for %q %Q, so disable for %s %S in easy case */ + nin = -1; + if(f->flags&FmtPrec) + nin = f->prec; if(runesin){ r = va_arg(f->args, Rune *); s = nil; @@ -206,7 +208,7 @@ __quotestrfmt(int runesin, Fmt *f) else outlen = (char*)f->stop - (char*)f->to; - __quotesetup(s, r, -1, outlen, &q, f->flags&FmtSharp, f->runes); + __quotesetup(s, r, nin, outlen, &q, f->flags&FmtSharp, f->runes); //print("bytes in %d bytes out %d runes in %d runesout %d\n", q.nbytesin, q.nbytesout, q.nrunesin, q.nrunesout); if(runesin){ |