msvcrt: Added _ungetc_nolock implementation.

This commit is contained in:
Iván Matellanes 2014-11-04 22:52:03 +01:00 committed by Alexandre Julliard
parent b536ff62ef
commit 6f24dd9677
8 changed files with 24 additions and 10 deletions

View File

@ -1405,7 +1405,7 @@
@ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s
@ cdecl _umask(long) MSVCRT__umask
@ stub _umask_s
@ stub _ungetc_nolock
@ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long)
@ stub _ungetch_nolock
@ stub _ungetwc_nolock

View File

@ -1763,7 +1763,7 @@
@ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s
@ cdecl _umask(long) MSVCRT__umask
@ stub _umask_s
@ stub _ungetc_nolock
@ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long)
@ stub _ungetch_nolock
@ stub _ungetwc_nolock

View File

@ -1777,7 +1777,7 @@
@ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s
@ cdecl _umask(long) MSVCRT__umask
@ stub _umask_s
@ stub _ungetc_nolock
@ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long)
@ stub _ungetch_nolock
@ stub _ungetwc_nolock

View File

@ -1084,7 +1084,7 @@
@ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s
@ cdecl _umask(long) MSVCRT__umask
@ stub _umask_s
@ stub _ungetc_nolock
@ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long)
@ stub _ungetch_nolock
@ stub _ungetwc_nolock

View File

@ -1060,7 +1060,7 @@
@ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s
@ cdecl _umask(long) MSVCRT__umask
@ stub _umask_s
@ stub _ungetc_nolock
@ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long)
@ stub _ungetch_nolock
@ stub _ungetwc_nolock

View File

@ -5001,6 +5001,22 @@ int CDECL MSVCRT_printf_s(const char *format, ...)
* ungetc (MSVCRT.@)
*/
int CDECL MSVCRT_ungetc(int c, MSVCRT_FILE * file)
{
int ret;
if(!MSVCRT_CHECK_PMT(file != NULL)) return MSVCRT_EOF;
MSVCRT__lock_file(file);
ret = MSVCRT__ungetc_nolock(c, file);
MSVCRT__unlock_file(file);
return ret;
}
/*********************************************************************
* _ungetc_nolock (MSVCRT.@)
*/
int CDECL MSVCRT__ungetc_nolock(int c, MSVCRT_FILE * file)
{
if(!MSVCRT_CHECK_PMT(file != NULL)) return MSVCRT_EOF;
@ -5008,7 +5024,6 @@ int CDECL MSVCRT_ungetc(int c, MSVCRT_FILE * file)
(file->_flag&MSVCRT__IORW && !(file->_flag&MSVCRT__IOWRT))))
return MSVCRT_EOF;
MSVCRT__lock_file(file);
if((!(file->_flag & (MSVCRT__IONBF | MSVCRT__IOMYBUF | MSVCRT__USERBUF))
&& msvcrt_alloc_buffer(file))
|| (!file->_cnt && file->_ptr==file->_base))
@ -5019,20 +5034,17 @@ int CDECL MSVCRT_ungetc(int c, MSVCRT_FILE * file)
if(file->_flag & MSVCRT__IOSTRG) {
if(*file->_ptr != c) {
file->_ptr++;
MSVCRT__unlock_file(file);
return MSVCRT_EOF;
}
}else {
*file->_ptr = c;
}
file->_cnt++;
MSVCRT_clearerr(file);
file->_flag &= ~(MSVCRT__IOERR | MSVCRT__IOEOF);
file->_flag |= MSVCRT__IOREAD;
MSVCRT__unlock_file(file);
return c;
}
MSVCRT__unlock_file(file);
return MSVCRT_EOF;
}

View File

@ -919,6 +919,7 @@ int __cdecl MSVCRT_fgetc(MSVCRT_FILE*);
int __cdecl MSVCRT__fgetc_nolock(MSVCRT_FILE*);
int __cdecl MSVCRT__fputc_nolock(int,MSVCRT_FILE*);
int __cdecl MSVCRT_ungetc(int,MSVCRT_FILE*);
int __cdecl MSVCRT__ungetc_nolock(int,MSVCRT_FILE*);
MSVCRT_wint_t __cdecl MSVCRT_fgetwc(MSVCRT_FILE*);
MSVCRT_wint_t __cdecl MSVCRT__fgetwc_nolock(MSVCRT_FILE*);
MSVCRT_wint_t __cdecl MSVCRT__fputwc_nolock(MSVCRT_wint_t,MSVCRT_FILE*);

View File

@ -137,6 +137,7 @@ int __cdecl _fseek_nolock(FILE*,__msvcrt_long,int);
int __cdecl _fseeki64_nolock(FILE*,__int64,int);
__msvcrt_long __cdecl _ftell_nolock(FILE*);
__int64 __cdecl _ftelli64_nolock(FILE*);
int __cdecl _ungetc_nolock(int,FILE*);
void __cdecl clearerr(FILE*);
int __cdecl fclose(FILE*);