From fa40f30b4253b1e05c46cc5e0c111176825b7623 Mon Sep 17 00:00:00 2001 From: Mystery Man Date: Wed, 29 Oct 2003 16:07:11 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'Corpo_2_1_1'. --- mdk-stage1/dietlibc/libstdio/fflush.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'mdk-stage1/dietlibc/libstdio/fflush.c') diff --git a/mdk-stage1/dietlibc/libstdio/fflush.c b/mdk-stage1/dietlibc/libstdio/fflush.c index 7078e04f4..e0e23b3ba 100644 --- a/mdk-stage1/dietlibc/libstdio/fflush.c +++ b/mdk-stage1/dietlibc/libstdio/fflush.c @@ -1,21 +1,16 @@ -#include "dietstdio.h" #include #include #include "dietwarning.h" +#include "dietstdio.h" FILE *__stdio_root; -#ifdef WANT_BUFFERED_STDIO int __stdio_atexit=0; -void __stdio_flushall() { +void __stdio_flushall(void) { fflush(0); } -extern int __fflush_stdin(); -extern int __fflush_stdout(); -extern int __fflush_stderr(); - int fflush(FILE *stream) { if (stream==0) { int res; @@ -28,15 +23,20 @@ int fflush(FILE *stream) { res=-1; return res; } +// if (stream->flags&NOBUF) return 0; if (stream->flags&BUFINPUT) { register int tmp; - if ((tmp=stream->bm-stream->bs)) lseek(stream->fd,tmp,SEEK_CUR); - } else - if (stream->bm && write(stream->fd,stream->buf,stream->bm)!=stream->bm) { + if ((tmp=stream->bm-stream->bs)) { + lseek(stream->fd,tmp,SEEK_CUR); + } + stream->bs=stream->bm=0; + } else { + if (stream->bm && write(stream->fd,stream->buf,stream->bm)!=(int)stream->bm) { stream->flags|=ERRORINDICATOR; return -1; } - stream->bm=0; + stream->bm=0; + } return 0; } @@ -50,13 +50,15 @@ int __fflush4(FILE *stream,int next) { stream->flags=(stream->flags&~BUFINPUT)|next; return res; } + if (stream->fd==0) __fflush_stdout(); return 0; } -#else -int fflush(FILE *stream) { - return 0; +/* Internal function, has no prototype. + * This is defined here because of the weak symbol ELF semantics */ +int __stdio_outs(const char *s,size_t len); +int __stdio_outs(const char *s,size_t len) { + return fwrite(s,1,(size_t)len,stdout)==len?1:0; } -#endif -link_warning("fflush","warning: your code uses stdio (several kilobytes of bloat).") +link_warning("fflush","warning: your code uses stdio (7+k bloat).") -- cgit v1.2.1