Module: wine Branch: refs/heads/master Commit: b44ea8084d8b507ec1630d47fdcbf2f75225174a URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=b44ea8084d8b507ec1630d47...
Author: Duane Clark fpga@pacbell.net Date: Sat Jul 29 15:35:02 2006 -0700
msvcrt: Fix fread.
---
dlls/msvcrt/file.c | 12 +++++++++--- dlls/msvcrt/tests/file.c | 10 ++-------- 2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 0e677c7..a1bc07a 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -2490,6 +2490,8 @@ MSVCRT_size_t CDECL MSVCRT_fread(void *p memcpy(ptr, file->_ptr, pcnt); file->_cnt -= pcnt; file->_ptr += pcnt; + if (MSVCRT_fdesc[file->_file].wxflag & WX_TEXT) + pcnt -= remove_cr(ptr,pcnt); read += pcnt ; rcnt -= pcnt ; ptr = (char*)ptr + pcnt; @@ -2499,18 +2501,22 @@ MSVCRT_size_t CDECL MSVCRT_fread(void *p } else return 0; } - if(rcnt) + while(rcnt>0) { - pread = _read(file->_file,ptr, rcnt); + int i = _read(file->_file,ptr, rcnt); + if (i==0) break; + pread += i; + rcnt -= i; /* expose feof condition in the flags * MFC tests file->_flag for feof, and doesn't not call feof()) */ if ( MSVCRT_fdesc[file->_file].wxflag & WX_ATEOF) file->_flag |= MSVCRT__IOEOF; - else if (pread == -1) + else if (i == -1) { file->_flag |= MSVCRT__IOERR; pread = 0; + rcnt = 0; } } read+=pread; diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 5eaf3eb..e3f8ce5 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -210,10 +210,7 @@ static void test_readmode( BOOL ascii_mo ok(fgets(buffer,MSVCRT_BUFSIZ-6,file) !=0,"padding line fgets failed unexpected in %s\n", IOMODE); j=strlen(outbuffer); i=fread(buffer,1,256,file); - if (ao == -1) - todo_wine todo_wine ok(i==j+6+ao*4,"fread failed, expected %d got %d in %s\n", j+6+ao*4, i, IOMODE); - else - ok(i==j+6+ao*4,"fread failed, expected %d got %d in %s\n", j+6+ao*4, i, IOMODE); + ok(i==j+6+ao*4,"fread failed, expected %d got %d in %s\n", j+6+ao*4, i, IOMODE); l = ftell(file); ok(l == pl+j+1,"ftell after fread got %ld should be %d in %s\n", l, pl+j+1, IOMODE); /* fread should return the requested number of bytes if available */ @@ -222,10 +219,7 @@ static void test_readmode( BOOL ascii_mo ok(fgets(buffer,MSVCRT_BUFSIZ-6,file) !=0,"padding line fgets failed unexpected in %s\n", IOMODE); j = fp+10; i=fread(buffer,1,j,file); - if (ao == -1) - todo_wine ok(i==j,"fread failed, expected %d got %d in %s\n", j, i, IOMODE); - else - ok(i==j,"fread failed, expected %d got %d in %s\n", j, i, IOMODE); + ok(i==j,"fread failed, expected %d got %d in %s\n", j, i, IOMODE);
/* test some additional functions */ rewind(file);