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
d38196a0
Commit
d38196a0
authored
Nov 15, 2010
by
Eric Pouech
Committed by
Alexandre Julliard
Nov 16, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Use the macros for parameter checking for wcsncat_s (and fix the test).
parent
beca1d73
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
4 deletions
+76
-4
msvcr90.c
dlls/msvcr90/tests/msvcr90.c
+59
-0
string.c
dlls/msvcrt/tests/string.c
+8
-0
wcs.c
dlls/msvcrt/wcs.c
+9
-4
No files found.
dlls/msvcr90/tests/msvcr90.c
View file @
d38196a0
...
...
@@ -64,6 +64,7 @@ static char** (__cdecl *p__sys_errlist)(void);
static
__int64
(
__cdecl
*
p_strtoi64
)(
const
char
*
,
char
**
,
int
);
static
unsigned
__int64
(
__cdecl
*
p_strtoui64
)(
const
char
*
,
char
**
,
int
);
static
errno_t
(
__cdecl
*
p_itoa_s
)(
int
,
char
*
,
size_t
,
int
);
static
int
(
__cdecl
*
p_wcsncat_s
)(
wchar_t
*
dst
,
size_t
elem
,
const
wchar_t
*
src
,
size_t
count
);
static
void
*
(
WINAPI
*
pEncodePointer
)(
void
*
);
...
...
@@ -384,6 +385,62 @@ static void test__itoa_s(void)
buffer
);
}
static
void
test_wcsncat_s
(
void
)
{
static
wchar_t
abcW
[]
=
{
'a'
,
'b'
,
'c'
,
0
};
int
ret
;
wchar_t
dst
[
4
];
wchar_t
src
[
4
];
if
(
!
p_wcsncat_s
)
{
win_skip
(
"skipping wcsncat_s tests
\n
"
);
return
;
}
if
(
!
p_set_invalid_parameter_handler
)
{
win_skip
(
"_set_invalid_parameter_handler not found
\n
"
);
return
;
}
memcpy
(
src
,
abcW
,
sizeof
(
abcW
));
dst
[
0
]
=
0
;
SET_EXPECT
(
invalid_parameter_handler
);
ret
=
p_wcsncat_s
(
NULL
,
4
,
src
,
4
);
ok
(
ret
==
EINVAL
,
"err = %d
\n
"
,
ret
);
CHECK_CALLED
(
invalid_parameter_handler
);
SET_EXPECT
(
invalid_parameter_handler
);
ret
=
p_wcsncat_s
(
dst
,
0
,
src
,
4
);
ok
(
ret
==
EINVAL
,
"err = %d
\n
"
,
ret
);
CHECK_CALLED
(
invalid_parameter_handler
);
SET_EXPECT
(
invalid_parameter_handler
);
ret
=
p_wcsncat_s
(
dst
,
0
,
src
,
_TRUNCATE
);
ok
(
ret
==
EINVAL
,
"err = %d
\n
"
,
ret
);
CHECK_CALLED
(
invalid_parameter_handler
);
ret
=
p_wcsncat_s
(
dst
,
4
,
NULL
,
0
);
ok
(
ret
==
0
,
"err = %d
\n
"
,
ret
);
dst
[
0
]
=
0
;
SET_EXPECT
(
invalid_parameter_handler
);
ret
=
p_wcsncat_s
(
dst
,
2
,
src
,
4
);
ok
(
ret
==
ERANGE
,
"err = %d
\n
"
,
ret
);
CHECK_CALLED
(
invalid_parameter_handler
);
dst
[
0
]
=
0
;
ret
=
p_wcsncat_s
(
dst
,
2
,
src
,
_TRUNCATE
);
ok
(
ret
==
STRUNCATE
,
"err = %d
\n
"
,
ret
);
ok
(
dst
[
0
]
==
'a'
&&
dst
[
1
]
==
0
,
"dst is %s
\n
"
,
wine_dbgstr_w
(
dst
));
memcpy
(
dst
,
abcW
,
sizeof
(
abcW
));
dst
[
3
]
=
'd'
;
SET_EXPECT
(
invalid_parameter_handler
);
ret
=
p_wcsncat_s
(
dst
,
4
,
src
,
4
);
ok
(
ret
==
EINVAL
,
"err = %d
\n
"
,
ret
);
CHECK_CALLED
(
invalid_parameter_handler
);
}
/* ########## */
...
...
@@ -415,6 +472,7 @@ START_TEST(msvcr90)
p_strtoi64
=
(
void
*
)
GetProcAddress
(
hcrt
,
"_strtoi64"
);
p_strtoui64
=
(
void
*
)
GetProcAddress
(
hcrt
,
"_strtoui64"
);
p_itoa_s
=
(
void
*
)
GetProcAddress
(
hcrt
,
"_itoa_s"
);
p_wcsncat_s
=
(
void
*
)
GetProcAddress
(
hcrt
,
"wcsncat_s"
);
hkernel32
=
GetModuleHandleA
(
"kernel32.dll"
);
pEncodePointer
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"EncodePointer"
);
...
...
@@ -424,4 +482,5 @@ START_TEST(msvcr90)
test_error_messages
();
test__strtoi64
();
test__itoa_s
();
test_wcsncat_s
();
}
dlls/msvcrt/tests/string.c
View file @
d38196a0
...
...
@@ -1459,6 +1459,10 @@ static void test_wcsncat_s(void)
return
;
}
if
(
p_set_invalid_parameter_handler
)
ok
(
p_set_invalid_parameter_handler
(
test_invalid_parameter_handler
)
==
NULL
,
"Invalid parameter handler was already set
\n
"
);
memcpy
(
src
,
abcW
,
sizeof
(
abcW
));
dst
[
0
]
=
0
;
ret
=
p_wcsncat_s
(
NULL
,
4
,
src
,
4
);
...
...
@@ -1483,6 +1487,10 @@ static void test_wcsncat_s(void)
dst
[
3
]
=
'd'
;
ret
=
p_wcsncat_s
(
dst
,
4
,
src
,
4
);
ok
(
ret
==
EINVAL
,
"err = %d
\n
"
,
ret
);
if
(
p_set_invalid_parameter_handler
)
ok
(
p_set_invalid_parameter_handler
(
NULL
)
==
test_invalid_parameter_handler
,
"Cannot reset invalid parameter handler
\n
"
);
}
static
void
test__mbsnbcat_s
(
void
)
...
...
dlls/msvcrt/wcs.c
View file @
d38196a0
...
...
@@ -1634,11 +1634,12 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
MSVCRT_wchar_t
dststart
;
INT
ret
=
0
;
if
(
src
==
NULL
&&
count
>
0
)
return
MSVCRT_EINVAL
;
if
(
dst
==
NULL
)
if
(
!
MSVCRT_CHECK_PMT
(
dst
!=
NULL
)
||
!
MSVCRT_CHECK_PMT
(
elem
>
0
)
)
{
*
MSVCRT__errno
()
=
MSVCRT_EINVAL
;
return
MSVCRT_EINVAL
;
if
(
elem
==
0
)
}
if
(
!
MSVCRT_CHECK_PMT
(
src
!=
NULL
||
count
==
0
))
return
MSVCRT_EINVAL
;
if
(
count
==
0
)
return
0
;
...
...
@@ -1649,7 +1650,10 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
break
;
}
if
(
dststart
==
elem
)
{
MSVCRT_INVALID_PMT
(
"dst[elem] is not NULL terminated
\n
"
);
return
MSVCRT_EINVAL
;
}
if
(
count
==
MSVCRT__TRUNCATE
)
{
...
...
@@ -1668,6 +1672,7 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
dst
[
srclen
]
=
'\0'
;
return
ret
;
}
MSVCRT_INVALID_PMT
(
"dst[elem] is too small"
);
dst
[
0
]
=
'\0'
;
return
MSVCRT_ERANGE
;
}
...
...
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