[PATCH] vbscript: implement case insensitive comparison functionality in InStr
Alexandre Julliard
julliard at winehq.org
Thu Jul 23 12:40:52 CDT 2020
Dmitry Kislyuk <dimaki at 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.
--
Alexandre Julliard
julliard at winehq.org
More information about the wine-devel
mailing list