Nikolay Sivov : comctl32/listview: Use case-insensitive compare in LVM_FINDITEM.

Alexandre Julliard julliard at winehq.org
Thu Jul 16 19:01:21 CDT 2020


Module: wine
Branch: master
Commit: ab81945d6568569ac23fad56b1bc895687feeb55
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ab81945d6568569ac23fad56b1bc895687feeb55

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Jul 16 13:38:21 2020 +0300

comctl32/listview: Use case-insensitive compare in LVM_FINDITEM.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/Makefile.in      |  2 +-
 dlls/comctl32/listview.c       | 10 +++++++---
 dlls/comctl32/tests/listview.c | 13 +++++++++++++
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/Makefile.in b/dlls/comctl32/Makefile.in
index e548d3761a..4ea068ea73 100644
--- a/dlls/comctl32/Makefile.in
+++ b/dlls/comctl32/Makefile.in
@@ -1,7 +1,7 @@
 EXTRADEFS = -D_COMCTL32_
 MODULE    = comctl32.dll
 IMPORTLIB = comctl32
-IMPORTS   = uuid user32 gdi32 advapi32 usp10 imm32
+IMPORTS   = uuid user32 gdi32 advapi32 usp10 imm32 kernelbase
 DELAYIMPORTS = winmm uxtheme
 
 EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 1092a6ce9b..6cee291dd6 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -140,6 +140,7 @@
 #include "commctrl.h"
 #include "comctl32.h"
 #include "uxtheme.h"
+#include "shlwapi.h"
 
 #include "wine/debug.h"
 
@@ -6313,6 +6314,7 @@ static INT LISTVIEW_FindItemW(const LISTVIEW_INFO *infoPtr, INT nStart,
     INT nItem = nStart + 1, nLast = infoPtr->nItemCount, nNearestItem = -1;
     ULONG xdist, ydist, dist, mindist = 0x7fffffff;
     POINT Position, Destination;
+    int search_len = 0;
     LVITEMW lvItem;
 
     /* Search in virtual listviews should be done by application, not by
@@ -6378,6 +6380,9 @@ static INT LISTVIEW_FindItemW(const LISTVIEW_INFO *infoPtr, INT nStart,
 
     nItem = bNearest ? -1 : nStart + 1;
 
+    if (lpFindInfo->flags & (LVFI_PARTIAL | LVFI_SUBSTRING))
+        search_len = lstrlenW(lpFindInfo->psz);
+
 again:
     for (; nItem < nLast; nItem++)
     {
@@ -6398,12 +6403,11 @@ again:
 	{
             if (lpFindInfo->flags & (LVFI_PARTIAL | LVFI_SUBSTRING))
             {
-		WCHAR *p = wcsstr(lvItem.pszText, lpFindInfo->psz);
-		if (!p || p != lvItem.pszText) continue;
+                if (StrCmpNIW(lvItem.pszText, lpFindInfo->psz, search_len)) continue;
             }
             else
             {
-            	if (lstrcmpW(lvItem.pszText, lpFindInfo->psz) != 0) continue;
+                if (StrCmpIW(lvItem.pszText, lpFindInfo->psz)) continue;
             }
 	}
 
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 20b9873d30..c19de7f03f 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);
 }
 




More information about the wine-cvs mailing list