diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 266adb2be09..3b3a6de41fe 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -2179,14 +2179,32 @@ MSVCRT_wint_t CDECL MSVCRT_fgetwc(MSVCRT_FILE* file) if (!(MSVCRT_fdesc[file->_file].wxflag & WX_TEXT)) { MSVCRT_wchar_t wc; - int r; - if ((r = _read(file->_file, &wc, sizeof(wc))) != sizeof(wc)) + int i,j; + char *chp, *wcp; + wcp = (char *)&wc; + for(i=0; i_flag |= (r == 0) ? MSVCRT__IOEOF : MSVCRT__IOERR; - return MSVCRT_WEOF; + if (file->_cnt>0) + { + file->_cnt--; + chp = file->_ptr++; + wcp[i] = *chp; + } + else + { + j = MSVCRT__filbuf(file); + if(file->_cnt<=0) + { + file->_flag |= (file->_cnt == 0) ? MSVCRT__IOEOF : MSVCRT__IOERR; + file->_cnt = 0; + return MSVCRT_WEOF; + } + wcp[i] = j; + } } return wc; } + c = MSVCRT_fgetc(file); if ((*__p___mb_cur_max() > 1) && MSVCRT_isleadbyte(c)) { diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 284e3ba4a68..0205de47f8b 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -329,28 +329,28 @@ static void test_fgetwc( void ) j++; ok(l==j, "ftell expected %d got %ld\n", j, l); fgetws(wtextW,3,tempfh); - todo_wine ok(wtextW[0]=='\r',"expected carriage return got %04hx\n", wtextW[0]); - todo_wine ok(wtextW[1]=='\n',"expected newline got %04hx\n", wtextW[1]); + ok(wtextW[0]=='\r',"expected carriage return got %04hx\n", wtextW[0]); + ok(wtextW[1]=='\n',"expected newline got %04hx\n", wtextW[1]); l=ftell(tempfh); j += 4; - todo_wine ok(l==j, "ftell expected %d got %ld\n", j, l); + ok(l==j, "ftell expected %d got %ld\n", j, l); for(i=0; i