]> 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 5da0cacfb01638efd77c61cd80e1a0f20cbe2800..896fb7da0fb9cd14d60b422267cf72429a276dc8 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # This file is used to define common string related functions used in parsing process\r
 #\r
-# Copyright (c) 2007 ~ 2008, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
@@ -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