X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fungetc.c;h=45b8a92a73e9fc004146ad9d46aae51bd0e9d013;hb=84d648157e22cecc65902ecfdd4e3a1b88d5e53f;hp=001735b533c04361648b2c3eb5475cdced99faac;hpb=fce9a8538009ea5c113b03c608cedf036ce4a364;p=pdclib.old diff --git a/functions/stdio/ungetc.c b/functions/stdio/ungetc.c index 001735b..45b8a92 100644 --- a/functions/stdio/ungetc.c +++ b/functions/stdio/ungetc.c @@ -10,7 +10,7 @@ #ifndef REGTEST -int ungetc( int c, struct _PDCLIB_file_t * stream ) +int ungetc_unlocked( int c, struct _PDCLIB_file_t * stream ) { if ( c == EOF || stream->ungetidx == _PDCLIB_UNGETCBUFSIZE ) { @@ -19,6 +19,14 @@ int ungetc( int c, struct _PDCLIB_file_t * stream ) return stream->ungetbuf[stream->ungetidx++] = (unsigned char) c; } +int ungetc( int c, struct _PDCLIB_file_t * stream ) +{ + flockfile( stream ); + int r = ungetc_unlocked( c, stream ); + funlockfile( stream); + return r; +} + #endif #ifdef TEST