shithub: drawterm-fdroid

Download patch

ref: f18ed453ebe4e6e03a96804fd5a596d067fe0d04
parent: 8741145095d580cae230e3d4dd1928168bbb49d5
author: Russ Cox <rsc@swtch.com>
date: Tue Jan 17 07:48:16 EST 2006

fixes

--- a/kern/devroot.c
+++ b/kern/devroot.c
@@ -54,6 +54,7 @@
 	Nbootfiles
 };
 
+static uchar *mntdata[Nmntfiles];
 static Dirtab mntdir[Nmntfiles] = {
 	"mnt",	{Qmnt, 0, QTDIR},	0,		DMDIR|0555,
 	"factotum",	{Qfactotum, 0, QTDIR},	0,	DMDIR|0555,
@@ -62,7 +63,7 @@
 {
 	Qmnt,
 	mntdir,
-	nil,
+	mntdata,
 	2,
 	Nmntfiles
 };
--- a/kern/sysfile.c
+++ b/kern/sysfile.c
@@ -1158,7 +1158,7 @@
 }
 
 int
-errfmt(Fmt *fmt)
+__errfmt(Fmt *fmt)
 {
 	if(up->nerrlab)
 		return fmtstrcpy(fmt, up->errstr);
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -22,6 +22,7 @@
 	fltfmt.$O\
 	fmt.$O\
 	fmtfd.$O\
+	fmtfdflush.$O\
 	fmtlock.$O\
 	fmtprint.$O\
 	fmtquote.$O\
--- a/libc/errfmt.c
+++ /dev/null
@@ -1,28 +1,0 @@
-/*
- * 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 <errno.h>
-#include <string.h>
-#include "plan9.h"
-#include "fmt.h"
-#include "fmtdef.h"
-
-int
-__errfmt(Fmt *f)
-{
-	char *s;
-
-	s = strerror(errno);
-	return fmtstrcpy(f, s);
-}
--- a/libc/fmt.h
+++ b/libc/fmt.h
@@ -1,4 +1,8 @@
-
+#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.
@@ -13,14 +17,8 @@
  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  */
 
-#ifndef _FMTH_
-#define _FMTH_ 1
-
 #include <stdarg.h>
-
-#ifndef _UTFH_
 #include <utf.h>
-#endif
 
 typedef struct Fmt	Fmt;
 struct Fmt{
@@ -57,43 +55,47 @@
 	FmtFlag		= FmtLDouble << 1
 };
 
-extern	int	print(char*, ...);
-extern	char*	seprint(char*, char*, char*, ...);
-extern	char*	vseprint(char*, char*, char*, va_list);
-extern	int	snprint(char*, int, char*, ...);
-extern	int	vsnprint(char*, int, char*, va_list);
-extern	char*	smprint(char*, ...);
-extern	char*	vsmprint(char*, va_list);
-extern	int	sprint(char*, char*, ...);
-extern	int	fprint(int, char*, ...);
-extern	int	vfprint(int, char*, va_list);
-
-extern	int	runesprint(Rune*, char*, ...);
-extern	int	runesnprint(Rune*, int, char*, ...);
-extern	int	runevsnprint(Rune*, int, char*, va_list);
-extern	Rune*	runeseprint(Rune*, Rune*, char*, ...);
-extern	Rune*	runevseprint(Rune*, Rune*, char*, va_list);
-extern	Rune*	runesmprint(char*, ...);
-extern	Rune*	runevsmprint(char*, va_list);
-
-extern	int	fmtfdinit(Fmt*, int, char*, int);
-extern	int	fmtfdflush(Fmt*);
-extern	int	fmtstrinit(Fmt*);
-extern	char*	fmtstrflush(Fmt*);
-
-extern	int	quotestrfmt(Fmt *f);
-extern	void	quotefmtinstall(void);
 extern	int	(*fmtdoquote)(int);
 
-
-extern	int	fmtinstall(int, int (*)(Fmt*));
-extern	int	dofmt(Fmt*, char*);
-extern	int	fmtprint(Fmt*, char*, ...);
-extern	int	fmtvprint(Fmt*, char*, va_list);
-extern	int	fmtrune(Fmt*, int);
-extern	int	fmtstrcpy(Fmt*, char*);
+/* 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);
 
-extern	double	fmtstrtod(const char *, char **);
-extern	double	fmtcharstod(int(*)(void*), void*);
-
+#if defined(__cplusplus)
+}
+#endif
 #endif
--- a/libc/fmtfd.c
+++ b/libc/fmtfd.c
@@ -11,10 +11,9 @@
  * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  */
-#include <stdarg.h>
-#include <string.h>
-#include "plan9.h"
-#include "fmt.h"
+#include <inttypes.h>
+#include <u.h>
+#include <libc.h>
 #include "fmtdef.h"
 
 /*
--- a/libc/fmtfdflush.c
+++ b/libc/fmtfdflush.c
@@ -11,10 +11,9 @@
  * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  */
-#include <stdarg.h>
-#include <unistd.h>
-#include "plan9.h"
-#include "fmt.h"
+#include <inttypes.h>
+#include <u.h>
+#include <libc.h>
 #include "fmtdef.h"
 
 /*
@@ -27,7 +26,7 @@
 	int n;
 
 	n = (char*)f->to - (char*)f->start;
-	if(n && write((uintptr)f->farg, f->start, n) != n)
+	if(n && write((uintptr_t)f->farg, f->start, n) != n)
 		return 0;
 	f->to = f->start;
 	return 1;
--- a/libmemdraw/draw.c
+++ b/libmemdraw/draw.c
@@ -55,7 +55,6 @@
 
 	fmtinstall('R', Rfmt); 
 	fmtinstall('P', Pfmt);
-	fmtinstall('b', _ifmt);
 
 	memones = allocmemimage(Rect(0,0,1,1), GREY1);
 	memones->flags |= Frepl;
--- a/main.c
+++ b/main.c
@@ -36,7 +36,6 @@
 		eve = "drawterm";
 
 	sizebug();
-	fmtinstall('r', errfmt);
 
 	osinit();
 	procinit0();