Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gabriel Ivăncescu
wine
Commits
343398d2
Commit
343398d2
authored
1 year ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
user32: Fix string comparison for listbox inexact matches.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=55446
parent
3e0c21be
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dlls/user32/listbox.c
+9
-9
9 additions, 9 deletions
dlls/user32/listbox.c
dlls/user32/tests/listbox.c
+78
-0
78 additions, 0 deletions
dlls/user32/tests/listbox.c
with
87 additions
and
9 deletions
dlls/user32/listbox.c
+
9
−
9
View file @
343398d2
...
...
@@ -891,9 +891,9 @@ static LRESULT LISTBOX_GetText( LB_DESCR *descr, INT index, LPWSTR buffer, BOOL
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
)
return
-
1
;
if
(
ret
==
CSTR_EQUAL
)
...
...
@@ -921,7 +921,7 @@ static INT LISTBOX_FindStringPos( LB_DESCR *descr, LPCWSTR str, BOOL exact )
{
index
=
(
min
+
max
)
/
2
;
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
{
COMPAREITEMSTRUCT
cis
;
...
...
@@ -976,13 +976,13 @@ static INT LISTBOX_FindFileStrPos( LB_DESCR *descr, LPCWSTR str )
else
/* directory */
{
if
(
str
[
1
]
==
'-'
)
res
=
1
;
else
res
=
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
p
);
else
res
=
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
p
,
-
1
);
}
}
else
/* filename */
{
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
<
0
)
max
=
index
;
...
...
@@ -1017,7 +1017,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
++
)
{
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
;
}
}
...
...
@@ -1032,11 +1032,11 @@ static INT LISTBOX_FindString( LB_DESCR *descr, INT start, LPCWSTR str, BOOL exa
if
(
index
==
descr
->
nb_items
)
index
=
0
;
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
(
!
wcsnicmp
(
str
,
item_str
+
1
,
len
))
return
index
;
if
(
item_str
[
1
]
==
'-'
&&
!
wcsnicmp
(
str
,
item_str
+
2
,
len
))
return
index
;
if
(
!
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
item_str
+
1
,
len
))
return
index
;
if
(
item_str
[
1
]
==
'-'
&&
!
LISTBOX_lstrcmpiW
(
descr
->
locale
,
str
,
item_str
+
2
,
len
))
return
index
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
dlls/user32/tests/listbox.c
+
78
−
0
View file @
343398d2
...
...
@@ -2421,6 +2421,83 @@ static void test_LBS_NODATA(void)
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
)
{
const
struct
listbox_test
SS
=
...
...
@@ -2520,4 +2597,5 @@ START_TEST(listbox)
test_WM_MEASUREITEM
();
test_LB_SETSEL
();
test_LBS_NODATA
();
test_LB_FINDSTRING
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment