|
From: <xf...@us...> - 2012-05-25 06:20:59
|
Revision: 2525
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2525&view=rev
Author: xfzyr
Date: 2012-05-25 06:20:53 +0000 (Fri, 25 May 2012)
Log Message:
-----------
Support to use "#" in the string content as PCD value.
Signed-off-by: Yurui Zeng <yur...@in...>
Reviewed-by: Liu, Yingke D <yin...@in...>
Modified Paths:
--------------
trunk/BaseTools/Source/Python/Common/String.py
Modified: trunk/BaseTools/Source/Python/Common/String.py
===================================================================
--- trunk/BaseTools/Source/Python/Common/String.py 2012-05-23 01:49:31 UTC (rev 2524)
+++ trunk/BaseTools/Source/Python/Common/String.py 2012-05-25 06:20:53 UTC (rev 2525)
@@ -368,7 +368,7 @@
## CleanString2
#
-# Split comments in a string
+# Split statement with comments in a string
# Remove spaces
#
# @param Line: The string to be cleaned
@@ -387,15 +387,21 @@
if AllowCppStyleComment:
Line = Line.replace(DataType.TAB_COMMENT_EDK_SPLIT, CommentCharacter)
#
- # separate comments and statements
+ # separate comments and statements, but we should escape comment character in string
#
- LineParts = Line.split(CommentCharacter, 1);
- #
- # remove whitespace again
- #
- Line = LineParts[0].strip();
- if len(LineParts) > 1:
- Comment = LineParts[1].strip()
+ InString = False
+ CommentInString = False
+ Comment = ''
+ for Index in range(0, len(Line)):
+ if Line[Index] == '"':
+ InString = not InString
+ elif Line[Index] == CommentCharacter and InString:
+ CommentInString = True
+ elif Line[Index] == CommentCharacter and not InString:
+ Comment = Line[Index:].strip()
+ Line = Line[0:Index].strip()
+ break
+ if Comment:
# Remove prefixed and trailing comment characters
Start = 0
End = len(Comment)
@@ -405,8 +411,6 @@
End -= 1
Comment = Comment[Start:End]
Comment = Comment.strip()
- else:
- Comment = ''
return Line, Comment
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|