URI: 
       tincorporate changes from Google - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit e17e1a71c2923717723f7038d6e123b6452e0b13
   DIR parent f8955f181efa175573ccecc71a19464fdba50ef5
  HTML Author: rsc <devnull@localhost>
       Date:   Mon, 22 May 2006 14:54:34 +0000
       
       incorporate changes from Google
       
       Diffstat:
         M src/lib9/fmt/LICENSE                |      10 ++++++----
         M src/lib9/fmt/dofmt.c                |      27 ++++++++++++++++++++++-----
         M src/lib9/fmt/fmtdef.h               |       1 +
         M src/lib9/fmt/fmtlocale.c            |       7 +++----
         A src/lib9/fmt/fmtnull.c              |      33 +++++++++++++++++++++++++++++++
         M src/lib9/fmt/test.c                 |       2 ++
       
       6 files changed, 67 insertions(+), 13 deletions(-)
       ---
   DIR diff --git a/src/lib9/fmt/LICENSE b/src/lib9/fmt/LICENSE
       t@@ -2,16 +2,18 @@
         * The authors of this software are Rob Pike and Ken Thompson,
         * with contributions from Mike Burrows and Sean Dorward.
         *
       - *              Copyright (c) 2002-2006 by Lucent Technologies.
       + *     Copyright (c) 2002-2006 by Lucent Technologies.
       + *     Portions Copyright (c) 2004 Google Inc.
       + * 
         * Permission to use, copy, modify, and distribute this software for any
         * purpose without fee is hereby granted, provided that this entire notice
         * is included in all copies of any software which is or includes a copy
         * or modification of this software and in all copies of the supporting
         * documentation for such software.
         * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
       - * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
       - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
       - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
       + * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES 
       + * NOR GOOGLE INC MAKE ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING 
       + * THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
        
        This is a Unix port of the Plan 9 formatted I/O package.
   DIR diff --git a/src/lib9/fmt/dofmt.c b/src/lib9/fmt/dofmt.c
       t@@ -1,4 +1,6 @@
        /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
       +/* Copyright (c) 2004 Google Inc.; see LICENSE */
       +
        #include <stdarg.h>
        #include <string.h>
        #include "plan9.h"
       t@@ -454,11 +456,26 @@ __ifmt(Fmt *f)
                        }
                }
                if(n == 0){
       -                *p-- = '0';
       -                n = 1;
       -                if(fl & FmtApost)
       -                        __needsep(&ndig, &grouping);
       -                fl &= ~FmtSharp;        /* ??? */
       +                /*
       +                 * "The result of converting a zero value with
       +                 * a precision of zero is no characters."  - ANSI
       +                 *
       +                 * "For o conversion, # increases the precision, if and only if
       +                 * necessary, to force the first digit of the result to be a zero
       +                 * (if the value and precision are both 0, a single 0 is printed)." - ANSI
       +                 */
       +                if(!(fl & FmtPrec) || f->prec != 0 || (f->r == 'o' && (fl & FmtSharp))){
       +                        *p-- = '0';
       +                        n = 1;
       +                        if(fl & FmtApost)
       +                                __needsep(&ndig, &grouping);
       +                }
       +                
       +                /*
       +                 * Zero values don't get 0x.
       +                 */
       +                if(f->r == 'x' || f->r == 'X')
       +                        fl &= ~FmtSharp;
                }
                for(w = f->prec; n < w && p > buf+3; n++){
                        if((fl & FmtApost) && __needsep(&ndig, &grouping)){
   DIR diff --git a/src/lib9/fmt/fmtdef.h b/src/lib9/fmt/fmtdef.h
       t@@ -41,6 +41,7 @@ void         __fmtunlock(void);
        int          __ifmt(Fmt *f);
        int          __isInf(double d, int sign);
        int          __isNaN(double d);
       +int          __needsep(int*, char**);
        int          __needsquotes(char *s, int *quotelenp);
        int          __percentfmt(Fmt *f);
        void         __quotesetup(char *s, Rune *r, int nin, int nout, Quoteinfo *q, int sharp, int runesout);
   DIR diff --git a/src/lib9/fmt/fmtlocale.c b/src/lib9/fmt/fmtlocale.c
       t@@ -1,12 +1,11 @@
       -/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
       +/* Copyright (c) 2004 Google Inc.; see LICENSE */
       +
        #include <stdarg.h>
        #include <string.h>
        #include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
       -/* XXX GOOGLE COPYRIGHT */
       -
        /*
         * Fill in the internationalization stuff in the State structure.
         * For nil arguments, provide the sensible defaults:
       t@@ -35,7 +34,7 @@ fmtlocaleinit(Fmt *f, char *decimal, char *thousands, char *grouping)
         * and pointer into the grouping descriptor.
         */
        int
       -__needsep(int *ndig, const char **grouping)
       +__needsep(int *ndig, char **grouping)
        {
                int group;
                
   DIR diff --git a/src/lib9/fmt/fmtnull.c b/src/lib9/fmt/fmtnull.c
       t@@ -0,0 +1,33 @@
       +/* Copyright (c) 2004 Google Inc.; see LICENSE */
       +#include <stdarg.h>
       +#include <string.h>
       +#include "plan9.h"
       +#include "fmt.h"
       +#include "fmtdef.h"
       +
       +/*
       + * Absorb output without using resources.
       + */
       +static Rune nullbuf[32];
       +
       +static int
       +__fmtnullflush(Fmt *f)
       +{
       +        f->to = nullbuf;
       +        f->nfmt = 0;
       +        return 0;
       +}
       +
       +int
       +fmtnullinit(Fmt *f)
       +{
       +        memset(&f, 0, sizeof *f);
       +        f->runes = 1;
       +        f->start = nullbuf;
       +        f->to = nullbuf;
       +        f->stop = nullbuf+nelem(nullbuf);
       +        f->flush = __fmtnullflush;
       +        fmtlocaleinit(f, nil, nil, nil);
       +        return 0;
       +}
       +
   DIR diff --git a/src/lib9/fmt/test.c b/src/lib9/fmt/test.c
       t@@ -1,4 +1,6 @@
        /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
       +/* Copyright (c) 2004 Google Inc.; see LICENSE */
       +
        #include <stdio.h>
        #include <stdarg.h>
        #include <utf.h>