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
4e2da207
Commit
4e2da207
authored
Jan 16, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Use unsigned comparisons in strcmp and strncmp.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=48454
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
28ab23db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
5 deletions
+39
-5
string.c
dlls/msvcrt/string.c
+3
-5
string.c
dlls/msvcrt/tests/string.c
+36
-0
No files found.
dlls/msvcrt/string.c
View file @
4e2da207
...
...
@@ -2289,8 +2289,8 @@ void* __cdecl MSVCRT_memchr(const void *ptr, int c, MSVCRT_size_t n)
int
__cdecl
MSVCRT_strcmp
(
const
char
*
str1
,
const
char
*
str2
)
{
while
(
*
str1
&&
*
str1
==
*
str2
)
{
str1
++
;
str2
++
;
}
if
(
*
str1
>
*
str2
)
return
1
;
if
(
*
str1
<
*
str2
)
return
-
1
;
if
(
(
unsigned
char
)
*
str1
>
(
unsigned
char
)
*
str2
)
return
1
;
if
(
(
unsigned
char
)
*
str1
<
(
unsigned
char
)
*
str2
)
return
-
1
;
return
0
;
}
...
...
@@ -2301,9 +2301,7 @@ int __cdecl MSVCRT_strncmp(const char *str1, const char *str2, MSVCRT_size_t len
{
if
(
!
len
)
return
0
;
while
(
--
len
&&
*
str1
&&
*
str1
==
*
str2
)
{
str1
++
;
str2
++
;
}
if
(
*
str1
>
*
str2
)
return
1
;
if
(
*
str1
<
*
str2
)
return
-
1
;
return
0
;
return
(
unsigned
char
)
*
str1
-
(
unsigned
char
)
*
str2
;
}
/*********************************************************************
...
...
dlls/msvcrt/tests/string.c
View file @
4e2da207
...
...
@@ -57,6 +57,8 @@ static void* (__cdecl *pmemcpy)(void *, const void *, size_t n);
static
int
(
__cdecl
*
p_memcpy_s
)(
void
*
,
size_t
,
const
void
*
,
size_t
);
static
int
(
__cdecl
*
p_memmove_s
)(
void
*
,
size_t
,
const
void
*
,
size_t
);
static
int
*
(
__cdecl
*
pmemcmp
)(
void
*
,
const
void
*
,
size_t
n
);
static
int
(
__cdecl
*
p_strcmp
)(
const
char
*
,
const
char
*
);
static
int
(
__cdecl
*
p_strncmp
)(
const
char
*
,
const
char
*
,
size_t
);
static
int
(
__cdecl
*
p_strcpy
)(
char
*
dst
,
const
char
*
src
);
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
);
...
...
@@ -630,6 +632,37 @@ static void test_strdup(void)
free
(
str
);
}
static
void
test_strcmp
(
void
)
{
int
ret
=
p_strcmp
(
"abc"
,
"abcd"
);
ok
(
ret
==
-
1
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strcmp
(
""
,
"abc"
);
ok
(
ret
==
-
1
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strcmp
(
"abc"
,
"ab
\xa0
"
);
ok
(
ret
==
-
1
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strcmp
(
"ab
\xb0
"
,
"ab
\xa0
"
);
ok
(
ret
==
1
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strcmp
(
"ab
\xc2
"
,
"ab
\xc2
"
);
ok
(
ret
==
0
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strncmp
(
"abc"
,
"abcd"
,
3
);
ok
(
ret
==
0
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strncmp
(
""
,
"abc"
,
3
);
ok
(
ret
==
0
-
'a'
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strncmp
(
"abc"
,
"ab
\xa0
"
,
4
);
ok
(
ret
==
'c'
-
0xa0
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strncmp
(
"ab
\xb0
"
,
"ab
\xa0
"
,
3
);
ok
(
ret
==
0xb0
-
0xa0
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strncmp
(
"ab
\xb0
"
,
"ab
\xa0
"
,
2
);
ok
(
ret
==
0
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strncmp
(
"ab
\xc2
"
,
"ab
\xc2
"
,
3
);
ok
(
ret
==
0
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strncmp
(
"abc"
,
"abd"
,
0
);
ok
(
ret
==
0
,
"wrong ret %d
\n
"
,
ret
);
ret
=
p_strncmp
(
"abc"
,
"abc"
,
12
);
ok
(
ret
==
0
,
"wrong ret %d
\n
"
,
ret
);
}
static
void
test_strcpy_s
(
void
)
{
char
dest
[
8
];
...
...
@@ -4067,6 +4100,8 @@ START_TEST(string)
SET
(
p_mbctype
,
"_mbctype"
);
SET
(
p__mb_cur_max
,
"__mb_cur_max"
);
SET
(
p_strcpy
,
"strcpy"
);
SET
(
p_strcmp
,
"strcmp"
);
SET
(
p_strncmp
,
"strncmp"
);
pstrcpy_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"strcpy_s"
);
pstrcat_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"strcat_s"
);
p_mbscat_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"_mbscat_s"
);
...
...
@@ -4134,6 +4169,7 @@ START_TEST(string)
test_mbsspn
();
test_mbsspnp
();
test_strdup
();
test_strcmp
();
test_strcpy_s
();
test_memcpy_s
();
test_memmove_s
();
...
...
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