Commit 4f807d9a authored by Iván Matellanes's avatar Iván Matellanes Committed by Alexandre Julliard

msvcrt: Added _ungetwc_nolock implementation.

parent 6f24dd96
......@@ -1408,7 +1408,7 @@
@ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long)
@ stub _ungetch_nolock
@ stub _ungetwc_nolock
@ cdecl _ungetwc_nolock(long ptr) MSVCRT__ungetwc_nolock
@ stub _ungetwch
@ stub _ungetwch_nolock
@ cdecl _unlink(str) MSVCRT__unlink
......
......@@ -1766,7 +1766,7 @@
@ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long)
@ stub _ungetch_nolock
@ stub _ungetwc_nolock
@ cdecl _ungetwc_nolock(long ptr) MSVCRT__ungetwc_nolock
@ stub _ungetwch
@ stub _ungetwch_nolock
@ cdecl _unlink(str) MSVCRT__unlink
......
......@@ -1780,7 +1780,7 @@
@ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long)
@ stub _ungetch_nolock
@ stub _ungetwc_nolock
@ cdecl _ungetwc_nolock(long ptr) MSVCRT__ungetwc_nolock
@ stub _ungetwch
@ stub _ungetwch_nolock
@ cdecl _unlink(str) MSVCRT__unlink
......
......@@ -1087,7 +1087,7 @@
@ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long)
@ stub _ungetch_nolock
@ stub _ungetwc_nolock
@ cdecl _ungetwc_nolock(long ptr) MSVCRT__ungetwc_nolock
@ stub _ungetwch
@ stub _ungetwch_nolock
@ cdecl _unlink(str) MSVCRT__unlink
......
......@@ -1063,7 +1063,7 @@
@ cdecl _ungetc_nolock(long ptr) MSVCRT__ungetc_nolock
@ cdecl _ungetch(long)
@ stub _ungetch_nolock
@ stub _ungetwc_nolock
@ cdecl _ungetwc_nolock(long ptr) MSVCRT__ungetwc_nolock
@ stub _ungetwch
@ stub _ungetwch_nolock
@ cdecl _unlink(str) MSVCRT__unlink
......
......@@ -5053,43 +5053,51 @@ int CDECL MSVCRT__ungetc_nolock(int c, MSVCRT_FILE * file)
*/
MSVCRT_wint_t CDECL MSVCRT_ungetwc(MSVCRT_wint_t wc, MSVCRT_FILE * file)
{
MSVCRT_wint_t ret;
if(!MSVCRT_CHECK_PMT(file != NULL)) return MSVCRT_WEOF;
MSVCRT__lock_file(file);
ret = MSVCRT__ungetwc_nolock(wc, file);
MSVCRT__unlock_file(file);
return ret;
}
/*********************************************************************
* _ungetwc_nolock (MSVCRT.@)
*/
MSVCRT_wint_t CDECL MSVCRT__ungetwc_nolock(MSVCRT_wint_t wc, MSVCRT_FILE * file)
{
MSVCRT_wchar_t mwc = wc;
if(!MSVCRT_CHECK_PMT(file != NULL)) return MSVCRT_WEOF;
if (wc == MSVCRT_WEOF)
return MSVCRT_WEOF;
MSVCRT__lock_file(file);
if((msvcrt_get_ioinfo(file->_file)->exflag & (EF_UTF8 | EF_UTF16))
|| !(msvcrt_get_ioinfo(file->_file)->wxflag & WX_TEXT)) {
unsigned char * pp = (unsigned char *)&mwc;
int i;
for(i=sizeof(MSVCRT_wchar_t)-1;i>=0;i--) {
if(pp[i] != MSVCRT_ungetc(pp[i],file)) {
MSVCRT__unlock_file(file);
if(pp[i] != MSVCRT__ungetc_nolock(pp[i],file))
return MSVCRT_WEOF;
}
}
}else {
char mbs[MSVCRT_MB_LEN_MAX];
int len;
len = MSVCRT_wctomb(mbs, mwc);
if(len == -1) {
MSVCRT__unlock_file(file);
if(len == -1)
return MSVCRT_WEOF;
}
for(len--; len>=0; len--) {
if(mbs[len] != MSVCRT_ungetc(mbs[len], file)) {
MSVCRT__unlock_file(file);
if(mbs[len] != MSVCRT__ungetc_nolock(mbs[len], file))
return MSVCRT_WEOF;
}
}
}
MSVCRT__unlock_file(file);
return mwc;
}
......
......@@ -924,6 +924,7 @@ 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*);
MSVCRT_wint_t __cdecl MSVCRT_ungetwc(MSVCRT_wint_t,MSVCRT_FILE*);
MSVCRT_wint_t __cdecl MSVCRT__ungetwc_nolock(MSVCRT_wint_t, MSVCRT_FILE*);
int __cdecl MSVCRT__fseeki64_nolock(MSVCRT_FILE*,__int64,int);
__int64 __cdecl MSVCRT__ftelli64(MSVCRT_FILE* file);
__int64 __cdecl MSVCRT__ftelli64_nolock(MSVCRT_FILE*);
......
......@@ -207,6 +207,7 @@ int __cdecl _putws(const wchar_t*);
int __cdecl _snwprintf(wchar_t*,size_t,const wchar_t*,...);
int __cdecl _snwprintf_s(wchar_t*,size_t,size_t,const wchar_t*,...);
int __cdecl _scwprintf(const wchar_t*,...);
wint_t __cdecl _ungetwc_nolock(wint_t,FILE*);
int __cdecl _vscwprintf(const wchar_t*,__ms_va_list);
int __cdecl _vscwprintf_p_l(const wchar_t*,_locale_t,__ms_va_list);
int __cdecl _vsnwprintf(wchar_t*,size_t,const wchar_t*,__ms_va_list);
......
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