mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix ungetc EOF having side effects.
This commit is contained in:
parent
0a63d26bf7
commit
38f8384d78
1 changed files with 3 additions and 6 deletions
|
@ -29,6 +29,9 @@
|
|||
|
||||
extern "C" int ungetc_unlocked(int c, FILE* fp)
|
||||
{
|
||||
if ( c == EOF )
|
||||
return EOF;
|
||||
|
||||
if ( !(fp->flags & _FILE_READABLE) )
|
||||
return errno = EBADF, fp->flags |= _FILE_STATUS_ERROR, EOF;
|
||||
|
||||
|
@ -41,12 +44,6 @@ extern "C" int ungetc_unlocked(int c, FILE* fp)
|
|||
|
||||
fp->flags |= _FILE_LAST_READ;
|
||||
|
||||
if ( c == EOF )
|
||||
{
|
||||
fp->flags &= ~_FILE_STATUS_EOF;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
// TODO: Is this a bug that ungetc doesn't work for unbuffered files?
|
||||
if ( fp->buffer_mode == _IONBF )
|
||||
return errno = EBADF, fp->flags |= _FILE_STATUS_ERROR, EOF;
|
||||
|
|
Loading…
Reference in a new issue