Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
8ec39067
Commit
8ec39067
authored
Dec 05, 2005
by
Michael Stefaniuc
Committed by
Alexandre Julliard
Dec 05, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix VarBstrCmp for NULL input BSTRs (MSDN is wrong).
parent
58e156b5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
10 deletions
+40
-10
vartype.c
dlls/oleaut32/tests/vartype.c
+32
-0
vartype.c
dlls/oleaut32/vartype.c
+8
-10
No files found.
dlls/oleaut32/tests/vartype.c
View file @
8ec39067
...
...
@@ -516,6 +516,7 @@ static HRESULT (WINAPI *pVarBoolFromUI8)(ULONG64,VARIANT_BOOL*);
static
HRESULT
(
WINAPI
*
pVarBstrFromR4
)(
FLOAT
,
LCID
,
ULONG
,
BSTR
*
);
static
HRESULT
(
WINAPI
*
pVarBstrFromDate
)(
DATE
,
LCID
,
ULONG
,
BSTR
*
);
static
HRESULT
(
WINAPI
*
pVarBstrFromDec
)(
DECIMAL
*
,
LCID
,
ULONG
,
BSTR
*
);
static
HRESULT
(
WINAPI
*
pVarBstrCmp
)(
BSTR
,
BSTR
,
LCID
,
ULONG
);
static
HRESULT
(
WINAPI
*
pVarCmp
)(
LPVARIANT
,
LPVARIANT
,
LCID
,
ULONG
);
...
...
@@ -4960,6 +4961,36 @@ static void test_VarBstrFromDec(void)
#undef BSTR_DEC
#undef BSTR_DEC64
#define _VARBSTRCMP(left,right,lcid,flags,result) \
hres = pVarBstrCmp(left,right,lcid,flags); \
ok(hres == result, "VarBstrCmp: expected " #result ", got hres=0x%lx\n", hres)
#define VARBSTRCMP(left,right,result) \
_VARBSTRCMP(left,right,lcid,0,result)
static
void
test_VarBstrCmp
(
void
)
{
LCID
lcid
;
HRESULT
hres
;
static
const
WCHAR
sz
[]
=
{
'W'
,
'u'
,
'r'
,
's'
,
'c'
,
'h'
,
't'
,
'\0'
};
static
const
WCHAR
szempty
[]
=
{
'\0'
};
BSTR
bstr
,
bstrempty
;
CHECKPTR
(
VarBstrCmp
);
lcid
=
MAKELCID
(
MAKELANGID
(
LANG_ENGLISH
,
SUBLANG_ENGLISH_US
),
SORT_DEFAULT
);
bstr
=
SysAllocString
(
sz
);
bstrempty
=
SysAllocString
(
szempty
);
/* NULL handling. Yepp, MSDN is totaly wrong here */
VARBSTRCMP
(
NULL
,
NULL
,
VARCMP_EQ
);
VARBSTRCMP
(
bstr
,
NULL
,
VARCMP_GT
);
VARBSTRCMP
(
NULL
,
bstr
,
VARCMP_LT
);
/* NULL and empty string comparisions */
VARBSTRCMP
(
bstrempty
,
NULL
,
VARCMP_EQ
);
VARBSTRCMP
(
NULL
,
bstrempty
,
VARCMP_EQ
);
}
/* Get the internal representation of a BSTR */
static
inline
LPINTERNAL_BSTR
Get
(
const
BSTR
lpszString
)
{
...
...
@@ -5968,6 +5999,7 @@ START_TEST(vartype)
test_VarBstrFromR4
();
test_VarBstrFromDate
();
test_VarBstrFromDec
();
test_VarBstrCmp
();
test_SysStringLen
();
test_SysStringByteLen
();
test_SysAllocString
();
...
...
dlls/oleaut32/vartype.c
View file @
8ec39067
...
...
@@ -6599,23 +6599,21 @@ HRESULT WINAPI VarBstrCat(BSTR pbstrLeft, BSTR pbstrRight, BSTR *pbstrOut)
* RETURNS
* VARCMP_LT, VARCMP_EQ or VARCMP_GT indicating that pbstrLeft is less
* than, equal to or greater than pbstrRight respectively.
* VARCMP_NULL is returned if either string is NULL, unless both are NULL
* in which case VARCMP_EQ is returned.
*
* NOTES
* VARCMP_NULL is NOT returned if either string is NULL unlike MSDN
* states. A NULL BSTR pointer is equivalent to an empty string.
*/
HRESULT
WINAPI
VarBstrCmp
(
BSTR
pbstrLeft
,
BSTR
pbstrRight
,
LCID
lcid
,
DWORD
dwFlags
)
{
if
(
!
pbstrLeft
)
if
(
!
pbstrLeft
||
!*
pbstrLeft
)
{
if
(
!
pbstrRight
||
!*
pbstrRight
)
return
VARCMP_EQ
;
return
VARCMP_NULL
;
}
else
if
(
!
pbstrRight
)
{
if
(
!*
pbstrLeft
)
return
VARCMP_EQ
;
return
VARCMP_NULL
;
return
VARCMP_LT
;
}
else
if
(
!
pbstrRight
||
!*
pbstrRight
)
return
VARCMP_GT
;
return
CompareStringW
(
lcid
,
dwFlags
,
pbstrLeft
,
-
1
,
pbstrRight
,
-
1
)
-
1
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment