From 9a862b964b7c7226f4d2fc52de13e0db0a9c66d4 Mon Sep 17 00:00:00 2001 From: solar Date: Mon, 13 Jun 2011 10:03:13 +0000 Subject: [PATCH] Fixes #45. --- functions/stdio/getc.c | 29 +++++++++++++++++++++++++++++ functions/stdio/getchar.c | 29 +++++++++++++++++++++++++++++ functions/stdio/putc.c | 29 +++++++++++++++++++++++++++++ functions/stdio/putchar.c | 29 +++++++++++++++++++++++++++++ includes/stdio.h | 16 ++++++++-------- 5 files changed, 124 insertions(+), 8 deletions(-) create mode 100644 functions/stdio/getc.c create mode 100644 functions/stdio/getchar.c create mode 100644 functions/stdio/putc.c create mode 100644 functions/stdio/putchar.c diff --git a/functions/stdio/getc.c b/functions/stdio/getc.c new file mode 100644 index 0000000..a459c22 --- /dev/null +++ b/functions/stdio/getc.c @@ -0,0 +1,29 @@ +/* $Id$ */ + +/* getc( FILE * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +int getc( struct _PDCLIB_file_t * stream ) +{ + return fgetc( stream ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + /* Testing covered by ftell.c */ + return TEST_RESULTS; +} + +#endif diff --git a/functions/stdio/getchar.c b/functions/stdio/getchar.c new file mode 100644 index 0000000..1603728 --- /dev/null +++ b/functions/stdio/getchar.c @@ -0,0 +1,29 @@ +/* $Id$ */ + +/* getchar( void ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +int getchar( void ) +{ + return fgetc( stdin ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + /* Testing covered by ftell.c */ + return TEST_RESULTS; +} + +#endif diff --git a/functions/stdio/putc.c b/functions/stdio/putc.c new file mode 100644 index 0000000..60a4dba --- /dev/null +++ b/functions/stdio/putc.c @@ -0,0 +1,29 @@ +/* $Id$ */ + +/* putc( int, FILE * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +int putc( int c, struct _PDCLIB_file_t * stream ) +{ + return fputc( c, stream ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + /* Testing covered by ftell.c */ + return TEST_RESULTS; +} + +#endif diff --git a/functions/stdio/putchar.c b/functions/stdio/putchar.c new file mode 100644 index 0000000..4e2d6ae --- /dev/null +++ b/functions/stdio/putchar.c @@ -0,0 +1,29 @@ +/* $Id$ */ + +/* putchar( int ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +int putchar( int c ) +{ + return fputc( c, stdout ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + /* Testing covered by ftell.c */ + return TEST_RESULTS; +} + +#endif diff --git a/includes/stdio.h b/includes/stdio.h index 6b562d9..a2428a5 100644 --- a/includes/stdio.h +++ b/includes/stdio.h @@ -654,13 +654,13 @@ int fputc( int c, FILE * stream ); */ int fputs( const char * _PDCLIB_restrict s, FILE * _PDCLIB_restrict stream ); -/* Equivalent to fgetc( stream ), but may be implemented as a macro that +/* Equivalent to fgetc( stream ), but may be overloaded by a macro that evaluates its parameter more than once. */ -#define getc( stream ) fgetc( stream ) +int getc( FILE * stream ); -/* Equivalent to fgetc( stdin ), but may be implemented as a macro. */ -#define getchar() fgetc( stdin ) +/* Equivalent to fgetc( stdin ). */ +int getchar( void ); /* Read characters from given stream into the array s, stopping at \n or EOF. The string read is terminated with \0. Returns s if successful. If EOF is @@ -670,15 +670,15 @@ int fputs( const char * _PDCLIB_restrict s, FILE * _PDCLIB_restrict stream ); */ char * gets( char * s ); -/* Equivalent to fputc( c, stream ), but may be implemented as a macro that +/* Equivalent to fputc( c, stream ), but may be overloaded by a macro that evaluates its parameter more than once. */ -#define putc( c, stream ) fputc( c, stream ) +int putc( int c, FILE * stream ); -/* Equivalent to fputc( c, stdout ), but may be implemented as a macro that +/* Equivalent to fputc( c, stdout ), but may be overloaded by a macro that evaluates its parameter more than once. */ -#define putchar( c ) putc( c, stdout ) +int putchar( int c ); /* Write the string s (not including the terminating \0) to stdout, and append a newline to the output. Returns a value >= 0 when successful, EOF if a -- 2.40.0