tclean up for unix port - 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 e5aa96acbf9107cd78f2536364c36f9a15751313
 (DIR) parent 5c8a0421712a471a00dbf78f7ea054b366ba471b
 (HTM) Author: rsc <devnull@localhost>
       Date:   Sun, 26 Dec 2004 21:50:14 +0000
       
       clean up for unix port
       
       Diffstat:
         M src/lib9/fmt/charstod.c             |       2 +-
         M src/lib9/fmt/dofmt.c                |      14 ++++++++------
         M src/lib9/fmt/dorfmt.c               |       4 ++--
         M src/lib9/fmt/errfmt.c               |       2 +-
         M src/lib9/fmt/fltfmt.c               |       3 ++-
         M src/lib9/fmt/fmt.c                  |      10 +++++++---
         M src/lib9/fmt/fmtdef.h               |      79 ++++++++++++-------------------
         M src/lib9/fmt/fmtfd.c                |       2 +-
         M src/lib9/fmt/fmtfdflush.c           |       1 +
         M src/lib9/fmt/fmtlock.c              |       1 +
         M src/lib9/fmt/fmtprint.c             |       2 +-
         M src/lib9/fmt/fmtquote.c             |       2 +-
         M src/lib9/fmt/fmtrune.c              |       2 +-
         M src/lib9/fmt/fmtstr.c               |      11 +++++++++++
         M src/lib9/fmt/fmtvprint.c            |       2 +-
         M src/lib9/fmt/fprint.c               |       3 ++-
         M src/lib9/fmt/nan64.c                |      15 +++------------
         M src/lib9/fmt/pow10.c                |       2 +-
         M src/lib9/fmt/print.c                |       3 ++-
         M src/lib9/fmt/runefmtstr.c           |      11 +++++++++++
         M src/lib9/fmt/runeseprint.c          |       2 +-
         M src/lib9/fmt/runesmprint.c          |       2 +-
         M src/lib9/fmt/runesnprint.c          |       2 +-
         M src/lib9/fmt/runesprint.c           |       2 +-
         M src/lib9/fmt/runevseprint.c         |       2 +-
         M src/lib9/fmt/runevsmprint.c         |       2 +-
         M src/lib9/fmt/runevsnprint.c         |       2 +-
         M src/lib9/fmt/seprint.c              |       2 ++
         M src/lib9/fmt/smprint.c              |       2 ++
         M src/lib9/fmt/snprint.c              |       2 ++
         M src/lib9/fmt/sprint.c               |       2 ++
         M src/lib9/fmt/strtod.c               |      10 ++--------
         M src/lib9/fmt/test.c                 |       2 ++
         M src/lib9/fmt/vfprint.c              |       1 +
         M src/lib9/fmt/vseprint.c             |       1 +
         M src/lib9/fmt/vsmprint.c             |       1 +
         M src/lib9/fmt/vsnprint.c             |       1 +
         M src/lib9/utf/rune.c                 |       2 +-
         M src/lib9/utf/runestrcat.c           |       2 +-
         M src/lib9/utf/runestrchr.c           |       2 +-
         M src/lib9/utf/runestrcmp.c           |       2 +-
         M src/lib9/utf/runestrcpy.c           |       2 +-
         M src/lib9/utf/runestrdup.c           |       2 +-
         M src/lib9/utf/runestrecpy.c          |       2 +-
         M src/lib9/utf/runestrlen.c           |       2 +-
         M src/lib9/utf/runestrncat.c          |       2 +-
         M src/lib9/utf/runestrncmp.c          |       2 +-
         M src/lib9/utf/runestrncpy.c          |       2 +-
         M src/lib9/utf/runestrrchr.c          |       2 +-
         M src/lib9/utf/runestrstr.c           |       2 +-
         M src/lib9/utf/runetype.c             |       5 ++---
         M src/lib9/utf/utfdef.h               |      35 ++++++++++++++++++++++++-------
         M src/lib9/utf/utfecpy.c              |       2 +-
         M src/lib9/utf/utflen.c               |       2 +-
         M src/lib9/utf/utfnlen.c              |       2 +-
         M src/lib9/utf/utfrrune.c             |       2 +-
         M src/lib9/utf/utfrune.c              |       2 +-
         M src/lib9/utf/utfutf.c               |       2 +-
       
       58 files changed, 160 insertions(+), 127 deletions(-)
       ---
 (DIR) diff --git a/src/lib9/fmt/charstod.c b/src/lib9/fmt/charstod.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/dofmt.c b/src/lib9/fmt/dofmt.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
       t@@ -339,10 +339,12 @@ __ifmt(Fmt *f)
                 * Unsigned verbs
                 */
                switch(f->r){
       -        case 'o':
       -        case 'u':
       +        /* unsigned by default only on Unix 
                case 'x':
                case 'X':
       +        */
       +        case 'o':
       +        case 'u':
                        fl |= FmtUnsigned;
                        break;
                }
       t@@ -402,7 +404,9 @@ __ifmt(Fmt *f)
                default:
                        return -1;
                }
       -        if(!(fl & FmtUnsigned)){
       +        if(fl & FmtUnsigned)
       +                fl &= ~(FmtSign|FmtSpace);
       +        else{
                        if(isv && (vlong)vu < 0){
                                vu = -(vlong)vu;
                                neg = 1;
       t@@ -410,8 +414,6 @@ __ifmt(Fmt *f)
                                u = -(long)u;
                                neg = 1;
                        }
       -        }else{
       -                fl &= ~(FmtSign|FmtSpace);        /* no + for unsigned conversions */
                }
                p = buf + sizeof buf - 1;
                n = 0;
 (DIR) diff --git a/src/lib9/fmt/dorfmt.c b/src/lib9/fmt/dorfmt.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
       t@@ -53,7 +53,7 @@ dorfmt(Fmt *f, const Rune *fmt)
                                f->stop = s;
                        }
        
       -                fmt = __fmtdispatch(f, fmt, 1);
       +                fmt = __fmtdispatch(f, (Rune*)fmt, 1);
                        if(fmt == nil)
                                return -1;
                }
 (DIR) diff --git a/src/lib9/fmt/errfmt.c b/src/lib9/fmt/errfmt.c
       t@@ -14,7 +14,7 @@
        #include <stdarg.h>
        #include <errno.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/fltfmt.c b/src/lib9/fmt/fltfmt.c
       t@@ -18,9 +18,10 @@
        #include <stdlib.h>
        #include <errno.h>
        #include <stdarg.h>
       +#include <fmt.h>
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
       -#include "nan.h"
        
        enum
        {
 (DIR) diff --git a/src/lib9/fmt/fmt.c b/src/lib9/fmt/fmt.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
       t@@ -64,7 +64,11 @@ static Convfmt knownfmt[] = {
                'p',        __ifmt,
                'r',        __errfmt,
                's',        __strfmt,
       -        'u',        __flagfmt,        /* in Unix, __ifmt */
       +#ifdef PLAN9PORT
       +        'u',        __flagfmt,
       +#else
       +        'u',        __ifmt,
       +#endif
                'x',        __ifmt,
                0,        nil,
        };
       t@@ -103,7 +107,7 @@ __fmtinstall(int c, Fmts f)
        }
        
        int
       -fmtinstall(int c, Fmts f)
       +fmtinstall(int c, int (*f)(Fmt*))
        {
                int ret;
        
 (DIR) diff --git a/src/lib9/fmt/fmtdef.h b/src/lib9/fmt/fmtdef.h
       t@@ -11,6 +11,7 @@
         * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
         * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
       +
        /*
         * dofmt -- format to a buffer
         * the number of characters formatted is returned,
       t@@ -18,29 +19,6 @@
         * if the buffer is ever filled, flush is called.
         * it should reset the buffer and return whether formatting should continue.
         */
       -#define uchar _fmtuchar
       -#define ushort _fmtushort
       -#define uint _fmtuint
       -#define ulong _fmtulong
       -#define vlong _fmtvlong
       -#define uvlong _fmtuvlong
       -
       -#ifndef USED
       -#define USED(x) if(x);else
       -#endif
       -
       -typedef unsigned char                uchar;
       -typedef unsigned short                ushort;
       -typedef unsigned int                uint;
       -typedef unsigned long                ulong;
       -
       -#ifndef NOVLONGS
       -typedef unsigned long long        uvlong;
       -typedef long long                vlong;
       -#endif
       -
       -#undef nil
       -#define nil                0        /* cannot be ((void*)0) because used for function pointers */
        
        typedef int (*Fmts)(Fmt*);
        
       t@@ -54,31 +32,36 @@ struct Quoteinfo
                int        nbytesout;        /* number of bytes that will be generated */
        };
        
       -void        *__fmtflush(Fmt*, void*, int);
       -void        *__fmtdispatch(Fmt*, void*, int);
       -int        __floatfmt(Fmt*, double);
       -int        __fmtpad(Fmt*, int);
       -int        __rfmtpad(Fmt*, int);
       -int        __fmtFdFlush(Fmt*);
       -
       -int        __efgfmt(Fmt*);
       -int        __charfmt(Fmt*);
       -int        __runefmt(Fmt*);
       -int        __runesfmt(Fmt*);
       -int        __countfmt(Fmt*);
       -int        __flagfmt(Fmt*);
       -int        __percentfmt(Fmt*);
       -int        __ifmt(Fmt*);
       -int        __strfmt(Fmt*);
       -int        __badfmt(Fmt*);
       -int        __fmtcpy(Fmt*, const void*, int, int);
       -int        __fmtrcpy(Fmt*, const void*, int n);
       -int        __errfmt(Fmt *f);
       -
       -double        __fmtpow10(int);
       -
       -void        __fmtlock(void);
       -void        __fmtunlock(void);
       +/* Edit .+1,/^$/ |cfn |grep -v static | grep __ */
       +double       __Inf(int sign);
       +double       __NaN(void);
       +int          __badfmt(Fmt *f);
       +int          __charfmt(Fmt *f);
       +int          __countfmt(Fmt *f);
       +int          __efgfmt(Fmt *fmt);
       +int          __errfmt(Fmt *f);
       +int          __flagfmt(Fmt *f);
       +int          __fmtFdFlush(Fmt *f);
       +int          __fmtcpy(Fmt *f, const void *vm, int n, int sz);
       +void*        __fmtdispatch(Fmt *f, void *fmt, int isrunes);
       +void *       __fmtflush(Fmt *f, void *t, int len);
       +void         __fmtlock(void);
       +int          __fmtpad(Fmt *f, int n);
       +double       __fmtpow10(int n);
       +int          __fmtrcpy(Fmt *f, const void *vm, int n);
       +void         __fmtunlock(void);
       +int          __ifmt(Fmt *f);
       +int          __isInf(double d, int sign);
       +int          __isNaN(double d);
       +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);
       +int          __quotestrfmt(int runesin, Fmt *f);
       +int          __rfmtpad(Fmt *f, int n);
       +int          __runefmt(Fmt *f);
       +int          __runeneedsquotes(Rune *r, int *quotelenp);
       +int          __runesfmt(Fmt *f);
       +int          __strfmt(Fmt *f);
        
        #define FMTCHAR(f, t, s, c)\
                do{\
 (DIR) diff --git a/src/lib9/fmt/fmtfd.c b/src/lib9/fmt/fmtfd.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/fmtfdflush.c b/src/lib9/fmt/fmtfdflush.c
       t@@ -13,6 +13,7 @@
         */
        #include <stdarg.h>
        #include <unistd.h>
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/fmtlock.c b/src/lib9/fmt/fmtlock.c
       t@@ -12,6 +12,7 @@
         * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
        #include <stdarg.h>
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/fmtprint.c b/src/lib9/fmt/fmtprint.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/fmtquote.c b/src/lib9/fmt/fmtquote.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/fmtrune.c b/src/lib9/fmt/fmtrune.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/fmtstr.c b/src/lib9/fmt/fmtstr.c
       t@@ -11,9 +11,20 @@
         * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
         * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
       +/*
       + * Plan 9 port version must include libc.h in order to 
       + * get Plan 9 debugging malloc, which sometimes returns
       + * different pointers than the standard malloc. 
       + */
       +#ifdef PLAN9PORT
        #include <u.h>
        #include <libc.h>
       +#else
       +#include <stdlib.h>
       +#include "plan9.h"
       +#include "fmt.h"
        #include "fmtdef.h"
       +#endif
        
        static int
        fmtStrFlush(Fmt *f)
 (DIR) diff --git a/src/lib9/fmt/fmtvprint.c b/src/lib9/fmt/fmtvprint.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/fprint.c b/src/lib9/fmt/fprint.c
       t@@ -12,8 +12,9 @@
         * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
        #include <stdarg.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
       +#include "fmtdef.h"
        
        int
        fprint(int fd, char *fmt, ...)
 (DIR) diff --git a/src/lib9/fmt/nan64.c b/src/lib9/fmt/nan64.c
       t@@ -5,24 +5,17 @@
         * same byte ordering.
         */
        
       -#include "nan.h"
       +#include "plan9.h"
       +#include "fmt.h"
       +#include "fmtdef.h"
        
        #if defined (__APPLE__) || (__powerpc__)
        #define _NEEDLL
        #endif
        
       -typedef unsigned long long uvlong;
       -typedef unsigned long ulong;
       -
       -#ifdef _NEEDLL
       -static uvlong uvnan    = 0x7FF0000000000001LL;
       -static uvlong uvinf    = 0x7FF0000000000000LL;
       -static uvlong uvneginf = 0xFFF0000000000000LL;
       -#else
        static uvlong uvnan    = ((uvlong)0x7FF00000<<32)|0x00000001;
        static uvlong uvinf    = ((uvlong)0x7FF00000<<32)|0x00000000;
        static uvlong uvneginf = ((uvlong)0xFFF00000<<32)|0x00000000;
       -#endif
        
        double
        __NaN(void)
       t@@ -72,5 +65,3 @@ __isInf(double d, int sign)
                else
                        return x==uvneginf;
        }
       -
       -
 (DIR) diff --git a/src/lib9/fmt/pow10.c b/src/lib9/fmt/pow10.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/print.c b/src/lib9/fmt/print.c
       t@@ -12,8 +12,9 @@
         * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
        #include <stdarg.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
       +#include "fmtdef.h"
        
        int
        print(char *fmt, ...)
 (DIR) diff --git a/src/lib9/fmt/runefmtstr.c b/src/lib9/fmt/runefmtstr.c
       t@@ -11,9 +11,20 @@
         * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
         * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
       +/*
       + * Plan 9 port version must include libc.h in order to 
       + * get Plan 9 debugging malloc, which sometimes returns
       + * different pointers than the standard malloc. 
       + */
       +#ifdef PLAN9PORT
        #include <u.h>
        #include <libc.h>
       +#else
       +#include <stdlib.h>
       +#include "plan9.h"
       +#include "fmt.h"
        #include "fmtdef.h"
       +#endif
        
        static int
        runeFmtStrFlush(Fmt *f)
 (DIR) diff --git a/src/lib9/fmt/runeseprint.c b/src/lib9/fmt/runeseprint.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/runesmprint.c b/src/lib9/fmt/runesmprint.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/runesnprint.c b/src/lib9/fmt/runesnprint.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/runesprint.c b/src/lib9/fmt/runesprint.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/runevseprint.c b/src/lib9/fmt/runevseprint.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/runevsmprint.c b/src/lib9/fmt/runevsmprint.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <stdlib.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/runevsnprint.c b/src/lib9/fmt/runevsnprint.c
       t@@ -13,7 +13,7 @@
         */
        #include <stdarg.h>
        #include <string.h>
       -#include "utf.h"
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/seprint.c b/src/lib9/fmt/seprint.c
       t@@ -12,7 +12,9 @@
         * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
        #include <stdarg.h>
       +#include "plan9.h"
        #include "fmt.h"
       +#include "fmtdef.h"
        
        char*
        seprint(char *buf, char *e, char *fmt, ...)
 (DIR) diff --git a/src/lib9/fmt/smprint.c b/src/lib9/fmt/smprint.c
       t@@ -12,7 +12,9 @@
         * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
        #include <stdarg.h>
       +#include "plan9.h"
        #include "fmt.h"
       +#include "fmtdef.h"
        
        char*
        smprint(char *fmt, ...)
 (DIR) diff --git a/src/lib9/fmt/snprint.c b/src/lib9/fmt/snprint.c
       t@@ -12,7 +12,9 @@
         * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
        #include <stdarg.h>
       +#include "plan9.h"
        #include "fmt.h"
       +#include "fmtdef.h"
        
        int
        snprint(char *buf, int len, char *fmt, ...)
 (DIR) diff --git a/src/lib9/fmt/sprint.c b/src/lib9/fmt/sprint.c
       t@@ -13,6 +13,8 @@
         */
        #include <stdarg.h>
        #include <fmt.h>
       +#include "plan9.h"
       +#include "fmt.h"
        #include "fmtdef.h"
        
        int
 (DIR) diff --git a/src/lib9/fmt/strtod.c b/src/lib9/fmt/strtod.c
       t@@ -17,15 +17,9 @@
        #include <stdlib.h>
        #include <string.h>
        #include <errno.h>
       +#include "plan9.h"
        #include "fmt.h"
       -#include "nan.h"
       -
       -#ifndef nelem
       -#define nelem(x)        (sizeof(x)/sizeof *(x))
       -#endif
       -#define nil ((void*)0)
       -#define ulong _fmtulong
       -typedef unsigned long ulong;
       +#include "fmtdef.h"
        
        static ulong
        umuldiv(ulong a, ulong b, ulong c)
 (DIR) diff --git a/src/lib9/fmt/test.c b/src/lib9/fmt/test.c
       t@@ -13,7 +13,9 @@
         */
        #include <stdarg.h>
        #include <utf.h>
       +#include "plan9.h"
        #include "fmt.h"
       +#include "fmtdef.h"
        
        int
        main(int argc, char *argv[])
 (DIR) diff --git a/src/lib9/fmt/vfprint.c b/src/lib9/fmt/vfprint.c
       t@@ -12,6 +12,7 @@
         * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
        #include <stdarg.h>
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/vseprint.c b/src/lib9/fmt/vseprint.c
       t@@ -12,6 +12,7 @@
         * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
         */
        #include <stdarg.h>
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/vsmprint.c b/src/lib9/fmt/vsmprint.c
       t@@ -13,6 +13,7 @@
         */
        #include <stdlib.h>
        #include <stdarg.h>
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/fmt/vsnprint.c b/src/lib9/fmt/vsnprint.c
       t@@ -13,6 +13,7 @@
         */
        #include <stdlib.h>
        #include <stdarg.h>
       +#include "plan9.h"
        #include "fmt.h"
        #include "fmtdef.h"
        
 (DIR) diff --git a/src/lib9/utf/rune.c b/src/lib9/utf/rune.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        enum
        {
 (DIR) diff --git a/src/lib9/utf/runestrcat.c b/src/lib9/utf/runestrcat.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        Rune*
        runestrcat(Rune *s1, Rune *s2)
 (DIR) diff --git a/src/lib9/utf/runestrchr.c b/src/lib9/utf/runestrchr.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        Rune*
        runestrchr(Rune *s, Rune c)
 (DIR) diff --git a/src/lib9/utf/runestrcmp.c b/src/lib9/utf/runestrcmp.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        int
        runestrcmp(Rune *s1, Rune *s2)
 (DIR) diff --git a/src/lib9/utf/runestrcpy.c b/src/lib9/utf/runestrcpy.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        Rune*
        runestrcpy(Rune *s1, Rune *s2)
 (DIR) diff --git a/src/lib9/utf/runestrdup.c b/src/lib9/utf/runestrdup.c
       t@@ -14,8 +14,8 @@
        #include <stdarg.h>
        #include <string.h>
        #include <stdlib.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        Rune*
        runestrdup(Rune *s) 
 (DIR) diff --git a/src/lib9/utf/runestrecpy.c b/src/lib9/utf/runestrecpy.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        Rune*
        runestrecpy(Rune *s1, Rune *es1, Rune *s2)
 (DIR) diff --git a/src/lib9/utf/runestrlen.c b/src/lib9/utf/runestrlen.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        long
        runestrlen(Rune *s)
 (DIR) diff --git a/src/lib9/utf/runestrncat.c b/src/lib9/utf/runestrncat.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        Rune*
        runestrncat(Rune *s1, Rune *s2, long n)
 (DIR) diff --git a/src/lib9/utf/runestrncmp.c b/src/lib9/utf/runestrncmp.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        int
        runestrncmp(Rune *s1, Rune *s2, long n)
 (DIR) diff --git a/src/lib9/utf/runestrncpy.c b/src/lib9/utf/runestrncpy.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        Rune*
        runestrncpy(Rune *s1, Rune *s2, long n)
 (DIR) diff --git a/src/lib9/utf/runestrrchr.c b/src/lib9/utf/runestrrchr.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        Rune*
        runestrrchr(Rune *s, Rune c)
 (DIR) diff --git a/src/lib9/utf/runestrstr.c b/src/lib9/utf/runestrstr.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        /*
         * Return pointer to first occurrence of s2 in s1,
 (DIR) diff --git a/src/lib9/utf/runetype.c b/src/lib9/utf/runetype.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        /*
         * alpha ranges -
       t@@ -1030,8 +1030,7 @@ Rune        __totitle1[] =
                0x01f3, 499,        /* dz Dz */
        };
        
       -static
       -Rune*
       +static Rune*
        bsearch(Rune c, Rune *t, int n, int ne)
        {
                Rune *p;
 (DIR) diff --git a/src/lib9/utf/utfdef.h b/src/lib9/utf/utfdef.h
       t@@ -1,14 +1,33 @@
       -#define uchar _utfuchar
       -#define ushort _utfushort
       -#define uint _utfuint
       -#define ulong _utfulong
       -#define vlong _utfvlong
       -#define uvlong _utfuvlong
       +/*
       + * compiler directive on Plan 9
       + */
       +#ifndef USED
       +#define USED(x) if(x);else
       +#endif
        
       +/*
       + * easiest way to make sure these are defined
       + */
       +#define uchar        _fmtuchar
       +#define ushort        _fmtushort
       +#define uint        _fmtuint
       +#define ulong        _fmtulong
       +#define vlong        _fmtvlong
       +#define uvlong        _fmtuvlong
        typedef unsigned char                uchar;
        typedef unsigned short                ushort;
        typedef unsigned int                uint;
        typedef unsigned long                ulong;
       +typedef unsigned long long        uvlong;
       +typedef long long                vlong;
       +
       +/*
       + * nil cannot be ((void*)0) on ANSI C,
       + * because it is used for function pointers
       + */
       +#undef        nil
       +#define        nil        0
       +
       +#undef        nelem
       +#define        nelem        ((void*)0)
        
       -#define nelem(x) (sizeof(x)/sizeof((x)[0]))
       -#define nil ((void*)0)
 (DIR) diff --git a/src/lib9/utf/utfecpy.c b/src/lib9/utf/utfecpy.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        char*
        utfecpy(char *to, char *e, char *from)
 (DIR) diff --git a/src/lib9/utf/utflen.c b/src/lib9/utf/utflen.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        int
        utflen(char *s)
 (DIR) diff --git a/src/lib9/utf/utfnlen.c b/src/lib9/utf/utfnlen.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        int
        utfnlen(char *s, long m)
 (DIR) diff --git a/src/lib9/utf/utfrrune.c b/src/lib9/utf/utfrrune.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        char*
        utfrrune(char *s, long c)
 (DIR) diff --git a/src/lib9/utf/utfrune.c b/src/lib9/utf/utfrune.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        char*
        utfrune(char *s, long c)
 (DIR) diff --git a/src/lib9/utf/utfutf.c b/src/lib9/utf/utfutf.c
       t@@ -13,8 +13,8 @@
         */
        #include <stdarg.h>
        #include <string.h>
       +#include "plan9.h"
        #include "utf.h"
       -#include "utfdef.h"
        
        
        /*