diff --git a/include/lib.h b/include/lib.h index 31c8d26..e3cdaa2 100644 --- a/include/lib.h +++ b/include/lib.h @@ -3,8 +3,7 @@ #define listen pm_listen #define sleep ksleep #define wakeup kwakeup -#define strtod libstrtod -#define pow10 libpow10 +#define strtod fmtstrtod /* conflicts on some os's */ #define encrypt libencrypt @@ -200,7 +199,8 @@ enum{ FmtComma = FmtVLong << 1, FmtByte = FmtComma << 1, - FmtFlag = FmtByte << 1 + FmtFlag = FmtByte << 1, + FmtLDouble = FmtFlag << 1 }; extern int print(char*, ...); @@ -253,8 +253,10 @@ void hnputs(void *p, unsigned short v); extern int dofmt(Fmt*, char*); extern double __NaN(void); extern int __isNaN(double); -extern double strtod(char*, char**); +extern double strtod(const char*, char**); extern int utfnlen(char*, long); extern double __Inf(int); extern int __isInf(double, int); -extern double pow10(int); + +extern int (*fmtdoquote)(int); + diff --git a/include/unix.h b/include/unix.h index a196494..81764ad 100644 --- a/include/unix.h +++ b/include/unix.h @@ -8,7 +8,10 @@ #include #include #include - +#include +#include +#include typedef long long p9_vlong; typedef unsigned long long p9_uvlong; +typedef uintptr_t uintptr; diff --git a/libc/dofmt.c b/libc/dofmt.c index 560d5c8..64e1c2e 100644 --- a/libc/dofmt.c +++ b/libc/dofmt.c @@ -332,7 +332,6 @@ __ifmt(Fmt *f) isv = 0; vu = 0; u = 0; -#ifndef PLAN9PORT /* * Unsigned verbs for ANSI C */ @@ -346,7 +345,6 @@ __ifmt(Fmt *f) fl &= ~(FmtSign|FmtSpace); break; } -#endif if(f->r == 'p'){ u = (ulong)va_arg(f->args, void*); f->r = 'x'; diff --git a/libc/fmt.h b/libc/fmt.h deleted file mode 100644 index 1744ddc..0000000 --- a/libc/fmt.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef _FMT_H_ -#define _FMT_H_ 1 -#if defined(__cplusplus) -extern "C" { -#endif -/* - * The authors of this software are Rob Pike and Ken Thompson. - * Copyright (c) 2002 by Lucent Technologies. - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. - */ - -#include -#include - -typedef struct Fmt Fmt; -struct Fmt{ - unsigned char runes; /* output buffer is runes or chars? */ - void *start; /* of buffer */ - void *to; /* current place in the buffer */ - void *stop; /* end of the buffer; overwritten if flush fails */ - int (*flush)(Fmt *); /* called when to == stop */ - void *farg; /* to make flush a closure */ - int nfmt; /* num chars formatted so far */ - va_list args; /* args passed to dofmt */ - int r; /* % format Rune */ - int width; - int prec; - unsigned long flags; -}; - -enum{ - FmtWidth = 1, - FmtLeft = FmtWidth << 1, - FmtPrec = FmtLeft << 1, - FmtSharp = FmtPrec << 1, - FmtSpace = FmtSharp << 1, - FmtSign = FmtSpace << 1, - FmtZero = FmtSign << 1, - FmtUnsigned = FmtZero << 1, - FmtShort = FmtUnsigned << 1, - FmtLong = FmtShort << 1, - FmtVLong = FmtLong << 1, - FmtComma = FmtVLong << 1, - FmtByte = FmtComma << 1, - FmtLDouble = FmtByte << 1, - - FmtFlag = FmtLDouble << 1 -}; - -extern int (*fmtdoquote)(int); - -/* Edit .+1,/^$/ | cfn $PLAN9/src/lib9/fmt/?*.c | grep -v static |grep -v __ */ -int dofmt(Fmt *f, char *fmt); -int dorfmt(Fmt *f, const Rune *fmt); -double fmtcharstod(int(*f)(void*), void *vp); -int fmtfdflush(Fmt *f); -int fmtfdinit(Fmt *f, int fd, char *buf, int size); -int fmtinstall(int c, int (*f)(Fmt*)); -int fmtprint(Fmt *f, char *fmt, ...); -int fmtrune(Fmt *f, int r); -int fmtrunestrcpy(Fmt *f, Rune *s); -int fmtstrcpy(Fmt *f, char *s); -char* fmtstrflush(Fmt *f); -int fmtstrinit(Fmt *f); -double fmtstrtod(const char *as, char **aas); -int fmtvprint(Fmt *f, char *fmt, va_list args); -int fprint(int fd, char *fmt, ...); -int print(char *fmt, ...); -void quotefmtinstall(void); -int quoterunestrfmt(Fmt *f); -int quotestrfmt(Fmt *f); -Rune* runefmtstrflush(Fmt *f); -int runefmtstrinit(Fmt *f); -Rune* runeseprint(Rune *buf, Rune *e, char *fmt, ...); -Rune* runesmprint(char *fmt, ...); -int runesnprint(Rune *buf, int len, char *fmt, ...); -int runesprint(Rune *buf, char *fmt, ...); -Rune* runevseprint(Rune *buf, Rune *e, char *fmt, va_list args); -Rune* runevsmprint(char *fmt, va_list args); -int runevsnprint(Rune *buf, int len, char *fmt, va_list args); -char* seprint(char *buf, char *e, char *fmt, ...); -char* smprint(char *fmt, ...); -int snprint(char *buf, int len, char *fmt, ...); -int sprint(char *buf, char *fmt, ...); -int vfprint(int fd, char *fmt, va_list args); -char* vseprint(char *buf, char *e, char *fmt, va_list args); -char* vsmprint(char *fmt, va_list args); -int vsnprint(char *buf, int len, char *fmt, va_list args); - -#if defined(__cplusplus) -} -#endif -#endif diff --git a/libc/fmtdef.h b/libc/fmtdef.h index 5a63f9b..7f8fa25 100644 --- a/libc/fmtdef.h +++ b/libc/fmtdef.h @@ -114,3 +114,4 @@ int __strfmt(Fmt *f); # define VA_END(a) #endif +#define PLAN9PORT diff --git a/libc/fprint.c b/libc/fprint.c index 043202c..8df42a1 100644 --- a/libc/fprint.c +++ b/libc/fprint.c @@ -11,9 +11,8 @@ * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ -#include -#include "plan9.h" -#include "fmt.h" +#include +#include #include "fmtdef.h" int diff --git a/libc/nan64.c b/libc/nan64.c index 6e355a2..c5e6eef 100644 --- a/libc/nan64.c +++ b/libc/nan64.c @@ -5,8 +5,8 @@ * same byte ordering. */ -#include "plan9.h" -#include "fmt.h" +#include +#include #include "fmtdef.h" #if defined (__APPLE__) || (__powerpc__) diff --git a/libc/plan9.h b/libc/plan9.h deleted file mode 100644 index 22fa7f0..0000000 --- a/libc/plan9.h +++ /dev/null @@ -1,38 +0,0 @@ -#include - -/* - * 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 -#define uintptr _fmtuintptr - -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; -typedef uintptr_t uintptr; - -/* - * nil cannot be ((void*)0) on ANSI C, - * because it is used for function pointers - */ -#undef nil -#define nil 0 - -#undef nelem -#define nelem(x) (sizeof (x)/sizeof (x)[0]) -