Signed-off-by: Jacek Caban jacek@codeweavers.com
---
We should probably handle embedded null bytes, which would require avoiding wcsstr, but the patch has the same limitations as existing implementation, so it's fine for now.
Dmitry Kislyuk dimaki@rocketmail.com writes:
}else {
ret = 0;
BSTR lowstr1, lowstr2;
lowstr1 = SysAllocString(str1);
if(!lowstr1)
return E_OUTOFMEMORY;
lowstr2 = SysAllocString(str2);
if(!lowstr2) {
SysFreeString(lowstr1);
return E_OUTOFMEMORY;
}
for(ptr = lowstr1; *ptr; ptr++)
*ptr = towlower(*ptr);
for(ptr = lowstr2; *ptr; ptr++)
*ptr = towlower(*ptr);
ptr = wcsstr(lowstr1+start, lowstr2);
ret = ptr ? ptr-lowstr1+1 : 0;
SysFreeString(lowstr1);
SysFreeString(lowstr2);
This looks very inefficient. You should be able to use wcsnicmp() or something similar, and avoid duplicating the strings and lower-casing them char by char.