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
97425bd9
Commit
97425bd9
authored
Oct 31, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Reimplement strcmp/strncmp to get consistent return values.
The system functions may not always return -1 or 1. Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
79052f58
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
7 deletions
+16
-7
cpp.c
dlls/msvcrt/cpp.c
+1
-1
mbcs.c
dlls/msvcrt/mbcs.c
+2
-2
msvcrt.h
dlls/msvcrt/msvcrt.h
+2
-0
string.c
dlls/msvcrt/string.c
+11
-4
No files found.
dlls/msvcrt/cpp.c
View file @
97425bd9
...
...
@@ -2075,7 +2075,7 @@ int CDECL MSVCRT_type_info_compare(const type_info140 *l, const type_info140 *r)
int
ret
;
if
(
l
==
r
)
ret
=
0
;
else
ret
=
strcmp
(
l
->
mangled
+
1
,
r
->
mangled
+
1
);
else
ret
=
MSVCRT_
strcmp
(
l
->
mangled
+
1
,
r
->
mangled
+
1
);
TRACE
(
"(%p %p) returning %d
\n
"
,
l
,
r
,
ret
);
return
ret
;
}
...
...
dlls/msvcrt/mbcs.c
View file @
97425bd9
...
...
@@ -118,7 +118,7 @@ static inline unsigned char* u_strncat( unsigned char* dst, const unsigned char*
static
inline
int
u_strcmp
(
const
unsigned
char
*
s1
,
const
unsigned
char
*
s2
)
{
return
strcmp
(
(
const
char
*
)
s1
,
(
const
char
*
)
s2
);
return
MSVCRT_
strcmp
(
(
const
char
*
)
s1
,
(
const
char
*
)
s2
);
}
static
inline
int
u_strcasecmp
(
const
unsigned
char
*
s1
,
const
unsigned
char
*
s2
)
...
...
@@ -128,7 +128,7 @@ static inline int u_strcasecmp( const unsigned char *s1, const unsigned char *s2
static
inline
int
u_strncmp
(
const
unsigned
char
*
s1
,
const
unsigned
char
*
s2
,
MSVCRT_size_t
len
)
{
return
strncmp
(
(
const
char
*
)
s1
,
(
const
char
*
)
s2
,
len
);
return
MSVCRT_
strncmp
(
(
const
char
*
)
s1
,
(
const
char
*
)
s2
,
len
);
}
static
inline
int
u_strncasecmp
(
const
unsigned
char
*
s1
,
const
unsigned
char
*
s2
,
MSVCRT_size_t
len
)
...
...
dlls/msvcrt/msvcrt.h
View file @
97425bd9
...
...
@@ -1176,6 +1176,8 @@ int __cdecl MSVCRT__stricmp(const char*, const char*);
int
__cdecl
MSVCRT__strnicmp
(
const
char
*
,
const
char
*
,
MSVCRT_size_t
);
int
__cdecl
MSVCRT__strnicoll_l
(
const
char
*
,
const
char
*
,
MSVCRT_size_t
,
MSVCRT__locale_t
);
int
__cdecl
MSVCRT__strncoll_l
(
const
char
*
,
const
char
*
,
MSVCRT_size_t
,
MSVCRT__locale_t
);
int
__cdecl
MSVCRT_strncmp
(
const
char
*
,
const
char
*
,
MSVCRT_size_t
);
int
__cdecl
MSVCRT_strcmp
(
const
char
*
,
const
char
*
);
char
*
__cdecl
MSVCRT_strstr
(
const
char
*
,
const
char
*
);
unsigned
int
__cdecl
MSVCRT__get_output_format
(
void
);
char
*
__cdecl
MSVCRT_strtok_s
(
char
*
,
const
char
*
,
char
**
);
...
...
dlls/msvcrt/string.c
View file @
97425bd9
...
...
@@ -616,7 +616,7 @@ int CDECL MSVCRT_strcoll_l( const char* str1, const char* str2, MSVCRT__locale_t
locinfo
=
locale
->
locinfo
;
if
(
!
locinfo
->
lc_handle
[
MSVCRT_LC_COLLATE
])
return
strcmp
(
str1
,
str2
);
return
MSVCRT_
strcmp
(
str1
,
str2
);
return
CompareStringA
(
locinfo
->
lc_handle
[
MSVCRT_LC_COLLATE
],
0
,
str1
,
-
1
,
str2
,
-
1
)
-
CSTR_EQUAL
;
}
...
...
@@ -667,7 +667,7 @@ int CDECL MSVCRT__strncoll_l( const char* str1, const char* str2, MSVCRT_size_t
locinfo
=
locale
->
locinfo
;
if
(
!
locinfo
->
lc_handle
[
MSVCRT_LC_COLLATE
])
return
strncmp
(
str1
,
str2
,
count
);
return
MSVCRT_
strncmp
(
str1
,
str2
,
count
);
return
CompareStringA
(
locinfo
->
lc_handle
[
MSVCRT_LC_COLLATE
],
0
,
str1
,
MSVCRT_strnlen
(
str1
,
count
),
str2
,
MSVCRT_strnlen
(
str2
,
count
))
-
CSTR_EQUAL
;
...
...
@@ -1943,7 +1943,10 @@ void* __cdecl MSVCRT_memchr(const void *ptr, int c, MSVCRT_size_t n)
*/
int
__cdecl
MSVCRT_strcmp
(
const
char
*
str1
,
const
char
*
str2
)
{
return
strcmp
(
str1
,
str2
);
while
(
*
str1
&&
*
str1
==
*
str2
)
{
str1
++
;
str2
++
;
}
if
(
*
str1
>
*
str2
)
return
1
;
if
(
*
str1
<
*
str2
)
return
-
1
;
return
0
;
}
/*********************************************************************
...
...
@@ -1951,7 +1954,11 @@ int __cdecl MSVCRT_strcmp(const char *str1, const char *str2)
*/
int
__cdecl
MSVCRT_strncmp
(
const
char
*
str1
,
const
char
*
str2
,
MSVCRT_size_t
len
)
{
return
strncmp
(
str1
,
str2
,
len
);
if
(
!
len
)
return
0
;
while
(
--
len
&&
*
str1
&&
*
str1
==
*
str2
)
{
str1
++
;
str2
++
;
}
if
(
*
str1
>
*
str2
)
return
1
;
if
(
*
str1
<
*
str2
)
return
-
1
;
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