Sebastian Lackner : shlwapi: Fix incorrect usage of CompareString in StrRStrIW.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Nov 19 10:07:50 CST 2014
Module: wine
Branch: master
Commit: 1b672e55ce738c5e02bd8c77df5dbf4668b7e30f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1b672e55ce738c5e02bd8c77df5dbf4668b7e30f
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Wed Nov 19 08:31:40 2014 +0100
shlwapi: Fix incorrect usage of CompareString in StrRStrIW.
---
dlls/shlwapi/string.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c
index 316dd3f..9ba6038 100644
--- a/dlls/shlwapi/string.c
+++ b/dlls/shlwapi/string.c
@@ -625,6 +625,7 @@ LPSTR WINAPI StrRStrIA(LPCSTR lpszStr, LPCSTR lpszEnd, LPCSTR lpszSearch)
*/
LPWSTR WINAPI StrRStrIW(LPCWSTR lpszStr, LPCWSTR lpszEnd, LPCWSTR lpszSearch)
{
+ LPWSTR lpszRet = NULL;
INT iLen;
TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSearch));
@@ -632,18 +633,23 @@ LPWSTR WINAPI StrRStrIW(LPCWSTR lpszStr, LPCWSTR lpszEnd, LPCWSTR lpszSearch)
if (!lpszStr || !lpszSearch || !*lpszSearch)
return NULL;
+ iLen = strlenW(lpszSearch);
+
if (!lpszEnd)
lpszEnd = lpszStr + strlenW(lpszStr);
+ else /* reproduce the broken behaviour on Windows */
+ lpszEnd += min(iLen - 1, lstrlenW(lpszEnd));
- iLen = strlenW(lpszSearch);
-
- while (lpszEnd > lpszStr)
+ while (lpszStr + iLen <= lpszEnd && *lpszStr)
{
- lpszEnd--;
- if (!StrCmpNIW(lpszEnd, lpszSearch, iLen))
- return (LPWSTR)lpszEnd;
+ if (!ChrCmpIW(*lpszSearch, *lpszStr))
+ {
+ if (!StrCmpNIW(lpszStr, lpszSearch, iLen))
+ lpszRet = (LPWSTR)lpszStr;
+ }
+ lpszStr++;
}
- return NULL;
+ return lpszRet;
}
/*************************************************************************
More information about the wine-cvs
mailing list