X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Fungetc.c;h=45b8a92a73e9fc004146ad9d46aae51bd0e9d013;hb=6ca24b75c75b9c6f22e1e69693d326b8e3330841;hp=001735b533c04361648b2c3eb5475cdced99faac;hpb=6cb7e8dab67e8807aad79c3bdc8f96d78a5e5dbc;p=pdclib 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