X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fputs.c;h=b7954ea0c69b92895a76741d8df170c6ccdd4cab;hb=ef6aa72f40326153ba99e833340ace354799ed95;hp=40c9727643fa3ad424cd33032b59e75f9950e2f3;hpb=e5112b619d1aae8ffc439389cfcbd3b2b4bd2454;p=pdclib diff --git a/functions/stdio/puts.c b/functions/stdio/puts.c index 40c9727..b7954ea 100644 --- a/functions/stdio/puts.c +++ b/functions/stdio/puts.c @@ -9,11 +9,37 @@ #include #ifndef REGTEST +#include <_PDCLIB_glue.h> + +extern char * _PDCLIB_eol; int puts( const char * s ) { - /* TODO: Implement. */ - return 0; + if ( _PDCLIB_prepwrite( stdout ) == EOF ) + { + return EOF; + } + while ( *s != '\0' ) + { + stdout->buffer[ stdout->bufidx++ ] = *s++; + if ( stdout->bufidx == stdout->bufsize ) + { + if ( _PDCLIB_flushbuffer( stdout ) == EOF ) + { + return EOF; + } + } + } + stdout->buffer[ stdout->bufidx++ ] = '\n'; + if ( ( stdout->bufidx == stdout->bufsize ) || + ( stdout->status & ( _IOLBF | _IONBF ) ) ) + { + return _PDCLIB_flushbuffer( stdout ); + } + else + { + return 0; + } } #endif @@ -23,8 +49,9 @@ int puts( const char * s ) int main( void ) { - TESTCASE( NO_TESTDRIVER ); + TESTCASE( puts( "SUCCESS testing puts()" ) >= 0 ); return TEST_RESULTS; } #endif +