Commit 9a71b483 authored by Duane Clark's avatar Duane Clark Committed by Alexandre Julliard

msvcrt: fgetc needs to use unsigned parameters.

Spotted by and adapted from test written by Tobias Ringström.
parent 7a61a617
...@@ -2127,12 +2127,12 @@ int CDECL MSVCRT__filbuf(MSVCRT_FILE* file) ...@@ -2127,12 +2127,12 @@ int CDECL MSVCRT__filbuf(MSVCRT_FILE* file)
*/ */
int CDECL MSVCRT_fgetc(MSVCRT_FILE* file) int CDECL MSVCRT_fgetc(MSVCRT_FILE* file)
{ {
char *i; unsigned char *i;
int j; unsigned int j;
do { do {
if (file->_cnt>0) { if (file->_cnt>0) {
file->_cnt--; file->_cnt--;
i = file->_ptr++; i = (unsigned char *)file->_ptr++;
j = *i; j = *i;
} else } else
j = MSVCRT__filbuf(file); j = MSVCRT__filbuf(file);
......
...@@ -255,6 +255,24 @@ static WCHAR* AtoW( char* p ) ...@@ -255,6 +255,24 @@ static WCHAR* AtoW( char* p )
return buffer; return buffer;
} }
static void test_fgetc( void )
{
char* tempf;
FILE *tempfh;
int ich=0xe0, ret;
tempf=_tempnam(".","wne");
tempfh = fopen(tempf,"w+");
fputc(ich, tempfh);
fputc(ich, tempfh);
rewind(tempfh);
ret = fgetc(tempfh);
ok(ich == ret, "First fgetc expected %x got %x\n", ich, ret);
ret = fgetc(tempfh);
ok(ich == ret, "Second fgetc expected %x got %x\n", ich, ret);
fclose(tempfh);
}
static void test_fgetwc( void ) static void test_fgetwc( void )
{ {
#define LLEN 512 #define LLEN 512
...@@ -773,6 +791,7 @@ START_TEST(file) ...@@ -773,6 +791,7 @@ START_TEST(file)
test_fileops(); test_fileops();
test_readmode(FALSE); /* binary mode */ test_readmode(FALSE); /* binary mode */
test_readmode(TRUE); /* ascii mode */ test_readmode(TRUE); /* ascii mode */
test_fgetc();
test_fgetwc(); test_fgetwc();
test_ctrlz(); test_ctrlz();
test_file_put_get(); test_file_put_get();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment