From f18ed453ebe4e6e03a96804fd5a596d067fe0d04 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 17 Jan 2006 12:48:16 +0000 Subject: [PATCH] fixes --- kern/devroot.c | 3 +- kern/sysfile.c | 2 +- libc/Makefile | 1 + libc/errfmt.c | 28 --------------- libc/fmt.h | 88 ++++++++++++++++++++++++----------------------- libc/fmtfd.c | 7 ++-- libc/fmtfdflush.c | 9 +++-- libmemdraw/draw.c | 1 - main.c | 1 - 9 files changed, 56 insertions(+), 84 deletions(-) delete mode 100644 libc/errfmt.c diff --git a/kern/devroot.c b/kern/devroot.c index 951e113..db081ff 100644 --- a/kern/devroot.c +++ b/kern/devroot.c @@ -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 }; diff --git a/kern/sysfile.c b/kern/sysfile.c index 34042c3..32272fd 100644 --- a/kern/sysfile.c +++ b/kern/sysfile.c @@ -1158,7 +1158,7 @@ werrstr(char *f, ...) } int -errfmt(Fmt *fmt) +__errfmt(Fmt *fmt) { if(up->nerrlab) return fmtstrcpy(fmt, up->errstr); diff --git a/libc/Makefile b/libc/Makefile index 7e773fb..9a1d72c 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -22,6 +22,7 @@ OFILES=\ fltfmt.$O\ fmt.$O\ fmtfd.$O\ + fmtfdflush.$O\ fmtlock.$O\ fmtprint.$O\ fmtquote.$O\ diff --git a/libc/errfmt.c b/libc/errfmt.c deleted file mode 100644 index b0eae73..0000000 --- a/libc/errfmt.c +++ /dev/null @@ -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 -#include -#include -#include "plan9.h" -#include "fmt.h" -#include "fmtdef.h" - -int -__errfmt(Fmt *f) -{ - char *s; - - s = strerror(errno); - return fmtstrcpy(f, s); -} diff --git a/libc/fmt.h b/libc/fmt.h index e3c9a98..1744ddc 100644 --- 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 - -#ifndef _UTFH_ #include -#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 diff --git a/libc/fmtfd.c b/libc/fmtfd.c index 9f35f02..84decd0 100644 --- 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 -#include -#include "plan9.h" -#include "fmt.h" +#include +#include +#include #include "fmtdef.h" /* diff --git a/libc/fmtfdflush.c b/libc/fmtfdflush.c index b615416..b94b2be 100644 --- 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 -#include -#include "plan9.h" -#include "fmt.h" +#include +#include +#include #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; diff --git a/libmemdraw/draw.c b/libmemdraw/draw.c index dab0ca2..523f174 100644 --- a/libmemdraw/draw.c +++ b/libmemdraw/draw.c @@ -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; diff --git a/main.c b/main.c index 5ab5257..091a133 100644 --- a/main.c +++ b/main.c @@ -36,7 +36,6 @@ main(int argc, char **argv) eve = "drawterm"; sizebug(); - fmtinstall('r', errfmt); osinit(); procinit0();