X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffgets.c;h=04510583ad29e82b46671106b81caac76399594e;hb=84d648157e22cecc65902ecfdd4e3a1b88d5e53f;hp=44518a3e0b0f2552a8d5b1a47c81fb7fd3bf37f0;hpb=fce9a8538009ea5c113b03c608cedf036ce4a364;p=pdclib.old diff --git a/functions/stdio/fgets.c b/functions/stdio/fgets.c index 44518a3..0451058 100644 --- a/functions/stdio/fgets.c +++ b/functions/stdio/fgets.c @@ -12,7 +12,7 @@ #include <_PDCLIB_glue.h> -char * fgets( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) +char * fgets_unlocked( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) { if ( size == 0 ) { @@ -46,6 +46,15 @@ char * fgets( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_t * _PDCL return ( dest == s ) ? NULL : s; } +char * fgets( char * _PDCLIB_restrict s, int size, + struct _PDCLIB_file_t * _PDCLIB_restrict stream ) +{ + flockfile( stream ); + char* r = fgets_unlocked( s, size, stream ); + funlockfile( stream ); + return r; +} + #endif #ifdef TEST