clean up for unix port

This commit is contained in:
rsc 2004-12-26 21:50:14 +00:00
parent 5c8a042171
commit e5aa96acbf
58 changed files with 160 additions and 127 deletions

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -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;

View file

@ -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;
}

View file

@ -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"

View file

@ -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
{

View file

@ -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;

View file

@ -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{\

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -13,6 +13,7 @@
*/
#include <stdarg.h>
#include <unistd.h>
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -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"

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -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)

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -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, ...)

View file

@ -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;
}

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -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, ...)

View file

@ -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)

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -13,7 +13,7 @@
*/
#include <stdarg.h>
#include <string.h>
#include "utf.h"
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -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, ...)

View file

@ -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, ...)

View file

@ -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, ...)

View file

@ -13,6 +13,8 @@
*/
#include <stdarg.h>
#include <fmt.h>
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"
int

View file

@ -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)

View file

@ -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[])

View file

@ -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"

View file

@ -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"

View file

@ -13,6 +13,7 @@
*/
#include <stdlib.h>
#include <stdarg.h>
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -13,6 +13,7 @@
*/
#include <stdlib.h>
#include <stdarg.h>
#include "plan9.h"
#include "fmt.h"
#include "fmtdef.h"

View file

@ -13,8 +13,8 @@
*/
#include <stdarg.h>
#include <string.h>
#include "plan9.h"
#include "utf.h"
#include "utfdef.h"
enum
{

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -13,8 +13,8 @@
*/
#include <stdarg.h>
#include <string.h>
#include "plan9.h"
#include "utf.h"
#include "utfdef.h"
long
runestrlen(Rune *s)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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,

View file

@ -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;

View file

@ -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)

View file

@ -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)

View file

@ -13,8 +13,8 @@
*/
#include <stdarg.h>
#include <string.h>
#include "plan9.h"
#include "utf.h"
#include "utfdef.h"
int
utflen(char *s)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -13,8 +13,8 @@
*/
#include <stdarg.h>
#include <string.h>
#include "plan9.h"
#include "utf.h"
#include "utfdef.h"
/*