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
b724a79e
Commit
b724a79e
authored
Dec 20, 2023
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comctl32: Fix string comparison for listbox inexact matches.
Same as
343398d2
. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=55446
parent
b0db6cfd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
9 deletions
+87
-9
listbox.c
dlls/comctl32/listbox.c
+9
-9
listbox.c
dlls/comctl32/tests/listbox.c
+78
-0
No files found.
dlls/comctl32/listbox.c
View file @
b724a79e
...
@@ -880,9 +880,9 @@ static LRESULT LISTBOX_GetText( LB_DESCR *descr, INT index, LPWSTR buffer, BOOL
...
@@ -880,9 +880,9 @@ static LRESULT LISTBOX_GetText( LB_DESCR *descr, INT index, LPWSTR buffer, BOOL
return
len
;
return
len
;
}
}
static
inline
INT
LISTBOX_lstrcmpiW
(
LCID
lcid
,
LPCWSTR
str1
,
LPCWSTR
str2
)
static
inline
INT
LISTBOX_lstrcmpiW
(
LCID
lcid
,
LPCWSTR
str1
,
LPCWSTR
str2
,
int
len
)
{
{
INT
ret
=
CompareStringW
(
lcid
,
NORM_IGNORECASE
,
str1
,
-
1
,
str2
,
-
1
);
INT
ret
=
CompareStringW
(
lcid
,
NORM_IGNORECASE
,
str1
,
len
,
str2
,
len
);
if
(
ret
==
CSTR_LESS_THAN
)
if
(
ret
==
CSTR_LESS_THAN
)
return
-
1
;
return
-
1
;
if
(
ret
==
CSTR_EQUAL
)
if
(
ret
==
CSTR_EQUAL
)
...
@@ -910,7 +910,7 @@ static INT LISTBOX_FindStringPos( LB_DESCR *descr, LPCWSTR str, BOOL exact )
...
@@ -910,7 +910,7 @@ static INT LISTBOX_FindStringPos( LB_DESCR *descr, LPCWSTR str, BOOL exact )
{
{
index
=
(
min
+
max
)
/
2
;
index
=
(
min
+
max
)
/
2
;
if
(
HAS_STRINGS
(
descr
))
if
(
HAS_STRINGS
(
descr
))
res
=
LISTBOX_lstrcmpiW
(
descr
->
locale
,
get_item_string
(
descr
,
index
),
str
);
res
=
LISTBOX_lstrcmpiW
(
descr
->
locale
,
get_item_string
(
descr
,
index
),
str
,
-
1
);
else
else
{
{
COMPAREITEMSTRUCT
cis
;
COMPAREITEMSTRUCT
cis
;
...
@@ -965,13 +965,13 @@ static INT LISTBOX_FindFileStrPos( LB_DESCR *descr, LPCWSTR str )
...
@@ -965,13 +965,13 @@ static INT LISTBOX_FindFileStrPos( LB_DESCR *descr, LPCWSTR str )
else
/* directory */
else
/* directory */
{
{
if
(
str
[
1
]
==
'-'
)
res
=
1
;
if
(
str
[
1
]
==
'-'
)
res
=
1
;
else
res
=
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
p
);
else
res
=
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
p
,
-
1
);
}
}
}
}
else
/* filename */
else
/* filename */
{
{
if
(
*
str
==
'['
)
res
=
1
;
if
(
*
str
==
'['
)
res
=
1
;
else
res
=
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
p
);
else
res
=
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
p
,
-
1
);
}
}
if
(
!
res
)
return
index
;
if
(
!
res
)
return
index
;
if
(
res
<
0
)
max
=
index
;
if
(
res
<
0
)
max
=
index
;
...
@@ -1002,7 +1002,7 @@ static INT LISTBOX_FindString( LB_DESCR *descr, INT start, LPCWSTR str, BOOL exa
...
@@ -1002,7 +1002,7 @@ static INT LISTBOX_FindString( LB_DESCR *descr, INT start, LPCWSTR str, BOOL exa
for
(
i
=
0
,
index
=
start
;
i
<
descr
->
nb_items
;
i
++
,
index
++
)
for
(
i
=
0
,
index
=
start
;
i
<
descr
->
nb_items
;
i
++
,
index
++
)
{
{
if
(
index
==
descr
->
nb_items
)
index
=
0
;
if
(
index
==
descr
->
nb_items
)
index
=
0
;
if
(
!
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
get_item_string
(
descr
,
index
)))
if
(
!
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
get_item_string
(
descr
,
index
)
,
-
1
))
return
index
;
return
index
;
}
}
}
}
...
@@ -1017,11 +1017,11 @@ static INT LISTBOX_FindString( LB_DESCR *descr, INT start, LPCWSTR str, BOOL exa
...
@@ -1017,11 +1017,11 @@ static INT LISTBOX_FindString( LB_DESCR *descr, INT start, LPCWSTR str, BOOL exa
if
(
index
==
descr
->
nb_items
)
index
=
0
;
if
(
index
==
descr
->
nb_items
)
index
=
0
;
item_str
=
get_item_string
(
descr
,
index
);
item_str
=
get_item_string
(
descr
,
index
);
if
(
!
wcsnicmp
(
str
,
item_str
,
len
))
return
index
;
if
(
!
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
item_str
,
len
))
return
index
;
if
(
item_str
[
0
]
==
'['
)
if
(
item_str
[
0
]
==
'['
)
{
{
if
(
!
wcsnicmp
(
str
,
item_str
+
1
,
len
))
return
index
;
if
(
!
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
item_str
+
1
,
len
))
return
index
;
if
(
item_str
[
1
]
==
'-'
&&
!
wcsnicmp
(
str
,
item_str
+
2
,
len
))
return
index
;
if
(
item_str
[
1
]
==
'-'
&&
!
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
item_str
+
2
,
len
))
return
index
;
}
}
}
}
}
}
...
...
dlls/comctl32/tests/listbox.c
View file @
b724a79e
...
@@ -2675,6 +2675,83 @@ static void test_LBS_NODATA(void)
...
@@ -2675,6 +2675,83 @@ static void test_LBS_NODATA(void)
DestroyWindow
(
parent
);
DestroyWindow
(
parent
);
}
}
static
void
test_LB_FINDSTRING
(
void
)
{
static
const
WCHAR
*
strings
[]
=
{
L"abci"
,
L"AbCI"
,
L"abcI"
,
L"abc
\xcd
zz"
,
L"abc
\xed
zz"
,
L"abc
\xcd
"
,
L"abc
\xed
"
,
L"abcO"
,
L"abc
\xd8
"
,
L"abcP"
,
};
static
const
struct
{
const
WCHAR
*
str
;
LRESULT
from
,
res
,
exact
,
alt_res
,
alt_exact
;
}
tests
[]
=
{
{
L"ab"
,
-
1
,
0
,
-
1
,
0
,
-
1
},
{
L"abc"
,
-
1
,
0
,
-
1
,
0
,
-
1
},
{
L"abci"
,
-
1
,
0
,
0
,
0
,
0
},
{
L"ABCI"
,
-
1
,
0
,
0
,
0
,
0
},
{
L"ABC
\xed
"
,
-
1
,
3
,
3
,
3
,
3
},
{
L"ABC
\xcd
"
,
4
,
5
,
3
,
5
,
3
},
{
L"abcp"
,
-
1
,
9
,
9
,
8
,
8
},
};
HWND
listbox
;
unsigned
int
i
;
LRESULT
ret
;
listbox
=
CreateWindowW
(
L"listbox"
,
L"TestList"
,
LBS_HASSTRINGS
|
LBS_SORT
,
0
,
0
,
100
,
100
,
NULL
,
NULL
,
NULL
,
0
);
ok
(
listbox
!=
NULL
,
"Failed to create listbox
\n
"
);
SendMessageW
(
listbox
,
LB_SETLOCALE
,
MAKELANGID
(
LANG_FRENCH
,
SUBLANG_DEFAULT
),
0
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
strings
);
i
++
)
SendMessageW
(
listbox
,
LB_ADDSTRING
,
0
,
(
LPARAM
)
strings
[
i
]
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
tests
);
i
++
)
{
ret
=
SendMessageW
(
listbox
,
LB_FINDSTRING
,
tests
[
i
].
from
,
(
LPARAM
)
tests
[
i
].
str
);
ok
(
ret
==
tests
[
i
].
res
,
"%u: wrong result %Id / %Id
\n
"
,
i
,
ret
,
tests
[
i
].
res
);
ret
=
SendMessageW
(
listbox
,
LB_FINDSTRINGEXACT
,
tests
[
i
].
from
,
(
LPARAM
)
tests
[
i
].
str
);
ok
(
ret
==
tests
[
i
].
exact
,
"%u: wrong result %Id / %Id
\n
"
,
i
,
ret
,
tests
[
i
].
exact
);
}
SendMessageW
(
listbox
,
LB_RESETCONTENT
,
0
,
0
);
SendMessageW
(
listbox
,
LB_SETLOCALE
,
MAKELANGID
(
LANG_SWEDISH
,
SUBLANG_DEFAULT
),
0
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
strings
);
i
++
)
SendMessageW
(
listbox
,
LB_ADDSTRING
,
0
,
(
LPARAM
)
strings
[
i
]
);
ret
=
SendMessageW
(
listbox
,
LB_FINDSTRING
,
-
1
,
(
LPARAM
)
L"abcp"
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
tests
);
i
++
)
{
ret
=
SendMessageW
(
listbox
,
LB_FINDSTRING
,
tests
[
i
].
from
,
(
LPARAM
)
tests
[
i
].
str
);
ok
(
ret
==
tests
[
i
].
alt_res
,
"%u: wrong result %Id / %Id
\n
"
,
i
,
ret
,
tests
[
i
].
alt_res
);
ret
=
SendMessageW
(
listbox
,
LB_FINDSTRINGEXACT
,
tests
[
i
].
from
,
(
LPARAM
)
tests
[
i
].
str
);
ok
(
ret
==
tests
[
i
].
alt_exact
,
"%u: wrong result %Id / %Id
\n
"
,
i
,
ret
,
tests
[
i
].
alt_exact
);
}
SendMessageW
(
listbox
,
LB_RESETCONTENT
,
0
,
0
);
SendMessageW
(
listbox
,
LB_ADDSTRING
,
0
,
(
LPARAM
)
L"abc"
);
SendMessageW
(
listbox
,
LB_ADDSTRING
,
0
,
(
LPARAM
)
L"[abc]"
);
SendMessageW
(
listbox
,
LB_ADDSTRING
,
0
,
(
LPARAM
)
L"[-abc-]"
);
ret
=
SendMessageW
(
listbox
,
LB_FINDSTRING
,
-
1
,
(
LPARAM
)
L"abc"
);
ok
(
ret
==
0
,
"wrong result %Id
\n
"
,
ret
);
ret
=
SendMessageW
(
listbox
,
LB_FINDSTRINGEXACT
,
-
1
,
(
LPARAM
)
L"abc"
);
todo_wine
ok
(
ret
==
0
,
"wrong result %Id
\n
"
,
ret
);
ret
=
SendMessageW
(
listbox
,
LB_FINDSTRING
,
0
,
(
LPARAM
)
L"abc"
);
ok
(
ret
==
1
,
"wrong result %Id
\n
"
,
ret
);
ret
=
SendMessageW
(
listbox
,
LB_FINDSTRINGEXACT
,
0
,
(
LPARAM
)
L"abc"
);
todo_wine
ok
(
ret
==
0
,
"wrong result %Id
\n
"
,
ret
);
ret
=
SendMessageW
(
listbox
,
LB_FINDSTRING
,
1
,
(
LPARAM
)
L"abc"
);
ok
(
ret
==
2
,
"wrong result %Id
\n
"
,
ret
);
ret
=
SendMessageW
(
listbox
,
LB_FINDSTRINGEXACT
,
1
,
(
LPARAM
)
L"abc"
);
todo_wine
ok
(
ret
==
0
,
"wrong result %Id
\n
"
,
ret
);
DestroyWindow
(
listbox
);
}
START_TEST
(
listbox
)
START_TEST
(
listbox
)
{
{
ULONG_PTR
ctx_cookie
;
ULONG_PTR
ctx_cookie
;
...
@@ -2704,6 +2781,7 @@ START_TEST(listbox)
...
@@ -2704,6 +2781,7 @@ START_TEST(listbox)
test_WM_MEASUREITEM
();
test_WM_MEASUREITEM
();
test_LB_SETSEL
();
test_LB_SETSEL
();
test_LBS_NODATA
();
test_LBS_NODATA
();
test_LB_FINDSTRING
();
unload_v6_module
(
ctx_cookie
,
hCtx
);
unload_v6_module
(
ctx_cookie
,
hCtx
);
}
}
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