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
00609d5e
Commit
00609d5e
authored
Feb 27, 2008
by
Alistair Leslie-Hughes
Committed by
Alexandre Julliard
Feb 27, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Implement wcscpy_s.
parent
aebcbf0f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
0 deletions
+84
-0
msvcrt.spec
dlls/msvcrt/msvcrt.spec
+1
-0
string.c
dlls/msvcrt/tests/string.c
+45
-0
wcs.c
dlls/msvcrt/wcs.c
+38
-0
No files found.
dlls/msvcrt/msvcrt.spec
View file @
00609d5e
...
...
@@ -761,6 +761,7 @@
@ cdecl wcscmp(wstr wstr) ntdll.wcscmp
@ cdecl wcscoll(wstr wstr) MSVCRT_wcscoll
@ cdecl wcscpy(ptr wstr) ntdll.wcscpy
@ cdecl wcscpy_s(ptr long wstr) MSVCRT_wcscpy_s
@ cdecl wcscspn(wstr wstr) ntdll.wcscspn
@ cdecl wcsftime(ptr long wstr ptr) MSVCRT_wcsftime
@ cdecl wcslen(wstr) ntdll.wcslen
...
...
dlls/msvcrt/tests/string.c
View file @
00609d5e
...
...
@@ -50,6 +50,7 @@ static int* (*pmemcmp)(void *, const void *, size_t n);
static
int
(
*
pstrcpy_s
)(
char
*
dst
,
size_t
len
,
const
char
*
src
);
static
int
(
*
pstrcat_s
)(
char
*
dst
,
size_t
len
,
const
char
*
src
);
static
int
(
*
p_mbsnbcpy_s
)(
unsigned
char
*
dst
,
size_t
size
,
const
unsigned
char
*
src
,
size_t
count
);
static
int
(
*
p_wcscpy_s
)(
wchar_t
*
wcDest
,
size_t
size
,
const
wchar_t
*
wcSrc
);
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
#define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
...
...
@@ -562,6 +563,47 @@ static void test__mbsnbcpy_s(void)
dest
[
0
],
dest
[
1
],
dest
[
2
],
dest
[
3
],
dest
[
4
],
dest
[
5
],
dest
[
6
],
dest
[
7
]);
}
static
void
test_wcscpy_s
(
void
)
{
static
const
WCHAR
szLongText
[]
=
{
'T'
,
'h'
,
'i'
,
's'
,
'A'
,
'L'
,
'o'
,
'n'
,
'g'
,
's'
,
't'
,
'r'
,
'i'
,
'n'
,
'g'
,
0
};
static
WCHAR
szDest
[
18
];
static
WCHAR
szDestShort
[
8
];
int
ret
;
if
(
!
p_wcscpy_s
)
{
skip
(
"wcscpy_s not found
\n
"
);
return
;
}
/* Test NULl Dest */
ret
=
p_wcscpy_s
(
NULL
,
18
,
szLongText
);
ok
(
ret
==
EINVAL
,
"p_wcscpy_s expect EINVAL got %d
\n
"
,
ret
);
/* Test NULl Source */
szDest
[
0
]
=
'A'
;
ret
=
p_wcscpy_s
(
szDest
,
18
,
NULL
);
ok
(
ret
==
EINVAL
,
"expected EINVAL got %d
\n
"
,
ret
);
ok
(
szDest
[
0
]
==
0
,
"szDest[0] not 0
\n
"
);
/* Test invalid size */
szDest
[
0
]
=
'A'
;
ret
=
p_wcscpy_s
(
szDest
,
0
,
szLongText
);
ok
(
ret
==
ERANGE
,
"expected ERANGE got %d
\n
"
,
ret
);
ok
(
szDest
[
0
]
==
0
,
"szDest[0] not 0
\n
"
);
/* Copy same buffer size */
ret
=
p_wcscpy_s
(
szDest
,
18
,
szLongText
);
ok
(
ret
==
0
,
"expected 0 got %d
\n
"
,
ret
);
ok
(
lstrcmpW
(
szDest
,
szLongText
)
==
0
,
"szDest != szLongText
\n
"
);
/* Copy smaller buffer size */
szDest
[
0
]
=
'A'
;
ret
=
p_wcscpy_s
(
szDestShort
,
8
,
szLongText
);
ok
(
ret
==
EINVAL
,
"expected EINVAL got %d
\n
"
,
ret
);
ok
(
szDestShort
[
0
]
==
0
,
"szDestShort[0] not 0
\n
"
);
}
START_TEST
(
string
)
{
char
mem
[
100
];
...
...
@@ -577,6 +619,7 @@ START_TEST(string)
SET
(
pstrcpy_s
,
"strcpy_s"
);
SET
(
pstrcat_s
,
"strcat_s"
);
SET
(
p_mbsnbcpy_s
,
"_mbsnbcpy_s"
);
SET
(
p_wcscpy_s
,
"wcscpy_s"
);
/* MSVCRT memcpy behaves like memmove for overlapping moves,
MFC42 CString::Insert seems to rely on that behaviour */
...
...
@@ -599,4 +642,6 @@ START_TEST(string)
test_strcpy_s
();
test_strcat_s
();
test__mbsnbcpy_s
();
test_wcscpy_s
();
}
dlls/msvcrt/wcs.c
View file @
00609d5e
...
...
@@ -971,3 +971,41 @@ INT CDECL MSVCRT_iswxdigit( MSVCRT_wchar_t wc )
{
return
isxdigitW
(
wc
);
}
/*********************************************************************
* wcscpy_s (MSVCRT.@)
*/
INT
CDECL
MSVCRT_wcscpy_s
(
MSVCRT_wchar_t
*
wcDest
,
MSVCRT_size_t
numElement
,
const
MSVCRT_wchar_t
*
wcSrc
)
{
INT
size
=
0
;
if
(
!
wcDest
)
return
MSVCRT_EINVAL
;
if
(
!
wcSrc
)
{
wcDest
[
0
]
=
0
;
return
MSVCRT_EINVAL
;
}
if
(
numElement
==
0
)
{
wcDest
[
0
]
=
0
;
return
MSVCRT_ERANGE
;
}
size
=
strlenW
(
wcSrc
)
+
1
;
if
(
size
>
numElement
)
{
wcDest
[
0
]
=
0
;
return
MSVCRT_EINVAL
;
}
if
(
size
>
numElement
)
size
=
numElement
;
memcpy
(
wcDest
,
wcSrc
,
size
*
sizeof
(
WCHAR
)
);
return
0
;
}
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