propsys: Fix comma processing in PSPropertyKeyFromString.
This commit is contained in:
parent
067168b67b
commit
4c7f9efd16
|
@ -216,7 +216,7 @@ static BOOL string_to_guid(LPCWSTR s, LPGUID id)
|
||||||
|
|
||||||
HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
|
HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
|
||||||
{
|
{
|
||||||
int has_minus = 0;
|
int has_minus = 0, has_comma = 0;
|
||||||
|
|
||||||
TRACE("(%s, %p)\n", debugstr_w(pszString), pkey);
|
TRACE("(%s, %p)\n", debugstr_w(pszString), pkey);
|
||||||
|
|
||||||
|
@ -233,31 +233,54 @@ HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
|
||||||
if (!*pszString)
|
if (!*pszString)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
/* Only the space seems to be recognized as whitespace. */
|
/* Only the space seems to be recognized as whitespace. The comma is only
|
||||||
while (*pszString == ' ')
|
* recognized once and processing terminates if another comma is found. */
|
||||||
|
while (*pszString == ' ' || *pszString == ',')
|
||||||
|
{
|
||||||
|
if (*pszString == ',')
|
||||||
|
{
|
||||||
|
if (has_comma)
|
||||||
|
return S_OK;
|
||||||
|
else
|
||||||
|
has_comma = 1;
|
||||||
|
}
|
||||||
pszString++;
|
pszString++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!*pszString)
|
if (!*pszString)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
/* Only two minus signs are recognized. The first is ignored, and the
|
/* Only two minus signs are recognized if no comma is detected. The first
|
||||||
* second is interpreted. */
|
* sign is ignored, and the second is interpreted. If a comma is detected
|
||||||
if (*pszString == '-')
|
* before the minus sign, then only one minus sign counts, and property ID
|
||||||
pszString++;
|
* interpretation begins with the next character. */
|
||||||
|
if (has_comma)
|
||||||
/* Skip any intermediate spaces after the first minus sign. */
|
|
||||||
while (*pszString == ' ')
|
|
||||||
pszString++;
|
|
||||||
|
|
||||||
if (*pszString == '-')
|
|
||||||
{
|
{
|
||||||
has_minus = 1;
|
if (*pszString == '-')
|
||||||
pszString++;
|
{
|
||||||
|
has_minus = 1;
|
||||||
|
pszString++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (*pszString == '-')
|
||||||
|
pszString++;
|
||||||
|
|
||||||
/* Skip any remaining spaces after minus sign. */
|
/* Skip any intermediate spaces after the first minus sign. */
|
||||||
while (*pszString == ' ')
|
while (*pszString == ' ')
|
||||||
pszString++;
|
pszString++;
|
||||||
|
|
||||||
|
if (*pszString == '-')
|
||||||
|
{
|
||||||
|
has_minus = 1;
|
||||||
|
pszString++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skip any remaining spaces after minus sign. */
|
||||||
|
while (*pszString == ' ')
|
||||||
|
pszString++;
|
||||||
|
}
|
||||||
|
|
||||||
/* Overflow is not checked. */
|
/* Overflow is not checked. */
|
||||||
while (isdigitW(*pszString))
|
while (isdigitW(*pszString))
|
||||||
|
|
|
@ -290,6 +290,42 @@ static void test_PSPropertyKeyFromString(void)
|
||||||
static const WCHAR fmtid_overflowpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
static const WCHAR fmtid_overflowpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
'1','2','3','4','-','1','2','3','4','-',
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','2','3','4','5','6','7','8','9','0','1',0};
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','2','3','4','5','6','7','8','9','0','1',0};
|
||||||
|
static const WCHAR fmtid_commapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',',','1','3','5','7','9',0};
|
||||||
|
static const WCHAR fmtid_commaspidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',',',',',',','1','3','5','7','9',0};
|
||||||
|
static const WCHAR fmtid_commaspacepidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',',',' ','1','3','5','7','9',0};
|
||||||
|
static const WCHAR fmtid_spacecommapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',','1','3','5','7','9',0};
|
||||||
|
static const WCHAR fmtid_spccommaspcpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ','1','3','5','7','9',0};
|
||||||
|
static const WCHAR fmtid_spacescommaspidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ',',','1','3','5','7','9',0};
|
||||||
|
static const WCHAR fmtid_commanegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',',','-','1','3','5','7','9',0};
|
||||||
|
static const WCHAR fmtid_spccommanegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',','-','1','3','5','7','9',0};
|
||||||
|
static const WCHAR fmtid_commaspcnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',',',' ','-','1','3','5','7','9',0};
|
||||||
|
static const WCHAR fmtid_spccommaspcnegpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ',',',' ','-','1','3','5','7','9',0};
|
||||||
|
static const WCHAR fmtid_commanegspcpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',',','-',' ','1','3','5','7','9',0};
|
||||||
|
static const WCHAR fmtid_negcommapidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
|
'1','2','3','4','5','6','7','8','9','0','1','2','}','-',',','1','3','5','7','9',0};
|
||||||
static const WCHAR fmtid_normalpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
static const WCHAR fmtid_normalpidW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
|
||||||
'1','2','3','4','-','1','2','3','4','-',
|
'1','2','3','4','-','1','2','3','4','-',
|
||||||
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','3','5','7','9',0};
|
'1','2','3','4','5','6','7','8','9','0','1','2','}',' ','1','3','5','7','9',0};
|
||||||
|
@ -357,6 +393,18 @@ static void test_PSPropertyKeyFromString(void)
|
||||||
{fmtid_hexpidW, &out, S_OK, {expect_guid, 0}},
|
{fmtid_hexpidW, &out, S_OK, {expect_guid, 0}},
|
||||||
{fmtid_mixedpidW, &out, S_OK, {expect_guid, 0}},
|
{fmtid_mixedpidW, &out, S_OK, {expect_guid, 0}},
|
||||||
{fmtid_overflowpidW, &out, S_OK, {expect_guid, 3755744309U}},
|
{fmtid_overflowpidW, &out, S_OK, {expect_guid, 3755744309U}},
|
||||||
|
{fmtid_commapidW, &out, S_OK, {expect_guid, 13579}},
|
||||||
|
{fmtid_commaspidW, &out, S_OK, {expect_guid, 0}},
|
||||||
|
{fmtid_commaspacepidW, &out, S_OK, {expect_guid, 13579}},
|
||||||
|
{fmtid_spacecommapidW, &out, S_OK, {expect_guid, 13579}},
|
||||||
|
{fmtid_spccommaspcpidW, &out, S_OK, {expect_guid, 13579}},
|
||||||
|
{fmtid_spacescommaspidW, &out, S_OK, {expect_guid, 0}},
|
||||||
|
{fmtid_commanegpidW, &out, S_OK, {expect_guid, 4294953717U}},
|
||||||
|
{fmtid_spccommanegpidW, &out, S_OK, {expect_guid, 4294953717U}},
|
||||||
|
{fmtid_commaspcnegpidW, &out, S_OK, {expect_guid, 4294953717U}},
|
||||||
|
{fmtid_spccommaspcnegpidW, &out, S_OK, {expect_guid, 4294953717U}},
|
||||||
|
{fmtid_commanegspcpidW, &out, S_OK, {expect_guid, 0U}},
|
||||||
|
{fmtid_negcommapidW, &out, S_OK, {expect_guid, 0}},
|
||||||
{fmtid_normalpidW, &out, S_OK, {expect_guid, 13579}},
|
{fmtid_normalpidW, &out, S_OK, {expect_guid, 13579}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue