toops - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit ab239cb5ba1e3e72d53a55ca2a2e97469c29e884
 (DIR) parent f3b8bf7f4ee326d9de31947584c6e9dbbfa75ce6
 (HTM) Author: rsc <devnull@localhost>
       Date:   Fri, 26 May 2006 00:53:07 +0000
       
       oops
       
       Diffstat:
         M src/lib9/fmt/dofmt.c                |       8 ++++++++
         M src/lib9/fmt/fmtquote.c             |       5 +++++
         M src/lib9/fmt/runevseprint.c         |       1 +
         M src/lib9/fmt/vseprint.c             |       1 +
       
       4 files changed, 15 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/lib9/fmt/dofmt.c b/src/lib9/fmt/dofmt.c
       t@@ -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));
 (DIR) diff --git a/src/lib9/fmt/fmtquote.c b/src/lib9/fmt/fmtquote.c
       t@@ -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
                }
        }
        
 (DIR) diff --git a/src/lib9/fmt/runevseprint.c b/src/lib9/fmt/runevseprint.c
       t@@ -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';
 (DIR) diff --git a/src/lib9/fmt/vseprint.c b/src/lib9/fmt/vseprint.c
       t@@ -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';