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