shlwapi: Fix incorrect usage of CompareString in StrRStrIW.

This commit is contained in:
Sebastian Lackner 2014-11-19 08:31:40 +01:00 committed by Alexandre Julliard
parent 80d98683d0
commit 1b672e55ce

View File

@ -625,6 +625,7 @@ LPSTR WINAPI StrRStrIA(LPCSTR lpszStr, LPCSTR lpszEnd, LPCSTR lpszSearch)
*/ */
LPWSTR WINAPI StrRStrIW(LPCWSTR lpszStr, LPCWSTR lpszEnd, LPCWSTR lpszSearch) LPWSTR WINAPI StrRStrIW(LPCWSTR lpszStr, LPCWSTR lpszEnd, LPCWSTR lpszSearch)
{ {
LPWSTR lpszRet = NULL;
INT iLen; INT iLen;
TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSearch)); 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) if (!lpszStr || !lpszSearch || !*lpszSearch)
return NULL; return NULL;
if (!lpszEnd)
lpszEnd = lpszStr + strlenW(lpszStr);
iLen = strlenW(lpszSearch); iLen = strlenW(lpszSearch);
while (lpszEnd > lpszStr) if (!lpszEnd)
lpszEnd = lpszStr + strlenW(lpszStr);
else /* reproduce the broken behaviour on Windows */
lpszEnd += min(iLen - 1, lstrlenW(lpszEnd));
while (lpszStr + iLen <= lpszEnd && *lpszStr)
{ {
lpszEnd--; if (!ChrCmpIW(*lpszSearch, *lpszStr))
if (!StrCmpNIW(lpszEnd, lpszSearch, iLen)) {
return (LPWSTR)lpszEnd; if (!StrCmpNIW(lpszStr, lpszSearch, iLen))
lpszRet = (LPWSTR)lpszStr;
} }
return NULL; lpszStr++;
}
return lpszRet;
} }
/************************************************************************* /*************************************************************************