From: "Iván Matellanes" Subject: [3/4] msvcrt: Added _fgetwc_nolock implementation Message-Id: <544A434D.6070609@gmail.com> Date: Fri, 24 Oct 2014 14:17:17 +0200 --- dlls/msvcr100/msvcr100.spec | 2 +- dlls/msvcr110/msvcr110.spec | 2 +- dlls/msvcr80/msvcr80.spec | 2 +- dlls/msvcr90/msvcr90.spec | 2 +- dlls/msvcrt/file.c | 21 ++++++++++++++++----- dlls/msvcrt/msvcrt.h | 1 + include/msvcrt/stdio.h | 1 + 7 files changed, 22 insertions(+), 9 deletions(-) diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 0f4e275..0953af6 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -802,7 +802,7 @@ @ stub _fflush_nolock @ cdecl _fgetc_nolock(ptr) MSVCRT__fgetc_nolock @ cdecl _fgetchar() MSVCRT__fgetchar -@ stub _fgetwc_nolock +@ cdecl _fgetwc_nolock(ptr) MSVCRT__fgetwc_nolock @ cdecl _fgetwchar() MSVCRT__fgetwchar @ cdecl _filbuf(ptr) MSVCRT__filbuf @ cdecl _filelength(long) MSVCRT__filelength diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec index 60f84a7..6ffbdb9 100644 --- a/dlls/msvcr110/msvcr110.spec +++ b/dlls/msvcr110/msvcr110.spec @@ -1150,7 +1150,7 @@ @ stub _fflush_nolock @ cdecl _fgetc_nolock(ptr) MSVCRT__fgetc_nolock @ cdecl _fgetchar() MSVCRT__fgetchar -@ stub _fgetwc_nolock +@ cdecl _fgetwc_nolock(ptr) MSVCRT__fgetwc_nolock @ cdecl _fgetwchar() MSVCRT__fgetwchar @ cdecl _filbuf(ptr) MSVCRT__filbuf @ cdecl _filelength(long) MSVCRT__filelength diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index 61324d6..2c6e293 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -469,7 +469,7 @@ @ stub _fflush_nolock @ cdecl _fgetc_nolock(ptr) MSVCRT__fgetc_nolock @ cdecl _fgetchar() MSVCRT__fgetchar -@ stub _fgetwc_nolock +@ cdecl _fgetwc_nolock(ptr) MSVCRT__fgetwc_nolock @ cdecl _fgetwchar() MSVCRT__fgetwchar @ cdecl _filbuf(ptr) MSVCRT__filbuf @ cdecl _filelength(long) MSVCRT__filelength diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index d7dceaf..7cf20c6 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -451,7 +451,7 @@ @ stub _fflush_nolock @ cdecl _fgetc_nolock(ptr) MSVCRT__fgetc_nolock @ cdecl _fgetchar() MSVCRT__fgetchar -@ stub _fgetwc_nolock +@ cdecl _fgetwc_nolock(ptr) MSVCRT__fgetwc_nolock @ cdecl _fgetwchar() MSVCRT__fgetwchar @ cdecl _filbuf(ptr) MSVCRT__filbuf @ cdecl _filelength(long) MSVCRT__filelength diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 03871e1..0e72099 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -3562,16 +3562,28 @@ char * CDECL MSVCRT_fgets(char *s, int size, MSVCRT_FILE* file) MSVCRT_wint_t CDECL MSVCRT_fgetwc(MSVCRT_FILE* file) { MSVCRT_wint_t ret; - int ch; MSVCRT__lock_file(file); + ret = MSVCRT__fgetwc_nolock(file); + MSVCRT__unlock_file(file); + + return ret; +} + +/********************************************************************* + * _fgetwc_nolock (MSVCRT.@) + */ +MSVCRT_wint_t CDECL MSVCRT__fgetwc_nolock(MSVCRT_FILE* file) +{ + MSVCRT_wint_t ret; + int ch; if((msvcrt_get_ioinfo(file->_file)->exflag & (EF_UTF8 | EF_UTF16)) || !(msvcrt_get_ioinfo(file->_file)->wxflag & WX_TEXT)) { char *p; for(p=(char*)&ret; (MSVCRT_wint_t*)p<&ret+1; p++) { - ch = MSVCRT_fgetc(file); + ch = MSVCRT__fgetc_nolock(file); if(ch == MSVCRT_EOF) { ret = MSVCRT_WEOF; break; @@ -3582,11 +3594,11 @@ MSVCRT_wint_t CDECL MSVCRT_fgetwc(MSVCRT_FILE* file) char mbs[MSVCRT_MB_LEN_MAX]; int len = 0; - ch = MSVCRT_fgetc(file); + ch = MSVCRT__fgetc_nolock(file); if(ch != MSVCRT_EOF) { mbs[0] = (char)ch; if(MSVCRT_isleadbyte((unsigned char)mbs[0])) { - ch = MSVCRT_fgetc(file); + ch = MSVCRT__fgetc_nolock(file); if(ch != MSVCRT_EOF) { mbs[1] = (char)ch; len = 2; @@ -3600,7 +3612,6 @@ MSVCRT_wint_t CDECL MSVCRT_fgetwc(MSVCRT_FILE* file) ret = MSVCRT_WEOF; } - MSVCRT__unlock_file(file); return ret; } diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index ac26d46..43d5bc2 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -919,6 +919,7 @@ int __cdecl MSVCRT_fgetc(MSVCRT_FILE*); int __cdecl MSVCRT__fgetc_nolock(MSVCRT_FILE*); int __cdecl MSVCRT_ungetc(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_ungetwc(MSVCRT_wint_t,MSVCRT_FILE*); int __cdecl MSVCRT__fseeki64_nolock(MSVCRT_FILE*,__int64,int); __int64 __cdecl MSVCRT__ftelli64(MSVCRT_FILE* file); diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h index af56f20..5c5d512 100644 --- a/include/msvcrt/stdio.h +++ b/include/msvcrt/stdio.h @@ -195,6 +195,7 @@ unsigned int __cdecl _set_output_format(void); #ifndef _WSTDIO_DEFINED #define _WSTDIO_DEFINED +wint_t __cdecl _fgetwc_nolock(FILE*); wint_t __cdecl _fgetwchar(void); wint_t __cdecl _fputwchar(wint_t); wchar_t* __cdecl _getws(wchar_t*); -- 1.9.1