Andrew Nguyen : propsys: Fix comma processing in PSPropertyKeyFromString.

Alexandre Julliard julliard at winehq.org
Wed Jul 28 10:45:07 CDT 2010


Module: wine
Branch: master
Commit: 4c7f9efd16caee6c1641532d8051f2a1882e217e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4c7f9efd16caee6c1641532d8051f2a1882e217e

Author: Andrew Nguyen <anguyen at codeweavers.com>
Date:   Tue Jul 27 02:36:50 2010 -0500

propsys: Fix comma processing in PSPropertyKeyFromString.

---

 dlls/propsys/propsys_main.c  |   59 +++++++++++++++++++++++++++++-------------
 dlls/propsys/tests/propsys.c |   48 ++++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+), 18 deletions(-)

diff --git a/dlls/propsys/propsys_main.c b/dlls/propsys/propsys_main.c
index 35efda8..6c46781 100644
--- a/dlls/propsys/propsys_main.c
+++ b/dlls/propsys/propsys_main.c
@@ -216,7 +216,7 @@ static BOOL string_to_guid(LPCWSTR s, LPGUID id)
 
 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);
 
@@ -233,31 +233,54 @@ HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
     if (!*pszString)
         return E_INVALIDARG;
 
-    /* Only the space seems to be recognized as whitespace. */
-    while (*pszString == ' ')
+    /* Only the space seems to be recognized as whitespace. The comma is only
+     * 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++;
+    }
 
     if (!*pszString)
         return E_INVALIDARG;
 
-    /* Only two minus signs are recognized. The first is ignored, and the
-     * second is interpreted. */
-    if (*pszString == '-')
-        pszString++;
-
-    /* Skip any intermediate spaces after the first minus sign. */
-    while (*pszString == ' ')
-        pszString++;
-
-    if (*pszString == '-')
+    /* Only two minus signs are recognized if no comma is detected. The first
+     * sign is ignored, and the second is interpreted. If a comma is detected
+     * before the minus sign, then only one minus sign counts, and property ID
+     * interpretation begins with the next character. */
+    if (has_comma)
     {
-        has_minus = 1;
-        pszString++;
+        if (*pszString == '-')
+        {
+            has_minus = 1;
+            pszString++;
+        }
     }
+    else
+    {
+        if (*pszString == '-')
+            pszString++;
 
-    /* Skip any remaining spaces after minus sign. */
-    while (*pszString == ' ')
-        pszString++;
+        /* Skip any intermediate spaces after the first minus sign. */
+        while (*pszString == ' ')
+            pszString++;
+
+        if (*pszString == '-')
+        {
+            has_minus = 1;
+            pszString++;
+        }
+
+        /* Skip any remaining spaces after minus sign. */
+        while (*pszString == ' ')
+            pszString++;
+    }
 
     /* Overflow is not checked. */
     while (isdigitW(*pszString))
diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c
index 8c11c42..d734029 100644
--- a/dlls/propsys/tests/propsys.c
+++ b/dlls/propsys/tests/propsys.c
@@ -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','-',
                                                '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};
+    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','-',
                                              '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};
@@ -357,6 +393,18 @@ static void test_PSPropertyKeyFromString(void)
         {fmtid_hexpidW, &out, S_OK, {expect_guid, 0}},
         {fmtid_mixedpidW, &out, S_OK, {expect_guid, 0}},
         {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}},
     };
 




More information about the wine-cvs mailing list