]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/String.py
Sync EDKII BaseTools to BaseTools project r1988
[mirror_edk2.git] / BaseTools / Source / Python / Common / String.py
index 1f199fe2ca58ff832185dfea8b4efb342b4a16c7..896fb7da0fb9cd14d60b422267cf72429a276dc8 100644 (file)
@@ -279,9 +279,16 @@ def CleanString(Line, CommentCharacter = DataType.TAB_COMMENT_SPLIT, AllowCppSty
     if AllowCppStyleComment:\r
         Line = Line.replace(DataType.TAB_COMMENT_R8_SPLIT, CommentCharacter)\r
     #\r
-    # remove comments\r
+    # remove comments, but we should escape comment character in string\r
     #\r
-    Line = Line.split(CommentCharacter, 1)[0];\r
+    InString = False\r
+    for Index in range(0, len(Line)):\r
+        if Line[Index] == '"':\r
+            InString = not InString\r
+        elif Line[Index] == CommentCharacter and not InString:\r
+            Line = Line[0: Index]\r
+            break\r
+    \r
     #\r
     # remove whitespace again\r
     #\r