aboutsummaryrefslogtreecommitdiff
path: root/src/lib9
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-12-26 21:50:14 +0000
committerrsc <devnull@localhost>2004-12-26 21:50:14 +0000
commite5aa96acbf9107cd78f2536364c36f9a15751313 (patch)
tree9c198bb62564c433c28d2de81a5fb6b782f39903 /src/lib9
parent5c8a0421712a471a00dbf78f7ea054b366ba471b (diff)
downloadplan9port-e5aa96acbf9107cd78f2536364c36f9a15751313.tar.gz
plan9port-e5aa96acbf9107cd78f2536364c36f9a15751313.tar.bz2
plan9port-e5aa96acbf9107cd78f2536364c36f9a15751313.zip
clean up for unix port
Diffstat (limited to 'src/lib9')
-rw-r--r--src/lib9/fmt/charstod.c2
-rw-r--r--src/lib9/fmt/dofmt.c14
-rw-r--r--src/lib9/fmt/dorfmt.c4
-rw-r--r--src/lib9/fmt/errfmt.c2
-rw-r--r--src/lib9/fmt/fltfmt.c3
-rw-r--r--src/lib9/fmt/fmt.c10
-rw-r--r--src/lib9/fmt/fmtdef.h79
-rw-r--r--src/lib9/fmt/fmtfd.c2
-rw-r--r--src/lib9/fmt/fmtfdflush.c1
-rw-r--r--src/lib9/fmt/fmtlock.c1
-rw-r--r--src/lib9/fmt/fmtprint.c2
-rw-r--r--src/lib9/fmt/fmtquote.c2
-rw-r--r--src/lib9/fmt/fmtrune.c2
-rw-r--r--src/lib9/fmt/fmtstr.c11
-rw-r--r--src/lib9/fmt/fmtvprint.c2
-rw-r--r--src/lib9/fmt/fprint.c3
-rw-r--r--src/lib9/fmt/nan64.c15
-rw-r--r--src/lib9/fmt/pow10.c2
-rw-r--r--src/lib9/fmt/print.c3
-rw-r--r--src/lib9/fmt/runefmtstr.c11
-rw-r--r--src/lib9/fmt/runeseprint.c2
-rw-r--r--src/lib9/fmt/runesmprint.c2
-rw-r--r--src/lib9/fmt/runesnprint.c2
-rw-r--r--src/lib9/fmt/runesprint.c2
-rw-r--r--src/lib9/fmt/runevseprint.c2
-rw-r--r--src/lib9/fmt/runevsmprint.c2
-rw-r--r--src/lib9/fmt/runevsnprint.c2
-rw-r--r--src/lib9/fmt/seprint.c2
-rw-r--r--src/lib9/fmt/smprint.c2
-rw-r--r--src/lib9/fmt/snprint.c2
-rw-r--r--src/lib9/fmt/sprint.c2
-rw-r--r--src/lib9/fmt/strtod.c10
-rw-r--r--src/lib9/fmt/test.c2
-rw-r--r--src/lib9/fmt/vfprint.c1
-rw-r--r--src/lib9/fmt/vseprint.c1
-rw-r--r--src/lib9/fmt/vsmprint.c1
-rw-r--r--src/lib9/fmt/vsnprint.c1
-rw-r--r--src/lib9/utf/rune.c2
-rw-r--r--src/lib9/utf/runestrcat.c2
-rw-r--r--src/lib9/utf/runestrchr.c2
-rw-r--r--src/lib9/utf/runestrcmp.c2
-rw-r--r--src/lib9/utf/runestrcpy.c2
-rw-r--r--src/lib9/utf/runestrdup.c2
-rw-r--r--src/lib9/utf/runestrecpy.c2
-rw-r--r--src/lib9/utf/runestrlen.c2
-rw-r--r--src/lib9/utf/runestrncat.c2
-rw-r--r--src/lib9/utf/runestrncmp.c2
-rw-r--r--src/lib9/utf/runestrncpy.c2
-rw-r--r--src/lib9/utf/runestrrchr.c2
-rw-r--r--src/lib9/utf/runestrstr.c2
-rw-r--r--src/lib9/utf/runetype.c5
-rw-r--r--src/lib9/utf/utfdef.h35
-rw-r--r--src/lib9/utf/utfecpy.c2
-rw-r--r--src/lib9/utf/utflen.c2
-rw-r--r--src/lib9/utf/utfnlen.c2
-rw-r--r--src/lib9/utf/utfrrune.c2
-rw-r--r--src/lib9/utf/utfrune.c2
-rw-r--r--src/lib9/utf/utfutf.c2
58 files changed, 160 insertions, 127 deletions
diff --git a/src/lib9/fmt/charstod.c b/src/lib9/fmt/charstod.c
index ec403b11..65a4e189 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 cee3f4e4..873d6926 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 @@ __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;
}
@@ -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;
@@ -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;
diff --git a/src/lib9/fmt/dorfmt.c b/src/lib9/fmt/dorfmt.c
index cdaee8a5..5b547d51 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 @@ 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;
}
diff --git a/src/lib9/fmt/errfmt.c b/src/lib9/fmt/errfmt.c
index 21847054..df6c3101 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 234f03d9..a7e57997 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 976bf7ca..f9d8328d 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 @@ 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,
};
@@ -103,7 +107,7 @@ __fmtinstall(int c, Fmts f)
}
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 89468767..bfb2aa97 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 @@ 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{\
diff --git a/src/lib9/fmt/fmtfd.c b/src/lib9/fmt/fmtfd.c
index d4251402..5de42ae6 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 796feab2..73bf47c4 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 fffe81cf..7501ce41 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 c682f49f..7044d5bd 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 9d5633d6..b8f00c18 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 a034546b..a7f620eb 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 0b227166..b4b68185 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 60974a0b..d1176a50 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 c8b889de..b1433806 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 dcdcd799..6e355a20 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 @@ __isInf(double d, int sign)
else
return x==uvneginf;
}
-
-
diff --git a/src/lib9/fmt/pow10.c b/src/lib9/fmt/pow10.c
index 65a426c3..ecd8b6dc 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 381a1da9..81f202f8 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 9ec84cd0..53376395 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 7829a439..2753b580 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 538ae0ee..285ec190 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 5abb6dbf..2fd1b417 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 8abfeb65..ad66efaf 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 a9ef99b9..72f7e1b0 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 3326da81..988e5c02 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 71557e5b..8aff7345 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 d5031a2b..32f60c69 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 543411a0..1bc8975a 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 594606d2..693affd7 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 8551ca3c..8313b169 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 685b7fae..5939dd90 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 a1a1d5ed..650f0f55 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 711b6588..1df47477 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 a1be5e40..9eb674ac 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 4f55c41c..871531ee 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 7272ab62..ec05d48a 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 e1aaa9be..1cf8c7e6 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 e1e8c9d5..f345a1b6 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 45ee673a..90d05e5a 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 d14145f3..35906275 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 9d7aa026..b8c2411f 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 97a889c8..7accedaa 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 f3e4a096..83450c9a 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 bca3050c..0096d525 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 74400c30..7404fb9a 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 dbd9da45..4fbdb0a1 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 acba7bc2..f2517347 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 1f40c5a6..1f368548 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 48583a3d..8be7a032 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 ffae30e6..41a32729 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 @@ Rune __totitle1[] =
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 4b58ae87..1ff41813 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;
+
+/*
+ * 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)
diff --git a/src/lib9/utf/utfecpy.c b/src/lib9/utf/utfecpy.c
index 57159350..fde9338c 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 a10a5318..2e8c666a 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 66d674fd..6418f619 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 37d2a725..fc84d6b8 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 1a2e04c9..5aa476a9 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 ea360361..70873cc3 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"
/*