Author: greatlrd Date: Thu Jun 1 13:26:32 2006 New Revision: 22143
URL: http://svn.reactos.ru/svn/reactos?rev=22143&view=rev Log: small rewrite by me, pass wine test and no bugs in ungetc accroing wine test of msvcrt.
Modified: trunk/reactos/lib/crt/stdio/ungetc.c
Modified: trunk/reactos/lib/crt/stdio/ungetc.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/crt/stdio/ungetc.c?rev=2... ============================================================================== --- trunk/reactos/lib/crt/stdio/ungetc.c (original) +++ trunk/reactos/lib/crt/stdio/ungetc.c Thu Jun 1 13:26:32 2006 @@ -18,33 +18,20 @@
if (c == _TEOF) return _TEOF; - - if (f->_ptr == NULL || f->_base == NULL) - return _TEOF; - + if (f->_ptr == f->_base) - { + { if (f->_cnt == 0) f->_ptr+=sizeof(_TCHAR); else return _TEOF; - } - - f->_cnt+=sizeof(_TCHAR); - f->_ptr-=sizeof(_TCHAR); - -#if 1 - if (*((_TCHAR*)(f->_ptr)) != c) - { - f->_flag |= _IOUNGETC; - *((_TCHAR*)(f->_ptr)) = c; - } -#else - /* This is the old unicode version. Dunno what version is most correct. -Gunnar */ - f->_flag |= _IOUNGETC; - *((_TCHAR*)(f->_ptr)) = c; -#endif - - return c; + } + + fseek(f, -1, SEEK_CUR); + + if(*(_TCHAR*)f->_ptr != c) + *((_TCHAR*)(f->_ptr)) = c; + + return c; }