Module: wine Branch: master Commit: 2b2ee9c7d1c8d1d1e79b06e8761b9e0a6e1e65bd URL: http://source.winehq.org/git/wine.git/?a=commit;h=2b2ee9c7d1c8d1d1e79b06e876...
Author: Charles Blacklock charles@diagnos.co.uk Date: Thu Nov 30 15:55:14 2006 +0000
oleaut32: Add VarBstrCmp binary comparison for LCID==0.
---
dlls/oleaut32/tests/vartype.c | 12 ++++++++++++ dlls/oleaut32/vartype.c | 26 ++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c index 666516f..57de5ce 100644 --- a/dlls/oleaut32/tests/vartype.c +++ b/dlls/oleaut32/tests/vartype.c @@ -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 */ diff --git a/dlls/oleaut32/vartype.c b/dlls/oleaut32/vartype.c index 57239a4..353a845 100644 --- a/dlls/oleaut32/vartype.c +++ b/dlls/oleaut32/vartype.c @@ -6630,10 +6630,12 @@ HRESULT WINAPI VarBstrCat(BSTR pbstrLeft * 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 else if (!pbstrRight || !*pbstrRight) return VARCMP_GT;
- hres = CompareStringW(lcid, dwFlags, pbstrLeft, SysStringLen(pbstrLeft), - pbstrRight, SysStringLen(pbstrRight)) - 1; - TRACE("%d\n", hres); - return hres; + 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; + } }
/*