mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-14 17:16:18 +00:00
msvcrt: Fix fgetwc/s in binary mode.
This commit is contained in:
parent
d74b6055fe
commit
bc194793a7
|
@ -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<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))
|
||||
{
|
||||
|
|
|
@ -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<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 @@ static void test_fgetwc( void )
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue