On 10/04/12 08:03, Mieczyslaw Nalewaj wrote:
> +static BOOL strings_equal(LPWSTR lpString1, const WCHAR *lpString2)
> +{
> + int cchCount;
Please avoid Hungarian style variable names. Also is seems like the
function not exactly compares strings, so something like is_subkey could
be more appropriate function name.
> + if ((!lpString1 || !*lpString1) && (!lpString2 || !*lpString2)) /* both empty */
> + return TRUE;
> + if ( !lpString1 || !*lpString1 || !lpString2 || !*lpString2 ) /* one empty */
> + return FALSE;
How about simplifying it to:
if(!str1 || !*str1)
return !str2 || !*str2;
if(!str2 || !*str2)
return FALSE;
> + cchCount = strlenW(lpString2);
> + if (strlenW(lpString1)<cchCount) /* too short */
> + return FALSE;
> +
> + if ( (CompareStringW(CP_ACP,NORM_IGNORECASE,lpString1,cchCount,lpString2,cchCount)==CSTR_EQUAL)
> + && ((lpString1[cchCount] == 0) || (lpString1[cchCount] == (WCHAR){'\\'})))
> + return TRUE;
> + else
> + return FALSE;
This could be simplified:
len = strlenW(str2);
return !strncmpiW(str1, str2, len) && (!str1[len] || str1[len] == '\\');
Cheers,
Jacek