oleaut32: Add VarBstrCmp binary comparison for LCID==0.
This commit is contained in:
parent
70ce548566
commit
2b2ee9c7d1
|
@ -4911,6 +4911,8 @@ static void test_VarBstrCmp(void)
|
|||
static const WCHAR sz2[] = { 'A',0 };
|
||||
static const WCHAR s1[] = { 'a',0 };
|
||||
static const WCHAR s2[] = { 'a',0,'b' };
|
||||
static const char sb1[] = {1,0,1};
|
||||
static const char sb2[] = {1,0,2};
|
||||
BSTR bstr, bstrempty, bstr2;
|
||||
|
||||
CHECKPTR(VarBstrCmp);
|
||||
|
@ -4948,6 +4950,16 @@ static void test_VarBstrCmp(void)
|
|||
SysFreeString(bstr2);
|
||||
|
||||
SysFreeString(bstr);
|
||||
|
||||
/* When (LCID == 0) it should be a binary comparison
|
||||
* so these two strings could not match.
|
||||
*/
|
||||
bstr = SysAllocStringByteLen(sb1, sizeof(sb1));
|
||||
bstr2 = SysAllocStringByteLen(sb2, sizeof(sb2));
|
||||
lcid = 0;
|
||||
VARBSTRCMP(bstr,bstr2,0,VARCMP_LT);
|
||||
SysFreeString(bstr2);
|
||||
SysFreeString(bstr);
|
||||
}
|
||||
|
||||
/* Get the internal representation of a BSTR */
|
||||
|
|
|
@ -6630,10 +6630,12 @@ HRESULT WINAPI VarBstrCat(BSTR pbstrLeft, BSTR pbstrRight, BSTR *pbstrOut)
|
|||
* NOTES
|
||||
* VARCMP_NULL is NOT returned if either string is NULL unlike MSDN
|
||||
* states. A NULL BSTR pointer is equivalent to an empty string.
|
||||
* If LCID is equal to 0, a byte by byte comparison is performed.
|
||||
*/
|
||||
HRESULT WINAPI VarBstrCmp(BSTR pbstrLeft, BSTR pbstrRight, LCID lcid, DWORD dwFlags)
|
||||
{
|
||||
HRESULT hres;
|
||||
int ret;
|
||||
|
||||
TRACE("%s,%s,%d,%08x\n",
|
||||
debugstr_wn(pbstrLeft, SysStringLen(pbstrLeft)),
|
||||
|
@ -6648,10 +6650,26 @@ HRESULT WINAPI VarBstrCmp(BSTR pbstrLeft, BSTR pbstrRight, LCID lcid, DWORD dwFl
|
|||
else if (!pbstrRight || !*pbstrRight)
|
||||
return VARCMP_GT;
|
||||
|
||||
if (lcid == 0)
|
||||
{
|
||||
ret = memcmp(pbstrLeft, pbstrRight, min(SysStringByteLen(pbstrLeft), SysStringByteLen(pbstrRight)));
|
||||
if (ret < 0)
|
||||
return VARCMP_LT;
|
||||
if (ret > 0)
|
||||
return VARCMP_GT;
|
||||
if (SysStringByteLen(pbstrLeft) < SysStringByteLen(pbstrRight))
|
||||
return VARCMP_LT;
|
||||
if (SysStringByteLen(pbstrLeft) > SysStringByteLen(pbstrRight))
|
||||
return VARCMP_GT;
|
||||
return VARCMP_EQ;
|
||||
}
|
||||
else
|
||||
{
|
||||
hres = CompareStringW(lcid, dwFlags, pbstrLeft, SysStringLen(pbstrLeft),
|
||||
pbstrRight, SysStringLen(pbstrRight)) - 1;
|
||||
TRACE("%d\n", hres);
|
||||
return hres;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue