>From bb30e29d27b1d35a56b97a4c70a484eaaa1237f9 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov@codeweavers.com>
Date: Wed, 25 Jan 2012 10:57:20 +0300
Subject: [PATCH 2/2] Use simple helper for case insensitive strstr()

---
 dlls/shell32/autocomplete.c |   19 +++++++++++++++----
 dlls/shell32/shell32_main.h |    9 +++++++++
 dlls/shell32/shelllink.c    |   10 ----------
 3 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index 8823262..118d578 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -93,9 +93,20 @@ static inline IAutoCompleteImpl *impl_from_IAutoCompleteDropDown(IAutoCompleteDr
     return CONTAINING_RECORD(iface, IAutoCompleteImpl, IAutoCompleteDropDown_iface);
 }
 
-/*
-  Window procedure for autocompletion
- */
+static WCHAR *strstriW( const WCHAR *str, const WCHAR *sub )
+{
+    LPWSTR strlower, sublower, r;
+    strlower = strlwrW(strdupW(str));
+    sublower = strlwrW(strdupW(sub));
+    r = strstrW(strlower, sublower);
+    if (r)
+        r = (LPWSTR)str + (r - strlower);
+    HeapFree(GetProcessHeap(), 0, strlower);
+    HeapFree(GetProcessHeap(), 0, sublower);
+    return r;
+}
+
+/* Window procedure for autocompletion */
 static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
     IAutoCompleteImpl *This = GetPropW(hwnd, autocomplete_propertyW);
@@ -223,7 +234,7 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
                 if (hr != S_OK)
                     break;
 
-                if (StrStrIW(strs, hwndText) == strs) {
+                if (strstriW(strs, hwndText) == strs) {
                     if (!filled && (This->options & ACO_AUTOAPPEND)) {
                         INT typed_length = strlenW(hwndText);
                         WCHAR buffW[255];
diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h
index ece1863..d649082 100644
--- a/dlls/shell32/shell32_main.h
+++ b/dlls/shell32/shell32_main.h
@@ -191,6 +191,15 @@ static inline WCHAR * __SHCloneStrAtoW(WCHAR ** target, const char * source)
 	return *target;
 }
 
+static inline LPWSTR strdupW( LPCWSTR src )
+{
+    LPWSTR dest;
+    if (!src) return NULL;
+    dest = HeapAlloc( GetProcessHeap(), 0, (strlenW(src)+1)*sizeof(WCHAR) );
+    if (dest)
+        strcpyW(dest, src);
+    return dest;
+}
 
 extern WCHAR swShell32Name[MAX_PATH] DECLSPEC_HIDDEN;
 
diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c
index e325e2e..04d2907 100644
--- a/dlls/shell32/shelllink.c
+++ b/dlls/shell32/shelllink.c
@@ -218,16 +218,6 @@ static inline LPWSTR HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str)
     return p;
 }
 
-static inline LPWSTR strdupW( LPCWSTR src )
-{
-    LPWSTR dest;
-    if (!src) return NULL;
-    dest = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(src)+1)*sizeof(WCHAR) );
-    if (dest)
-        lstrcpyW(dest, src);
-    return dest;
-}
-
 /**************************************************************************
  *  ShellLink::QueryInterface implementation
  */
-- 
1.5.6.5

