From df121a0027e6dc08abe6fc907c9af2593a263c17 Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 26 Dec 2004 23:07:37 +0000 Subject: import changes from plan 9 --- src/lib9/fmt/fmtstr.c | 52 +++------------------------------------------------ 1 file changed, 3 insertions(+), 49 deletions(-) (limited to 'src/lib9/fmt/fmtstr.c') diff --git a/src/lib9/fmt/fmtstr.c b/src/lib9/fmt/fmtstr.c index b4b68185..8568b5d5 100644 --- a/src/lib9/fmt/fmtstr.c +++ b/src/lib9/fmt/fmtstr.c @@ -11,63 +11,17 @@ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ -/* - * Plan 9 port version must include libc.h in order to - * get Plan 9 debugging malloc, which sometimes returns - * different pointers than the standard malloc. - */ -#ifdef PLAN9PORT -#include -#include -#else #include +#include #include "plan9.h" #include "fmt.h" #include "fmtdef.h" -#endif - -static int -fmtStrFlush(Fmt *f) -{ - char *s; - int n; - - n = (int)f->farg; - n += 256; - f->farg = (void*)n; - s = (char*)f->start; - f->start = realloc(s, n); - if(f->start == nil){ - f->start = s; - return 0; - } - f->to = (char*)f->start + ((char*)f->to - s); - f->stop = (char*)f->start + n - 1; - return 1; -} - -int -fmtstrinit(Fmt *f) -{ - int n; - - f->runes = 0; - n = 32; - f->start = malloc(n); - if(f->start == nil) - return -1; - f->to = f->start; - f->stop = (char*)f->start + n - 1; - f->flush = fmtStrFlush; - f->farg = (void*)n; - f->nfmt = 0; - return 0; -} char* fmtstrflush(Fmt *f) { + if(f->start == nil) + return nil; *(char*)f->to = '\0'; - f->to = f->start; return (char*)f->start; } -- cgit v1.2.3