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
1eb07756
Commit
1eb07756
authored
Nov 15, 2009
by
Andrew Nguyen
Committed by
Alexandre Julliard
Nov 16, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Implement and test _wcsupr_s.
parent
44ac91d7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
0 deletions
+120
-0
msvcrt.spec
dlls/msvcrt/msvcrt.spec
+1
-0
string.c
dlls/msvcrt/tests/string.c
+90
-0
wcs.c
dlls/msvcrt/wcs.c
+29
-0
No files found.
dlls/msvcrt/msvcrt.spec
View file @
1eb07756
...
...
@@ -548,6 +548,7 @@
@ cdecl _wcsrev(wstr)
@ cdecl _wcsset(wstr long)
@ cdecl _wcsupr(wstr) ntdll._wcsupr
@ cdecl _wcsupr_s(wstr long) MSVCRT__wcsupr_s
@ cdecl _wctime(ptr) MSVCRT__wctime
@ cdecl _wctime32(ptr) MSVCRT__wctime32
@ cdecl _wctime64(ptr) MSVCRT__wctime64
...
...
dlls/msvcrt/tests/string.c
View file @
1eb07756
...
...
@@ -51,6 +51,7 @@ static int (__cdecl *pstrcpy_s)(char *dst, size_t len, const char *src);
static
int
(
__cdecl
*
pstrcat_s
)(
char
*
dst
,
size_t
len
,
const
char
*
src
);
static
int
(
__cdecl
*
p_mbsnbcpy_s
)(
unsigned
char
*
dst
,
size_t
size
,
const
unsigned
char
*
src
,
size_t
count
);
static
int
(
__cdecl
*
p_wcscpy_s
)(
wchar_t
*
wcDest
,
size_t
size
,
const
wchar_t
*
wcSrc
);
static
int
(
__cdecl
*
p_wcsupr_s
)(
wchar_t
*
str
,
size_t
size
);
static
int
*
p__mb_cur_max
;
static
unsigned
char
*
p_mbctype
;
...
...
@@ -597,6 +598,93 @@ static void test_wcscpy_s(void)
ok
(
szDestShort
[
0
]
==
0
,
"szDestShort[0] not 0
\n
"
);
}
static
void
test__wcsupr_s
(
void
)
{
static
const
WCHAR
mixedString
[]
=
{
'M'
,
'i'
,
'X'
,
'e'
,
'D'
,
'l'
,
'o'
,
'w'
,
'e'
,
'r'
,
'U'
,
'P'
,
'P'
,
'E'
,
'R'
,
0
};
static
const
WCHAR
expectedString
[]
=
{
'M'
,
'I'
,
'X'
,
'E'
,
'D'
,
'L'
,
'O'
,
'W'
,
'E'
,
'R'
,
'U'
,
'P'
,
'P'
,
'E'
,
'R'
,
0
};
WCHAR
testBuffer
[
2
*
sizeof
(
mixedString
)
/
sizeof
(
WCHAR
)];
int
ret
;
if
(
!
p_wcsupr_s
)
{
win_skip
(
"_wcsupr_s not found
\n
"
);
return
;
}
/* Test NULL input string and invalid size. */
errno
=
EBADF
;
ret
=
p_wcsupr_s
(
NULL
,
0
);
ok
(
ret
==
EINVAL
,
"Expected _wcsupr_s to fail with EINVAL, got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"Expected errno to be EINVAL, got %d
\n
"
,
errno
);
/* Test NULL input string and valid size. */
errno
=
EBADF
;
ret
=
p_wcsupr_s
(
NULL
,
sizeof
(
testBuffer
)
/
sizeof
(
WCHAR
));
ok
(
ret
==
EINVAL
,
"Expected _wcsupr_s to fail with EINVAL, got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"Expected errno to be EINVAL, got %d
\n
"
,
errno
);
/* Test empty string with zero size. */
errno
=
EBADF
;
testBuffer
[
0
]
=
'\0'
;
ret
=
p_wcsupr_s
(
testBuffer
,
0
);
ok
(
ret
==
EINVAL
,
"Expected _wcsupr_s to fail with EINVAL, got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"Expected errno to be EINVAL, got %d
\n
"
,
errno
);
ok
(
testBuffer
[
0
]
==
'\0'
,
"Expected the buffer to be unchanged
\n
"
);
/* Test empty string with size of one. */
testBuffer
[
0
]
=
'\0'
;
ret
=
p_wcsupr_s
(
testBuffer
,
1
);
ok
(
ret
==
0
,
"Expected _wcsupr_s to succeed, got %d
\n
"
,
ret
);
ok
(
testBuffer
[
0
]
==
'\0'
,
"Expected the buffer to be unchanged
\n
"
);
/* Test one-byte buffer with zero size. */
errno
=
EBADF
;
testBuffer
[
0
]
=
'x'
;
ret
=
p_wcsupr_s
(
testBuffer
,
0
);
ok
(
ret
==
EINVAL
,
"Expected _wcsupr_s to fail with EINVAL, got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"Expected errno to be EINVAL, got %d
\n
"
,
errno
);
ok
(
testBuffer
[
0
]
==
'\0'
,
"Expected the first buffer character to be null
\n
"
);
/* Test one-byte buffer with size of one. */
errno
=
EBADF
;
testBuffer
[
0
]
=
'x'
;
ret
=
p_wcsupr_s
(
testBuffer
,
1
);
ok
(
ret
==
EINVAL
,
"Expected _wcsupr_s to fail with EINVAL, got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"Expected errno to be EINVAL, got %d
\n
"
,
errno
);
ok
(
testBuffer
[
0
]
==
'\0'
,
"Expected the first buffer character to be null
\n
"
);
/* Test invalid size. */
wcscpy
(
testBuffer
,
mixedString
);
errno
=
EBADF
;
ret
=
p_wcsupr_s
(
testBuffer
,
0
);
ok
(
ret
==
EINVAL
,
"Expected _wcsupr_s to fail with EINVAL, got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"Expected errno to be EINVAL, got %d
\n
"
,
errno
);
ok
(
testBuffer
[
0
]
==
'\0'
,
"Expected the first buffer character to be null
\n
"
);
/* Test normal string uppercasing. */
wcscpy
(
testBuffer
,
mixedString
);
ret
=
p_wcsupr_s
(
testBuffer
,
sizeof
(
mixedString
)
/
sizeof
(
WCHAR
));
ok
(
ret
==
0
,
"Expected _wcsupr_s to succeed, got %d
\n
"
,
ret
);
ok
(
!
wcscmp
(
testBuffer
,
expectedString
),
"Expected the string to be fully upper-case
\n
"
);
/* Test uppercasing with a shorter buffer size count. */
wcscpy
(
testBuffer
,
mixedString
);
errno
=
EBADF
;
ret
=
p_wcsupr_s
(
testBuffer
,
sizeof
(
mixedString
)
/
sizeof
(
WCHAR
)
-
1
);
ok
(
ret
==
EINVAL
,
"Expected _wcsupr_s to fail with EINVAL, got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"Expected errno to be EINVAL, got %d
\n
"
,
errno
);
ok
(
testBuffer
[
0
]
==
'\0'
,
"Expected the first buffer character to be null
\n
"
);
/* Test uppercasing with a longer buffer size count. */
wcscpy
(
testBuffer
,
mixedString
);
ret
=
p_wcsupr_s
(
testBuffer
,
sizeof
(
testBuffer
)
/
sizeof
(
WCHAR
));
ok
(
ret
==
0
,
"Expected _wcsupr_s to succeed, got %d
\n
"
,
ret
);
ok
(
!
wcscmp
(
testBuffer
,
expectedString
),
"Expected the string to be fully upper-case
\n
"
);
}
static
void
test_mbcjisjms
(
void
)
{
/* List of value-pairs to test. The test assumes the last pair to be {0, ..} */
...
...
@@ -721,6 +809,7 @@ START_TEST(string)
pstrcat_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"strcat_s"
);
p_mbsnbcpy_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"_mbsnbcpy_s"
);
p_wcscpy_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"wcscpy_s"
);
p_wcsupr_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"_wcsupr_s"
);
/* MSVCRT memcpy behaves like memmove for overlapping moves,
MFC42 CString::Insert seems to rely on that behaviour */
...
...
@@ -746,5 +835,6 @@ START_TEST(string)
test_mbcjisjms
();
test_strtok
();
test_wcscpy_s
();
test__wcsupr_s
();
test_strtol
();
}
dlls/msvcrt/wcs.c
View file @
1eb07756
...
...
@@ -90,6 +90,35 @@ MSVCRT_wchar_t* CDECL _wcsset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c )
return
ret
;
}
/******************************************************************
* _wcsupr_s (MSVCRT.@)
*
*/
INT
CDECL
MSVCRT__wcsupr_s
(
MSVCRT_wchar_t
*
str
,
MSVCRT_size_t
n
)
{
MSVCRT_wchar_t
*
ptr
=
str
;
if
(
!
str
||
!
n
)
{
if
(
str
)
*
str
=
'\0'
;
*
MSVCRT__errno
()
=
MSVCRT_EINVAL
;
return
MSVCRT_EINVAL
;
}
while
(
n
--
)
{
if
(
!*
ptr
)
return
0
;
*
ptr
=
toupperW
(
*
ptr
);
ptr
++
;
}
/* MSDN claims that the function should return and set errno to
* ERANGE, which doesn't seem to be true based on the tests. */
*
str
=
'\0'
;
*
MSVCRT__errno
()
=
MSVCRT_EINVAL
;
return
MSVCRT_EINVAL
;
}
/*********************************************************************
* wcstod (MSVCRT.@)
*/
...
...
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