public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Fix the bug that use '|' or '||' in DSC file's Pcd value
@ 2017-06-20  8:04 Yonghong Zhu
  2017-06-23  8:12 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2017-06-20  8:04 UTC (permalink / raw)
  To: edk2-devel; +Cc: Yunhua Feng, Liming Gao

From: Yunhua Feng <yunhuax.feng@intel.com>

Fix the bug to support use '|' or '||' in DSC file's Pcd value.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
 BaseTools/Source/Python/Common/String.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py
index 5c8d1e0..81c053d 100644
--- a/BaseTools/Source/Python/Common/String.py
+++ b/BaseTools/Source/Python/Common/String.py
@@ -44,16 +44,17 @@ gHumanReadableVerPatt = re.compile(r'([1-9][0-9]*|0)\.[0-9]{1,2}$')
 def GetSplitValueList(String, SplitTag=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
     ValueList = []
     Last = 0
     Escaped = False
     InString = False
+    InParenthesis = 0
     for Index in range(0, len(String)):
         Char = String[Index]
 
         if not Escaped:
             # Found a splitter not in a string, split it
-            if not InString and Char == SplitTag:
+            if not InString and InParenthesis == 0 and Char == SplitTag:
                 ValueList.append(String[Last:Index].strip())
                 Last = Index + 1
                 if MaxSplit > 0 and len(ValueList) >= MaxSplit:
                     break
 
@@ -62,10 +63,14 @@ def GetSplitValueList(String, SplitTag=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
             elif Char == '"':
                 if not InString:
                     InString = True
                 else:
                     InString = False
+            elif Char == '(':
+                InParenthesis = InParenthesis + 1
+            elif Char == ')':
+                InParenthesis = InParenthesis - 1
         else:
             Escaped = False
 
     if Last < len(String):
         ValueList.append(String[Last:].strip())
-- 
2.6.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] BaseTools: Fix the bug that use '|' or '||' in DSC file's Pcd value
  2017-06-20  8:04 [Patch] BaseTools: Fix the bug that use '|' or '||' in DSC file's Pcd value Yonghong Zhu
@ 2017-06-23  8:12 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2017-06-23  8:12 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org; +Cc: Feng, YunhuaX

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Zhu, Yonghong
>Sent: Tuesday, June 20, 2017 4:05 PM
>To: edk2-devel@lists.01.org
>Cc: Feng, YunhuaX <yunhuax.feng@intel.com>; Gao, Liming
><liming.gao@intel.com>
>Subject: [Patch] BaseTools: Fix the bug that use '|' or '||' in DSC file's Pcd value
>
>From: Yunhua Feng <yunhuax.feng@intel.com>
>
>Fix the bug to support use '|' or '||' in DSC file's Pcd value.
>
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Yonghong Zhu <yonghong.zhu@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
>---
> BaseTools/Source/Python/Common/String.py | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
>diff --git a/BaseTools/Source/Python/Common/String.py
>b/BaseTools/Source/Python/Common/String.py
>index 5c8d1e0..81c053d 100644
>--- a/BaseTools/Source/Python/Common/String.py
>+++ b/BaseTools/Source/Python/Common/String.py
>@@ -44,16 +44,17 @@ gHumanReadableVerPatt = re.compile(r'([1-9][0-
>9]*|0)\.[0-9]{1,2}$')
> def GetSplitValueList(String, SplitTag=DataType.TAB_VALUE_SPLIT, MaxSplit=
>-1):
>     ValueList = []
>     Last = 0
>     Escaped = False
>     InString = False
>+    InParenthesis = 0
>     for Index in range(0, len(String)):
>         Char = String[Index]
>
>         if not Escaped:
>             # Found a splitter not in a string, split it
>-            if not InString and Char == SplitTag:
>+            if not InString and InParenthesis == 0 and Char == SplitTag:
>                 ValueList.append(String[Last:Index].strip())
>                 Last = Index + 1
>                 if MaxSplit > 0 and len(ValueList) >= MaxSplit:
>                     break
>
>@@ -62,10 +63,14 @@ def GetSplitValueList(String,
>SplitTag=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
>             elif Char == '"':
>                 if not InString:
>                     InString = True
>                 else:
>                     InString = False
>+            elif Char == '(':
>+                InParenthesis = InParenthesis + 1
>+            elif Char == ')':
>+                InParenthesis = InParenthesis - 1
>         else:
>             Escaped = False
>
>     if Last < len(String):
>         ValueList.append(String[Last:].strip())
>--
>2.6.1.windows.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-23  8:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-20  8:04 [Patch] BaseTools: Fix the bug that use '|' or '||' in DSC file's Pcd value Yonghong Zhu
2017-06-23  8:12 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox