From 74d68f462410e2f0fea80ed0ebf32a1e2e4e6f29 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Wed, 14 May 2014 14:55:37 +0000 Subject: [PATCH] [CRT] * Update ungetc(). CORE-8080 svn path=/trunk/; revision=63293 --- reactos/lib/sdk/crt/stdio/file.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/reactos/lib/sdk/crt/stdio/file.c b/reactos/lib/sdk/crt/stdio/file.c index ec22bfe570b..ae6164e94f0 100644 --- a/reactos/lib/sdk/crt/stdio/file.c +++ b/reactos/lib/sdk/crt/stdio/file.c @@ -3880,13 +3880,19 @@ int CDECL ungetc(int c, FILE * file) return EOF; _lock_file(file); - if(file->_bufsiz == 0) { - alloc_buffer(file); + if(file->_bufsiz == 0 && alloc_buffer(file)) file->_ptr++; - } if(file->_ptr>file->_base) { file->_ptr--; - *file->_ptr=c; + if(file->_flag & _IOSTRG) { + if(*file->_ptr != c) { + file->_ptr++; + _unlock_file(file); + return EOF; + } + }else { + *file->_ptr = c; + } file->_cnt++; clearerr(file); _unlock_file(file);