This commit is contained in:
Russ Cox 2006-01-17 12:48:16 +00:00
parent 8741145095
commit f18ed453eb
9 changed files with 56 additions and 84 deletions

View File

@ -54,6 +54,7 @@ static Dirlist bootlist =
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 @@ static Dirlist mntlist =
{
Qmnt,
mntdir,
nil,
mntdata,
2,
Nmntfiles
};

View File

@ -1158,7 +1158,7 @@ werrstr(char *f, ...)
}
int
errfmt(Fmt *fmt)
__errfmt(Fmt *fmt)
{
if(up->nerrlab)
return fmtstrcpy(fmt, up->errstr);

View File

@ -22,6 +22,7 @@ OFILES=\
fltfmt.$O\
fmt.$O\
fmtfd.$O\
fmtfdflush.$O\
fmtlock.$O\
fmtprint.$O\
fmtquote.$O\

View File

@ -1,28 +0,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);
}

View File

@ -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 @@ enum{
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);
/* 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 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*);
extern double fmtstrtod(const char *, char **);
extern double fmtcharstod(int(*)(void*), void*);
#if defined(__cplusplus)
}
#endif
#endif

View File

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

View File

@ -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 @@ __fmtFdFlush(Fmt *f)
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;

View File

@ -55,7 +55,6 @@ _memimageinit(void)
fmtinstall('R', Rfmt);
fmtinstall('P', Pfmt);
fmtinstall('b', _ifmt);
memones = allocmemimage(Rect(0,0,1,1), GREY1);
memones->flags |= Frepl;

1
main.c
View File

@ -36,7 +36,6 @@ main(int argc, char **argv)
eve = "drawterm";
sizebug();
fmtinstall('r', errfmt);
osinit();
procinit0();