shithub: drawterm

Download patch

ref: 5572ebf9ed54fa7d53480e8119bf10205dc5298b
parent: f60d3735c65b04554d206ced6d45370cc1d5633d
author: Russ Cox <[email protected]>
date: Tue Jan 17 08:55:02 EST 2006

fixes

--- 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 @@
 	FmtComma	= FmtVLong << 1,
 	FmtByte	= FmtComma << 1,
 
-	FmtFlag		= FmtByte << 1
+	FmtFlag		= FmtByte << 1,
+	FmtLDouble	= FmtFlag << 1
 };
 
 extern	int	print(char*, ...);
@@ -253,8 +253,10 @@
 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);
+
--- a/include/unix.h
+++ b/include/unix.h
@@ -8,7 +8,10 @@
 #include <assert.h>
 #include <unistd.h>
 #include <stdarg.h>
+#include <inttypes.h>
+#include <ctype.h>
+#include <errno.h>
 
-
 typedef long long		p9_vlong;
 typedef	unsigned long long p9_uvlong;
+typedef uintptr_t uintptr;
--- a/libc/dofmt.c
+++ b/libc/dofmt.c
@@ -332,7 +332,6 @@
 	isv = 0;
 	vu = 0;
 	u = 0;
-#ifndef PLAN9PORT
 	/*
 	 * Unsigned verbs for ANSI C
 	 */
@@ -346,7 +345,6 @@
 		fl &= ~(FmtSign|FmtSpace);
 		break;
 	}
-#endif
 	if(f->r == 'p'){
 		u = (ulong)va_arg(f->args, void*);
 		f->r = 'x';
--- a/libc/fmt.h
+++ /dev/null
@@ -1,101 +1,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 <stdarg.h>
-#include <utf.h>
-
-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
--- a/libc/fmtdef.h
+++ b/libc/fmtdef.h
@@ -114,3 +114,4 @@
 #	define VA_END(a)
 #endif
 
+#define PLAN9PORT
--- 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 <stdarg.h>
-#include "plan9.h"
-#include "fmt.h"
+#include <u.h>
+#include <libc.h>
 #include "fmtdef.h"
 
 int
--- a/libc/nan64.c
+++ b/libc/nan64.c
@@ -5,8 +5,8 @@
  * same byte ordering.
  */
 
-#include "plan9.h"
-#include "fmt.h"
+#include <u.h>
+#include <libc.h>
 #include "fmtdef.h"
 
 #if defined (__APPLE__) || (__powerpc__)
--- a/libc/plan9.h
+++ /dev/null
@@ -1,38 +1,0 @@
-#include <stdint.h>
-
-/*
- * 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])
-