Duane Clark : msvcrt: Fix fgetwc/s in binary mode.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Jul 31 15:01:27 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: bc194793a701b219516329bc4b3232dbc79e9d4a
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=bc194793a701b219516329bc4b3232dbc79e9d4a
Author: Duane Clark <fpga at pacbell.net>
Date: Mon Jul 31 12:15:37 2006 -0700
msvcrt: Fix fgetwc/s in binary mode.
---
dlls/msvcrt/file.c | 26 ++++++++++++++++++++++----
dlls/msvcrt/tests/file.c | 20 ++++++++++----------
2 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 266adb2..3b3a6de 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -2179,14 +2179,32 @@ MSVCRT_wint_t CDECL MSVCRT_fgetwc(MSVCRT
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<sizeof(wc); i++)
{
- file->_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 284e3ba..0205de4 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -329,28 +329,28 @@ #define LLEN 512
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<strlen(mytext); i++)
wtextW[i] = 0;
/* the first time we get the string, it should be entirely within the local buffer */
fgetws(wtextW,LLEN,tempfh);
l=ftell(tempfh);
j += (strlen(mytext)-1)*sizeof(WCHAR);
- todo_wine ok(l==j, "ftell expected %d got %ld\n", j, l);
+ ok(l==j, "ftell expected %d got %ld\n", j, l);
diff_found = FALSE;
aptr = mytextW;
wptr = wtextW;
for (i=0; i<strlen(mytext)-2; i++, aptr++, wptr++)
{
- todo_wine ok(*aptr == *wptr, "Char %d expected %04hx got %04hx\n", i, *aptr, *wptr);
+ ok(*aptr == *wptr, "Char %d expected %04hx got %04hx\n", i, *aptr, *wptr);
diff_found |= (*aptr != *wptr);
}
- todo_wine ok(!(diff_found), "fgetwc difference found in BINARY mode\n");
- todo_wine ok(*wptr == '\n', "Should get newline\n");
+ ok(!(diff_found), "fgetwc difference found in BINARY mode\n");
+ ok(*wptr == '\n', "Should get newline\n");
for(i=0; i<strlen(mytext); i++)
wtextW[i] = 0;
/* the second time we get the string, it should cross the local buffer boundary.
@@ -361,11 +361,11 @@ #define LLEN 512
wptr = wtextW;
for (i=0; i<strlen(mytext)-2; i++, aptr++, wptr++)
{
- todo_wine ok(*aptr == *wptr, "Char %d expected %04hx got %04hx\n", i, *aptr, *wptr);
+ ok(*aptr == *wptr, "Char %d expected %04hx got %04hx\n", i, *aptr, *wptr);
diff_found |= (*aptr != *wptr);
}
- todo_wine ok(!(diff_found), "fgetwc difference found in BINARY mode\n");
- todo_wine ok(*wptr == '\n', "Should get newline\n");
+ ok(!(diff_found), "fgetwc difference found in BINARY mode\n");
+ ok(*wptr == '\n', "Should get newline\n");
if(mytextW) free (mytextW);
fclose(tempfh);
More information about the wine-cvs
mailing list