Commit 6f24dd96 authored by Iván Matellanes's avatar Iván Matellanes Committed by Alexandre Julliard

msvcrt: Added _ungetc_nolock implementation.

parent b536ff62
...@@ -1405,7 +1405,7 @@ ...@@ -1405,7 +1405,7 @@
@ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s @ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s
@ cdecl _umask(long) MSVCRT__umask @ cdecl _umask(long) MSVCRT__umask
@ stub _umask_s @ stub _umask_s
@ stub _ungetc_nolock @ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long) @ cdecl _ungetch(long)
@ stub _ungetch_nolock @ stub _ungetch_nolock
@ stub _ungetwc_nolock @ stub _ungetwc_nolock
......
...@@ -1763,7 +1763,7 @@ ...@@ -1763,7 +1763,7 @@
@ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s @ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s
@ cdecl _umask(long) MSVCRT__umask @ cdecl _umask(long) MSVCRT__umask
@ stub _umask_s @ stub _umask_s
@ stub _ungetc_nolock @ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long) @ cdecl _ungetch(long)
@ stub _ungetch_nolock @ stub _ungetch_nolock
@ stub _ungetwc_nolock @ stub _ungetwc_nolock
......
...@@ -1777,7 +1777,7 @@ ...@@ -1777,7 +1777,7 @@
@ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s @ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s
@ cdecl _umask(long) MSVCRT__umask @ cdecl _umask(long) MSVCRT__umask
@ stub _umask_s @ stub _umask_s
@ stub _ungetc_nolock @ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long) @ cdecl _ungetch(long)
@ stub _ungetch_nolock @ stub _ungetch_nolock
@ stub _ungetwc_nolock @ stub _ungetwc_nolock
......
...@@ -1084,7 +1084,7 @@ ...@@ -1084,7 +1084,7 @@
@ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s @ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s
@ cdecl _umask(long) MSVCRT__umask @ cdecl _umask(long) MSVCRT__umask
@ stub _umask_s @ stub _umask_s
@ stub _ungetc_nolock @ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long) @ cdecl _ungetch(long)
@ stub _ungetch_nolock @ stub _ungetch_nolock
@ stub _ungetwc_nolock @ stub _ungetwc_nolock
......
...@@ -1060,7 +1060,7 @@ ...@@ -1060,7 +1060,7 @@
@ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s @ cdecl _ultow_s(long ptr long long) MSVCRT__ultow_s
@ cdecl _umask(long) MSVCRT__umask @ cdecl _umask(long) MSVCRT__umask
@ stub _umask_s @ stub _umask_s
@ stub _ungetc_nolock @ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long) @ cdecl _ungetch(long)
@ stub _ungetch_nolock @ stub _ungetch_nolock
@ stub _ungetwc_nolock @ stub _ungetwc_nolock
......
...@@ -5002,13 +5002,28 @@ int CDECL MSVCRT_printf_s(const char *format, ...) ...@@ -5002,13 +5002,28 @@ int CDECL MSVCRT_printf_s(const char *format, ...)
*/ */
int CDECL MSVCRT_ungetc(int c, MSVCRT_FILE * file) 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; if(!MSVCRT_CHECK_PMT(file != NULL)) return MSVCRT_EOF;
if (c == MSVCRT_EOF || !(file->_flag&MSVCRT__IOREAD || if (c == MSVCRT_EOF || !(file->_flag&MSVCRT__IOREAD ||
(file->_flag&MSVCRT__IORW && !(file->_flag&MSVCRT__IOWRT)))) (file->_flag&MSVCRT__IORW && !(file->_flag&MSVCRT__IOWRT))))
return MSVCRT_EOF; return MSVCRT_EOF;
MSVCRT__lock_file(file);
if((!(file->_flag & (MSVCRT__IONBF | MSVCRT__IOMYBUF | MSVCRT__USERBUF)) if((!(file->_flag & (MSVCRT__IONBF | MSVCRT__IOMYBUF | MSVCRT__USERBUF))
&& msvcrt_alloc_buffer(file)) && msvcrt_alloc_buffer(file))
|| (!file->_cnt && file->_ptr==file->_base)) || (!file->_cnt && file->_ptr==file->_base))
...@@ -5019,20 +5034,17 @@ int CDECL MSVCRT_ungetc(int c, MSVCRT_FILE * file) ...@@ -5019,20 +5034,17 @@ int CDECL MSVCRT_ungetc(int c, MSVCRT_FILE * file)
if(file->_flag & MSVCRT__IOSTRG) { if(file->_flag & MSVCRT__IOSTRG) {
if(*file->_ptr != c) { if(*file->_ptr != c) {
file->_ptr++; file->_ptr++;
MSVCRT__unlock_file(file);
return MSVCRT_EOF; return MSVCRT_EOF;
} }
}else { }else {
*file->_ptr = c; *file->_ptr = c;
} }
file->_cnt++; file->_cnt++;
MSVCRT_clearerr(file); file->_flag &= ~(MSVCRT__IOERR | MSVCRT__IOEOF);
file->_flag |= MSVCRT__IOREAD; file->_flag |= MSVCRT__IOREAD;
MSVCRT__unlock_file(file);
return c; return c;
} }
MSVCRT__unlock_file(file);
return MSVCRT_EOF; return MSVCRT_EOF;
} }
......
...@@ -919,6 +919,7 @@ int __cdecl MSVCRT_fgetc(MSVCRT_FILE*); ...@@ -919,6 +919,7 @@ int __cdecl MSVCRT_fgetc(MSVCRT_FILE*);
int __cdecl MSVCRT__fgetc_nolock(MSVCRT_FILE*); int __cdecl MSVCRT__fgetc_nolock(MSVCRT_FILE*);
int __cdecl MSVCRT__fputc_nolock(int,MSVCRT_FILE*); int __cdecl MSVCRT__fputc_nolock(int,MSVCRT_FILE*);
int __cdecl MSVCRT_ungetc(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(MSVCRT_FILE*);
MSVCRT_wint_t __cdecl MSVCRT__fgetwc_nolock(MSVCRT_FILE*); MSVCRT_wint_t __cdecl MSVCRT__fgetwc_nolock(MSVCRT_FILE*);
MSVCRT_wint_t __cdecl MSVCRT__fputwc_nolock(MSVCRT_wint_t,MSVCRT_FILE*); MSVCRT_wint_t __cdecl MSVCRT__fputwc_nolock(MSVCRT_wint_t,MSVCRT_FILE*);
......
...@@ -137,6 +137,7 @@ int __cdecl _fseek_nolock(FILE*,__msvcrt_long,int); ...@@ -137,6 +137,7 @@ int __cdecl _fseek_nolock(FILE*,__msvcrt_long,int);
int __cdecl _fseeki64_nolock(FILE*,__int64,int); int __cdecl _fseeki64_nolock(FILE*,__int64,int);
__msvcrt_long __cdecl _ftell_nolock(FILE*); __msvcrt_long __cdecl _ftell_nolock(FILE*);
__int64 __cdecl _ftelli64_nolock(FILE*); __int64 __cdecl _ftelli64_nolock(FILE*);
int __cdecl _ungetc_nolock(int,FILE*);
void __cdecl clearerr(FILE*); void __cdecl clearerr(FILE*);
int __cdecl fclose(FILE*); int __cdecl fclose(FILE*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment