Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
5f2159e8
Commit
5f2159e8
authored
Aug 16, 2008
by
Michael Karcher
Committed by
Alexandre Julliard
Aug 19, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt/file: stdio should clamp characters to 8 bits.
parent
af4562c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
2 deletions
+61
-2
file.c
dlls/msvcrt/file.c
+2
-2
file.c
dlls/msvcrt/tests/file.c
+59
-0
No files found.
dlls/msvcrt/file.c
View file @
5f2159e8
...
...
@@ -2539,7 +2539,7 @@ int CDECL MSVCRT_fputc(int c, MSVCRT_FILE* file)
return
res
?
res
:
c
;
}
else
return
c
;
return
c
&
0xff
;
}
else
{
return
MSVCRT__flsbuf
(
c
,
file
);
}
...
...
@@ -2568,7 +2568,7 @@ int CDECL MSVCRT__flsbuf(int c, MSVCRT_FILE* file)
unsigned
char
cc
=
c
;
int
len
;
len
=
MSVCRT__write
(
file
->
_file
,
&
cc
,
1
);
if
(
len
==
1
)
return
c
;
if
(
len
==
1
)
return
c
&
0xff
;
file
->
_flag
|=
MSVCRT__IOERR
;
return
MSVCRT_EOF
;
}
...
...
dlls/msvcrt/tests/file.c
View file @
5f2159e8
...
...
@@ -334,6 +334,63 @@ static void test_fgetc( void )
unlink
(
tempf
);
}
static
void
test_fputc
(
void
)
{
char
*
tempf
;
FILE
*
tempfh
;
int
ret
;
tempf
=
_tempnam
(
"."
,
"wne"
);
tempfh
=
fopen
(
tempf
,
"wb"
);
ret
=
fputc
(
0
,
tempfh
);
ok
(
0
==
ret
,
"fputc(0,tempfh) expected %x got %x
\n
"
,
0
,
ret
);
ret
=
fputc
(
0xff
,
tempfh
);
ok
(
0xff
==
ret
,
"fputc(0xff,tempfh) expected %x got %x
\n
"
,
0xff
,
ret
);
ret
=
fputc
(
0xffffffff
,
tempfh
);
ok
(
0xff
==
ret
,
"fputc(0xffffffff,tempfh) expected %x got %x
\n
"
,
0xff
,
ret
);
fclose
(
tempfh
);
tempfh
=
fopen
(
tempf
,
"rb"
);
ret
=
fputc
(
0
,
tempfh
);
ok
(
EOF
==
ret
,
"fputc(0,tempfh) on r/o file expected %x got %x
\n
"
,
EOF
,
ret
);
fclose
(
tempfh
);
unlink
(
tempf
);
}
static
void
test_flsbuf
(
void
)
{
char
*
tempf
;
FILE
*
tempfh
;
int
ret
;
int
bufmode
;
int
bufmodes
[]
=
{
_IOFBF
,
_IONBF
};
tempf
=
_tempnam
(
"."
,
"wne"
);
for
(
bufmode
=
0
;
bufmode
<
sizeof
(
bufmodes
)
/
sizeof
(
bufmodes
[
0
]);
bufmode
++
)
{
tempfh
=
fopen
(
tempf
,
"wb"
);
setvbuf
(
tempfh
,
NULL
,
bufmodes
[
bufmode
],
2048
);
ret
=
_flsbuf
(
0
,
tempfh
);
ok
(
0
==
ret
,
"_flsbuf(0,tempfh) with bufmode %x expected %x got %x
\n
"
,
bufmodes
[
bufmode
],
0
,
ret
);
ret
=
_flsbuf
(
0xff
,
tempfh
);
ok
(
0xff
==
ret
,
"_flsbuf(0xff,tempfh) with bufmode %x expected %x got %x
\n
"
,
bufmodes
[
bufmode
],
0
,
ret
);
ret
=
_flsbuf
(
0xffffffff
,
tempfh
);
ok
(
0xff
==
ret
,
"_flsbuf(0xffffffff,tempfh) with bufmode %x expected %x got %x
\n
"
,
bufmodes
[
bufmode
],
0
,
ret
);
fclose
(
tempfh
);
}
tempfh
=
fopen
(
tempf
,
"rb"
);
ret
=
_flsbuf
(
0
,
tempfh
);
ok
(
EOF
==
ret
,
"_flsbuf(0,tempfh) on r/o file expected %x got %x
\n
"
,
EOF
,
ret
);
fclose
(
tempfh
);
unlink
(
tempf
);
}
static
void
test_fgetwc
(
void
)
{
#define LLEN 512
...
...
@@ -1061,6 +1118,8 @@ START_TEST(file)
test_readmode
(
FALSE
);
/* binary mode */
test_readmode
(
TRUE
);
/* ascii mode */
test_fgetc
();
test_fputc
();
test_flsbuf
();
test_fgetwc
();
test_ctrlz
();
test_file_put_get
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment