[PATCH] comctl32/listview: Use case-insensitive compare in LVM_FINDITEM.
Nikolay Sivov
nsivov at codeweavers.com
Wed Jul 15 09:16:24 CDT 2020
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/comctl32/listview.c | 12 +++++++++---
dlls/comctl32/tests/listview.c | 13 +++++++++++++
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index f1f09d201e0..1e9902fd6c1 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -6292,6 +6292,13 @@ static BOOL LISTVIEW_EnsureVisible(LISTVIEW_INFO *infoPtr, INT nItem, BOOL bPart
return TRUE;
}
+static unsigned int startswithW(const WCHAR *str, const WCHAR *sub)
+{
+ const WCHAR *p1 = str, *p2 = sub;
+ while (*p1 && *p2 && towlower(*p1) == towlower(*p2)) { p1++; p2++; }
+ return !*p2;
+}
+
/***
* DESCRIPTION:
* Searches for an item with specific characteristics.
@@ -6398,12 +6405,11 @@ again:
{
if (lpFindInfo->flags & (LVFI_PARTIAL | LVFI_SUBSTRING))
{
- WCHAR *p = wcsstr(lvItem.pszText, lpFindInfo->psz);
- if (!p || p != lvItem.pszText) continue;
+ if (!startswithW(lvItem.pszText, lpFindInfo->psz)) continue;
}
else
{
- if (lstrcmpW(lvItem.pszText, lpFindInfo->psz) != 0) continue;
+ if (lstrcmpiW(lvItem.pszText, lpFindInfo->psz)) continue;
}
}
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 20b9873d30d..c19de7f03f9 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -5366,6 +5366,19 @@ static void test_finditem(void)
r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
expect(0, r);
+ /* Case sensitivity. */
+ strcpy(f, "Foo");
+ fi.flags = LVFI_STRING;
+ fi.psz = f;
+ r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
+ ok(!r, "Unexpected item index %d.\n", r);
+
+ strcpy(f, "F");
+ fi.flags = LVFI_SUBSTRING;
+ fi.psz = f;
+ r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
+ ok(!r, "Unexpected item index %d.\n", r);
+
DestroyWindow(hwnd);
}
--
2.27.0
More information about the wine-devel
mailing list