Module: wine Branch: master Commit: 735e2cd7749b4d4aa1b46a6d2c6f4b54bd4efb33 URL: http://source.winehq.org/git/wine.git/?a=commit;h=735e2cd7749b4d4aa1b46a6d2c...
Author: Sebastian Lackner sebastian@fds-team.de Date: Wed Nov 19 08:36:22 2014 +0100
comctl32: Allow broken behaviour in StrRStr functions.
---
dlls/comctl32/string.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/dlls/comctl32/string.c b/dlls/comctl32/string.c index 5e28b8f..112d9d3 100644 --- a/dlls/comctl32/string.c +++ b/dlls/comctl32/string.c @@ -674,18 +674,20 @@ LPSTR WINAPI StrRStrIA(LPCSTR lpszStr, LPCSTR lpszEnd, LPCSTR lpszSearch) if (!lpszStr || !lpszSearch || !*lpszSearch) return NULL;
- if (!lpszEnd) - lpszEnd = lpszStr + lstrlenA(lpszStr); - if (IsDBCSLeadByte(*lpszSearch)) - ch1 = *lpszSearch << 8 | lpszSearch[1]; + ch1 = *lpszSearch << 8 | (UCHAR)lpszSearch[1]; else ch1 = *lpszSearch; iLen = lstrlenA(lpszSearch);
+ if (!lpszEnd) + lpszEnd = lpszStr + lstrlenA(lpszStr); + else /* reproduce the broken behaviour on Windows */ + lpszEnd += min(iLen - 1, lstrlenA(lpszEnd)); + while (lpszStr + iLen <= lpszEnd && *lpszStr) { - ch2 = IsDBCSLeadByte(*lpszStr)? *lpszStr << 8 | lpszStr[1] : *lpszStr; + ch2 = IsDBCSLeadByte(*lpszStr)? *lpszStr << 8 | (UCHAR)lpszStr[1] : *lpszStr; if (!COMCTL32_ChrCmpIA(ch1, ch2)) { if (!StrCmpNIA(lpszStr, lpszSearch, iLen)) @@ -711,10 +713,13 @@ 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 (lpszStr + iLen <= lpszEnd && *lpszStr) {