Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
c9bd269d
Commit
c9bd269d
authored
Nov 10, 2010
by
Eryk Wieliczko
Committed by
Alexandre Julliard
Nov 11, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Fixed (_w)fopen_s with test.
parent
3bbe658e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
2 deletions
+93
-2
file.c
dlls/msvcrt/file.c
+2
-2
file.c
dlls/msvcrt/tests/file.c
+91
-0
No files found.
dlls/msvcrt/file.c
View file @
c9bd269d
...
...
@@ -2742,7 +2742,7 @@ int CDECL MSVCRT_fopen_s(MSVCRT_FILE** pFile,
const
char
*
filename
,
const
char
*
mode
)
{
if
(
!
MSVCRT_CHECK_PMT
(
pFile
!=
NULL
)
||
!
MSVCRT_CHECK_PMT
(
filename
!=
NULL
)
||
MSVCRT_CHECK_PMT
(
mode
!=
NULL
))
{
!
MSVCRT_CHECK_PMT
(
mode
!=
NULL
))
{
*
MSVCRT__errno
()
=
MSVCRT_EINVAL
;
return
MSVCRT_EINVAL
;
}
...
...
@@ -2769,7 +2769,7 @@ int CDECL MSVCRT__wfopen_s(MSVCRT_FILE** pFile, const MSVCRT_wchar_t *filename,
const
MSVCRT_wchar_t
*
mode
)
{
if
(
!
MSVCRT_CHECK_PMT
(
pFile
!=
NULL
)
||
!
MSVCRT_CHECK_PMT
(
filename
!=
NULL
)
||
MSVCRT_CHECK_PMT
(
mode
!=
NULL
))
{
!
MSVCRT_CHECK_PMT
(
mode
!=
NULL
))
{
*
MSVCRT__errno
()
=
MSVCRT_EINVAL
;
return
MSVCRT_EINVAL
;
}
...
...
dlls/msvcrt/tests/file.c
View file @
c9bd269d
...
...
@@ -36,6 +36,17 @@
static
HANDLE
proc_handles
[
2
];
static
int
(
__cdecl
*
p_fopen_s
)(
FILE
**
,
const
char
*
,
const
char
*
);
static
int
(
__cdecl
*
p__wfopen_s
)(
FILE
**
,
const
wchar_t
*
,
const
wchar_t
*
);
static
void
init
(
void
)
{
HMODULE
hmod
=
GetModuleHandleA
(
"msvcrt.dll"
);
p_fopen_s
=
(
void
*
)
GetProcAddress
(
hmod
,
"fopen_s"
);
p__wfopen_s
=
(
void
*
)
GetProcAddress
(
hmod
,
"_wfopen_s"
);
}
static
void
test_filbuf
(
void
)
{
FILE
*
fp
;
...
...
@@ -1201,6 +1212,82 @@ static void test_fopen_fclose_fcloseall( void )
ok
(
_unlink
(
fname3
)
==
0
,
"Couldn't unlink file named '%s'
\n
"
,
fname3
);
}
static
void
test_fopen_s
(
void
)
{
const
char
name
[]
=
"empty1"
;
char
buff
[
16
];
FILE
*
file
;
int
ret
;
int
len
;
if
(
!
p_fopen_s
)
{
win_skip
(
"Skipping fopen_s test
\n
"
);
return
;
}
/* testing fopen_s */
ret
=
p_fopen_s
(
&
file
,
name
,
"w"
);
ok
(
ret
==
0
,
"fopen_s failed with %d
\n
"
,
ret
);
ok
(
file
!=
0
,
"fopen_s failed to return value
\n
"
);
fwrite
(
name
,
sizeof
(
name
),
1
,
file
);
ret
=
fclose
(
file
);
ok
(
ret
!=
EOF
,
"File failed to close
\n
"
);
file
=
fopen
(
name
,
"r"
);
ok
(
file
!=
0
,
"fopen failed
\n
"
);
len
=
fread
(
buff
,
1
,
sizeof
(
name
),
file
);
ok
(
len
==
sizeof
(
name
),
"File length supposed to be %d, not %d
\n
"
,
sizeof
(
name
),
len
);
buff
[
sizeof
(
name
)]
=
'\0'
;
ok
(
strcmp
(
name
,
buff
)
==
0
,
"File content mismatch! Got %s, expected %s
\n
"
,
buff
,
name
);
ret
=
fclose
(
file
);
ok
(
ret
!=
EOF
,
"File failed to close
\n
"
);
ok
(
_unlink
(
name
)
==
0
,
"Couldn't unlink file named '%s'
\n
"
,
name
);
}
static
void
test__wfopen_s
(
void
)
{
const
char
name
[]
=
"empty1"
;
const
WCHAR
wname
[]
=
{
'e'
,
'm'
,
'p'
,
't'
,
'y'
,
'1'
,
0
};
const
WCHAR
wmode
[]
=
{
'w'
,
0
};
char
buff
[
16
];
FILE
*
file
;
int
ret
;
int
len
;
if
(
!
p__wfopen_s
)
{
win_skip
(
"Skipping _wfopen_s test
\n
"
);
return
;
}
/* testing _wfopen_s */
ret
=
p__wfopen_s
(
&
file
,
wname
,
wmode
);
ok
(
ret
==
0
,
"_wfopen_s failed with %d
\n
"
,
ret
);
ok
(
file
!=
0
,
"_wfopen_s failed to return value
\n
"
);
fwrite
(
name
,
sizeof
(
name
),
1
,
file
);
ret
=
fclose
(
file
);
ok
(
ret
!=
EOF
,
"File failed to close
\n
"
);
file
=
fopen
(
name
,
"r"
);
ok
(
file
!=
0
,
"fopen failed
\n
"
);
len
=
fread
(
buff
,
1
,
sizeof
(
name
),
file
);
ok
(
len
==
sizeof
(
name
),
"File length supposed to be %d, not %d
\n
"
,
sizeof
(
name
),
len
);
buff
[
sizeof
(
name
)]
=
'\0'
;
ok
(
strcmp
(
name
,
buff
)
==
0
,
"File content mismatch! Got %s, expected %s
\n
"
,
buff
,
name
);
ret
=
fclose
(
file
);
ok
(
ret
!=
EOF
,
"File failed to close
\n
"
);
ok
(
_unlink
(
name
)
==
0
,
"Couldn't unlink file named '%s'
\n
"
,
name
);
}
static
void
test_get_osfhandle
(
void
)
{
int
fd
;
...
...
@@ -1424,6 +1511,8 @@ START_TEST(file)
int
arg_c
;
char
**
arg_v
;
init
();
arg_c
=
winetest_get_mainargs
(
&
arg_v
);
/* testing low-level I/O */
...
...
@@ -1450,6 +1539,8 @@ START_TEST(file)
test_filbuf
();
test_fdopen
();
test_fopen_fclose_fcloseall
();
test_fopen_s
();
test__wfopen_s
();
test_fileops
();
test_asciimode
();
test_asciimode2
();
...
...
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