clean up for unix port
diff --git a/src/lib9/fmt/charstod.c b/src/lib9/fmt/charstod.c index ec403b1..65a4e18 100644 --- a/src/lib9/fmt/charstod.c +++ b/src/lib9/fmt/charstod.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/dofmt.c b/src/lib9/fmt/dofmt.c index cee3f4e..873d692 100644 --- a/src/lib9/fmt/dofmt.c +++ b/src/lib9/fmt/dofmt.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h" @@ -339,10 +339,12 @@ * 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; } @@ -402,7 +404,9 @@ default: return -1; } - if(!(fl & FmtUnsigned)){ + if(fl & FmtUnsigned) + fl &= ~(FmtSign|FmtSpace); + else{ if(isv && (vlong)vu < 0){ vu = -(vlong)vu; neg = 1; @@ -410,8 +414,6 @@ u = -(long)u; neg = 1; } - }else{ - fl &= ~(FmtSign|FmtSpace); /* no + for unsigned conversions */ } p = buf + sizeof buf - 1; n = 0;
diff --git a/src/lib9/fmt/dorfmt.c b/src/lib9/fmt/dorfmt.c index cdaee8a..5b547d5 100644 --- a/src/lib9/fmt/dorfmt.c +++ b/src/lib9/fmt/dorfmt.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h" @@ -53,7 +53,7 @@ f->stop = s; } - fmt = __fmtdispatch(f, fmt, 1); + fmt = __fmtdispatch(f, (Rune*)fmt, 1); if(fmt == nil) return -1; }
diff --git a/src/lib9/fmt/errfmt.c b/src/lib9/fmt/errfmt.c index 2184705..df6c310 100644 --- a/src/lib9/fmt/errfmt.c +++ b/src/lib9/fmt/errfmt.c
@@ -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"
diff --git a/src/lib9/fmt/fltfmt.c b/src/lib9/fmt/fltfmt.c index 234f03d..a7e5799 100644 --- a/src/lib9/fmt/fltfmt.c +++ b/src/lib9/fmt/fltfmt.c
@@ -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 {
diff --git a/src/lib9/fmt/fmt.c b/src/lib9/fmt/fmt.c index 976bf7c..f9d8328 100644 --- a/src/lib9/fmt/fmt.c +++ b/src/lib9/fmt/fmt.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h" @@ -64,7 +64,11 @@ 'p', __ifmt, 'r', __errfmt, 's', __strfmt, - 'u', __flagfmt, /* in Unix, __ifmt */ +#ifdef PLAN9PORT + 'u', __flagfmt, +#else + 'u', __ifmt, +#endif 'x', __ifmt, 0, nil, }; @@ -103,7 +107,7 @@ } int -fmtinstall(int c, Fmts f) +fmtinstall(int c, int (*f)(Fmt*)) { int ret;
diff --git a/src/lib9/fmt/fmtdef.h b/src/lib9/fmt/fmtdef.h index 8946876..bfb2aa9 100644 --- a/src/lib9/fmt/fmtdef.h +++ b/src/lib9/fmt/fmtdef.h
@@ -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, @@ -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*); @@ -54,31 +32,36 @@ 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{\
diff --git a/src/lib9/fmt/fmtfd.c b/src/lib9/fmt/fmtfd.c index d425140..5de42ae 100644 --- a/src/lib9/fmt/fmtfd.c +++ b/src/lib9/fmt/fmtfd.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/fmtfdflush.c b/src/lib9/fmt/fmtfdflush.c index 796feab..73bf47c 100644 --- a/src/lib9/fmt/fmtfdflush.c +++ b/src/lib9/fmt/fmtfdflush.c
@@ -13,6 +13,7 @@ */ #include <stdarg.h> #include <unistd.h> +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/fmtlock.c b/src/lib9/fmt/fmtlock.c index fffe81c..7501ce4 100644 --- a/src/lib9/fmt/fmtlock.c +++ b/src/lib9/fmt/fmtlock.c
@@ -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"
diff --git a/src/lib9/fmt/fmtprint.c b/src/lib9/fmt/fmtprint.c index c682f49..7044d5b 100644 --- a/src/lib9/fmt/fmtprint.c +++ b/src/lib9/fmt/fmtprint.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/fmtquote.c b/src/lib9/fmt/fmtquote.c index 9d5633d..b8f00c1 100644 --- a/src/lib9/fmt/fmtquote.c +++ b/src/lib9/fmt/fmtquote.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/fmtrune.c b/src/lib9/fmt/fmtrune.c index a034546..a7f620e 100644 --- a/src/lib9/fmt/fmtrune.c +++ b/src/lib9/fmt/fmtrune.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/fmtstr.c b/src/lib9/fmt/fmtstr.c index 0b22716..b4b6818 100644 --- a/src/lib9/fmt/fmtstr.c +++ b/src/lib9/fmt/fmtstr.c
@@ -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)
diff --git a/src/lib9/fmt/fmtvprint.c b/src/lib9/fmt/fmtvprint.c index 60974a0..d1176a5 100644 --- a/src/lib9/fmt/fmtvprint.c +++ b/src/lib9/fmt/fmtvprint.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/fprint.c b/src/lib9/fmt/fprint.c index c8b889d..b143380 100644 --- a/src/lib9/fmt/fprint.c +++ b/src/lib9/fmt/fprint.c
@@ -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, ...)
diff --git a/src/lib9/fmt/nan64.c b/src/lib9/fmt/nan64.c index dcdcd79..6e355a2 100644 --- a/src/lib9/fmt/nan64.c +++ b/src/lib9/fmt/nan64.c
@@ -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) @@ -72,5 +65,3 @@ else return x==uvneginf; } - -
diff --git a/src/lib9/fmt/pow10.c b/src/lib9/fmt/pow10.c index 65a426c..ecd8b6d 100644 --- a/src/lib9/fmt/pow10.c +++ b/src/lib9/fmt/pow10.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/print.c b/src/lib9/fmt/print.c index 381a1da..81f202f 100644 --- a/src/lib9/fmt/print.c +++ b/src/lib9/fmt/print.c
@@ -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, ...)
diff --git a/src/lib9/fmt/runefmtstr.c b/src/lib9/fmt/runefmtstr.c index 9ec84cd..5337639 100644 --- a/src/lib9/fmt/runefmtstr.c +++ b/src/lib9/fmt/runefmtstr.c
@@ -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)
diff --git a/src/lib9/fmt/runeseprint.c b/src/lib9/fmt/runeseprint.c index 7829a43..2753b58 100644 --- a/src/lib9/fmt/runeseprint.c +++ b/src/lib9/fmt/runeseprint.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/runesmprint.c b/src/lib9/fmt/runesmprint.c index 538ae0e..285ec19 100644 --- a/src/lib9/fmt/runesmprint.c +++ b/src/lib9/fmt/runesmprint.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/runesnprint.c b/src/lib9/fmt/runesnprint.c index 5abb6db..2fd1b41 100644 --- a/src/lib9/fmt/runesnprint.c +++ b/src/lib9/fmt/runesnprint.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/runesprint.c b/src/lib9/fmt/runesprint.c index 8abfeb6..ad66efa 100644 --- a/src/lib9/fmt/runesprint.c +++ b/src/lib9/fmt/runesprint.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/runevseprint.c b/src/lib9/fmt/runevseprint.c index a9ef99b..72f7e1b 100644 --- a/src/lib9/fmt/runevseprint.c +++ b/src/lib9/fmt/runevseprint.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/runevsmprint.c b/src/lib9/fmt/runevsmprint.c index 3326da8..988e5c0 100644 --- a/src/lib9/fmt/runevsmprint.c +++ b/src/lib9/fmt/runevsmprint.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <stdlib.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/runevsnprint.c b/src/lib9/fmt/runevsnprint.c index 71557e5..8aff734 100644 --- a/src/lib9/fmt/runevsnprint.c +++ b/src/lib9/fmt/runevsnprint.c
@@ -13,7 +13,7 @@ */ #include <stdarg.h> #include <string.h> -#include "utf.h" +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/seprint.c b/src/lib9/fmt/seprint.c index d5031a2..32f60c6 100644 --- a/src/lib9/fmt/seprint.c +++ b/src/lib9/fmt/seprint.c
@@ -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, ...)
diff --git a/src/lib9/fmt/smprint.c b/src/lib9/fmt/smprint.c index 543411a..1bc8975 100644 --- a/src/lib9/fmt/smprint.c +++ b/src/lib9/fmt/smprint.c
@@ -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, ...)
diff --git a/src/lib9/fmt/snprint.c b/src/lib9/fmt/snprint.c index 594606d..693affd 100644 --- a/src/lib9/fmt/snprint.c +++ b/src/lib9/fmt/snprint.c
@@ -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, ...)
diff --git a/src/lib9/fmt/sprint.c b/src/lib9/fmt/sprint.c index 8551ca3..8313b16 100644 --- a/src/lib9/fmt/sprint.c +++ b/src/lib9/fmt/sprint.c
@@ -13,6 +13,8 @@ */ #include <stdarg.h> #include <fmt.h> +#include "plan9.h" +#include "fmt.h" #include "fmtdef.h" int
diff --git a/src/lib9/fmt/strtod.c b/src/lib9/fmt/strtod.c index 685b7fa..5939dd9 100644 --- a/src/lib9/fmt/strtod.c +++ b/src/lib9/fmt/strtod.c
@@ -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)
diff --git a/src/lib9/fmt/test.c b/src/lib9/fmt/test.c index a1a1d5e..650f0f5 100644 --- a/src/lib9/fmt/test.c +++ b/src/lib9/fmt/test.c
@@ -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[])
diff --git a/src/lib9/fmt/vfprint.c b/src/lib9/fmt/vfprint.c index 711b658..1df4747 100644 --- a/src/lib9/fmt/vfprint.c +++ b/src/lib9/fmt/vfprint.c
@@ -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"
diff --git a/src/lib9/fmt/vseprint.c b/src/lib9/fmt/vseprint.c index a1be5e4..9eb674a 100644 --- a/src/lib9/fmt/vseprint.c +++ b/src/lib9/fmt/vseprint.c
@@ -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"
diff --git a/src/lib9/fmt/vsmprint.c b/src/lib9/fmt/vsmprint.c index 4f55c41..871531e 100644 --- a/src/lib9/fmt/vsmprint.c +++ b/src/lib9/fmt/vsmprint.c
@@ -13,6 +13,7 @@ */ #include <stdlib.h> #include <stdarg.h> +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/fmt/vsnprint.c b/src/lib9/fmt/vsnprint.c index 7272ab6..ec05d48 100644 --- a/src/lib9/fmt/vsnprint.c +++ b/src/lib9/fmt/vsnprint.c
@@ -13,6 +13,7 @@ */ #include <stdlib.h> #include <stdarg.h> +#include "plan9.h" #include "fmt.h" #include "fmtdef.h"
diff --git a/src/lib9/utf/rune.c b/src/lib9/utf/rune.c index e1aaa9b..1cf8c7e 100644 --- a/src/lib9/utf/rune.c +++ b/src/lib9/utf/rune.c
@@ -13,8 +13,8 @@ */ #include <stdarg.h> #include <string.h> +#include "plan9.h" #include "utf.h" -#include "utfdef.h" enum {
diff --git a/src/lib9/utf/runestrcat.c b/src/lib9/utf/runestrcat.c index e1e8c9d..f345a1b 100644 --- a/src/lib9/utf/runestrcat.c +++ b/src/lib9/utf/runestrcat.c
@@ -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)
diff --git a/src/lib9/utf/runestrchr.c b/src/lib9/utf/runestrchr.c index 45ee673..90d05e5 100644 --- a/src/lib9/utf/runestrchr.c +++ b/src/lib9/utf/runestrchr.c
@@ -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)
diff --git a/src/lib9/utf/runestrcmp.c b/src/lib9/utf/runestrcmp.c index d14145f..3590627 100644 --- a/src/lib9/utf/runestrcmp.c +++ b/src/lib9/utf/runestrcmp.c
@@ -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)
diff --git a/src/lib9/utf/runestrcpy.c b/src/lib9/utf/runestrcpy.c index 9d7aa02..b8c2411 100644 --- a/src/lib9/utf/runestrcpy.c +++ b/src/lib9/utf/runestrcpy.c
@@ -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)
diff --git a/src/lib9/utf/runestrdup.c b/src/lib9/utf/runestrdup.c index 97a889c..7acceda 100644 --- a/src/lib9/utf/runestrdup.c +++ b/src/lib9/utf/runestrdup.c
@@ -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)
diff --git a/src/lib9/utf/runestrecpy.c b/src/lib9/utf/runestrecpy.c index f3e4a09..83450c9 100644 --- a/src/lib9/utf/runestrecpy.c +++ b/src/lib9/utf/runestrecpy.c
@@ -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)
diff --git a/src/lib9/utf/runestrlen.c b/src/lib9/utf/runestrlen.c index bca3050..0096d52 100644 --- a/src/lib9/utf/runestrlen.c +++ b/src/lib9/utf/runestrlen.c
@@ -13,8 +13,8 @@ */ #include <stdarg.h> #include <string.h> +#include "plan9.h" #include "utf.h" -#include "utfdef.h" long runestrlen(Rune *s)
diff --git a/src/lib9/utf/runestrncat.c b/src/lib9/utf/runestrncat.c index 74400c3..7404fb9 100644 --- a/src/lib9/utf/runestrncat.c +++ b/src/lib9/utf/runestrncat.c
@@ -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)
diff --git a/src/lib9/utf/runestrncmp.c b/src/lib9/utf/runestrncmp.c index dbd9da4..4fbdb0a 100644 --- a/src/lib9/utf/runestrncmp.c +++ b/src/lib9/utf/runestrncmp.c
@@ -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)
diff --git a/src/lib9/utf/runestrncpy.c b/src/lib9/utf/runestrncpy.c index acba7bc..f251734 100644 --- a/src/lib9/utf/runestrncpy.c +++ b/src/lib9/utf/runestrncpy.c
@@ -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)
diff --git a/src/lib9/utf/runestrrchr.c b/src/lib9/utf/runestrrchr.c index 1f40c5a..1f36854 100644 --- a/src/lib9/utf/runestrrchr.c +++ b/src/lib9/utf/runestrrchr.c
@@ -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)
diff --git a/src/lib9/utf/runestrstr.c b/src/lib9/utf/runestrstr.c index 48583a3..8be7a03 100644 --- a/src/lib9/utf/runestrstr.c +++ b/src/lib9/utf/runestrstr.c
@@ -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,
diff --git a/src/lib9/utf/runetype.c b/src/lib9/utf/runetype.c index ffae30e..41a3272 100644 --- a/src/lib9/utf/runetype.c +++ b/src/lib9/utf/runetype.c
@@ -13,8 +13,8 @@ */ #include <stdarg.h> #include <string.h> +#include "plan9.h" #include "utf.h" -#include "utfdef.h" /* * alpha ranges - @@ -1030,8 +1030,7 @@ 0x01f3, 499, /* dz Dz */ }; -static -Rune* +static Rune* bsearch(Rune c, Rune *t, int n, int ne) { Rune *p;
diff --git a/src/lib9/utf/utfdef.h b/src/lib9/utf/utfdef.h index 4b58ae8..1ff4181 100644 --- a/src/lib9/utf/utfdef.h +++ b/src/lib9/utf/utfdef.h
@@ -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; -#define nelem(x) (sizeof(x)/sizeof((x)[0])) -#define nil ((void*)0) +/* + * 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) +
diff --git a/src/lib9/utf/utfecpy.c b/src/lib9/utf/utfecpy.c index 5715935..fde9338 100644 --- a/src/lib9/utf/utfecpy.c +++ b/src/lib9/utf/utfecpy.c
@@ -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)
diff --git a/src/lib9/utf/utflen.c b/src/lib9/utf/utflen.c index a10a531..2e8c666 100644 --- a/src/lib9/utf/utflen.c +++ b/src/lib9/utf/utflen.c
@@ -13,8 +13,8 @@ */ #include <stdarg.h> #include <string.h> +#include "plan9.h" #include "utf.h" -#include "utfdef.h" int utflen(char *s)
diff --git a/src/lib9/utf/utfnlen.c b/src/lib9/utf/utfnlen.c index 66d674f..6418f61 100644 --- a/src/lib9/utf/utfnlen.c +++ b/src/lib9/utf/utfnlen.c
@@ -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)
diff --git a/src/lib9/utf/utfrrune.c b/src/lib9/utf/utfrrune.c index 37d2a72..fc84d6b 100644 --- a/src/lib9/utf/utfrrune.c +++ b/src/lib9/utf/utfrrune.c
@@ -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)
diff --git a/src/lib9/utf/utfrune.c b/src/lib9/utf/utfrune.c index 1a2e04c..5aa476a 100644 --- a/src/lib9/utf/utfrune.c +++ b/src/lib9/utf/utfrune.c
@@ -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)
diff --git a/src/lib9/utf/utfutf.c b/src/lib9/utf/utfutf.c index ea36036..70873cc 100644 --- a/src/lib9/utf/utfutf.c +++ b/src/lib9/utf/utfutf.c
@@ -13,8 +13,8 @@ */ #include <stdarg.h> #include <string.h> +#include "plan9.h" #include "utf.h" -#include "utfdef.h" /*