msvcrt: Added _ungetwc_nolock implementation.

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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -5053,12 +5053,27 @@ int CDECL MSVCRT__ungetc_nolock(int c, MSVCRT_FILE * file)
*/
MSVCRT_wint_t CDECL MSVCRT_ungetwc(MSVCRT_wint_t wc, MSVCRT_FILE * file)
{
MSVCRT_wchar_t mwc = wc;
MSVCRT_wint_t ret;
if (wc == MSVCRT_WEOF)
return MSVCRT_WEOF;
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;
if((msvcrt_get_ioinfo(file->_file)->exflag & (EF_UTF8 | EF_UTF16))
|| !(msvcrt_get_ioinfo(file->_file)->wxflag & WX_TEXT)) {
@ -5066,30 +5081,23 @@ MSVCRT_wint_t CDECL MSVCRT_ungetwc(MSVCRT_wint_t wc, MSVCRT_FILE * file)
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;
}

View File

@ -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*);

View 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);