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
9b52a967
Commit
9b52a967
authored
Mar 26, 2019
by
Piotr Caban
Committed by
Alexandre Julliard
Mar 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Fix _strnicmp implementation to not depend on locale.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
98517857
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
7 deletions
+48
-7
string.c
dlls/ntdll/string.c
+22
-7
string.c
dlls/ntdll/tests/string.c
+26
-0
No files found.
dlls/ntdll/string.c
View file @
9b52a967
...
...
@@ -258,21 +258,36 @@ INT __cdecl _memicmp( LPCSTR s1, LPCSTR s2, DWORD len )
/*********************************************************************
* _stricmp (NTDLL.@)
* _strcmpi (NTDLL.@)
* _strnicmp (NTDLL.@)
*/
int
__cdecl
_str
icmp
(
LPCSTR
str1
,
LPCSTR
str2
)
int
__cdecl
_str
nicmp
(
LPCSTR
str1
,
LPCSTR
str2
,
size_t
n
)
{
return
strcasecmp
(
str1
,
str2
);
int
l1
,
l2
;
while
(
n
--
)
{
l1
=
(
unsigned
char
)
NTDLL_tolower
(
*
str1
);
l2
=
(
unsigned
char
)
NTDLL_tolower
(
*
str2
);
if
(
l1
!=
l2
)
{
if
(
sizeof
(
void
*
)
>
sizeof
(
int
))
return
l1
-
l2
;
return
l1
-
l2
>
0
?
1
:
-
1
;
}
if
(
!
l1
)
return
0
;
str1
++
;
str2
++
;
}
return
0
;
}
/*********************************************************************
* _strnicmp (NTDLL.@)
* _stricmp (NTDLL.@)
* _strcmpi (NTDLL.@)
*/
int
__cdecl
_str
nicmp
(
LPCSTR
str1
,
LPCSTR
str2
,
size_t
n
)
int
__cdecl
_str
icmp
(
LPCSTR
str1
,
LPCSTR
str2
)
{
return
strncasecmp
(
str1
,
str2
,
n
);
return
_strnicmp
(
str1
,
str2
,
-
1
);
}
...
...
dlls/ntdll/tests/string.c
View file @
9b52a967
...
...
@@ -64,6 +64,7 @@ static int (WINAPIV *p__snprintf)(char *, size_t, const char *, ...);
static
int
(
__cdecl
*
p_tolower
)(
int
);
static
int
(
__cdecl
*
p_toupper
)(
int
);
static
int
(
__cdecl
*
p__strnicmp
)(
LPCSTR
,
LPCSTR
,
size_t
);
static
void
InitFunctionPtrs
(
void
)
{
...
...
@@ -105,6 +106,7 @@ static void InitFunctionPtrs(void)
p_tolower
=
(
void
*
)
GetProcAddress
(
hntdll
,
"tolower"
);
p_toupper
=
(
void
*
)
GetProcAddress
(
hntdll
,
"toupper"
);
p__strnicmp
=
(
void
*
)
GetProcAddress
(
hntdll
,
"_strnicmp"
);
}
/* if */
}
...
...
@@ -1381,6 +1383,29 @@ static void test_toupper(void)
}
}
static
void
test__strnicmp
(
void
)
{
BOOL
is_win64
=
(
sizeof
(
void
*
)
>
sizeof
(
int
));
int
ret
;
ok
(
p__strnicmp
!=
NULL
,
"_strnicmp is not available
\n
"
);
ret
=
p__strnicmp
(
"a"
,
"C"
,
1
);
ok
(
ret
==
(
is_win64
?
-
2
:
-
1
),
"_strnicmp returned %d
\n
"
,
ret
);
ret
=
p__strnicmp
(
"a"
,
"c"
,
1
);
ok
(
ret
==
(
is_win64
?
-
2
:
-
1
),
"_strnicmp returned %d
\n
"
,
ret
);
ret
=
p__strnicmp
(
"C"
,
"a"
,
1
);
ok
(
ret
==
(
is_win64
?
2
:
1
),
"_strnicmp returned %d
\n
"
,
ret
);
ret
=
p__strnicmp
(
"c"
,
"a"
,
1
);
ok
(
ret
==
(
is_win64
?
2
:
1
),
"_strnicmp returned %d
\n
"
,
ret
);
ret
=
p__strnicmp
(
"ijk0"
,
"IJK1"
,
3
);
ok
(
!
ret
,
"_strnicmp returned %d
\n
"
,
ret
);
ret
=
p__strnicmp
(
"ijk0"
,
"IJK1"
,
4
);
ok
(
ret
==
-
1
,
"_strnicmp returned %d
\n
"
,
ret
);
ret
=
p__strnicmp
(
"ijk
\0
X"
,
"IJK
\0
Y"
,
5
);
ok
(
!
ret
,
"_strnicmp returned %d
\n
"
,
ret
);
}
START_TEST
(
string
)
{
InitFunctionPtrs
();
...
...
@@ -1419,4 +1444,5 @@ START_TEST(string)
test__snprintf
();
test_tolower
();
test_toupper
();
test__strnicmp
();
}
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