From 2bc3256ca6d439ebf5d85d5e74e5f3e68df14130 Mon Sep 17 00:00:00 2001 From: "Gao, Liming" Date: Fri, 10 Jan 2014 05:25:50 +0000 Subject: Sync BaseTool trunk (version r2640) into EDKII BaseTools. Signed-off-by: Gao, Liming Reviewed-by: Liu, Jiang A git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15089 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/Common/String.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'BaseTools/Source/Python/Common/String.py') diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py index c282326677..04b45a0b83 100644 --- a/BaseTools/Source/Python/Common/String.py +++ b/BaseTools/Source/Python/Common/String.py @@ -401,16 +401,6 @@ def CleanString2(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyl Comment = Line[Index:].strip() Line = Line[0:Index].strip() break - if Comment: - # Remove prefixed and trailing comment characters - Start = 0 - End = len(Comment) - while Start < End and Comment.startswith(CommentCharacter, Start, End): - Start += 1 - while End >= 0 and Comment.endswith(CommentCharacter, Start, End): - End -= 1 - Comment = Comment[Start:End] - Comment = Comment.strip() return Line, Comment @@ -811,11 +801,25 @@ def StringToArray(String): return "{%s, 0x00, 0x00}" % ", ".join(["0x%02x, 0x00" % ord(C) for C in String[2:-1]]) elif String.startswith('"'): if String == "\"\"": - return "{0x00}"; + return "{0x00,0x00}" else: - return "{%s, 0x00}" % ", ".join(["0x%02x" % ord(C) for C in String[1:-1]]) + StringLen = len(String[1:-1]) + if StringLen % 2: + return "{%s, 0x00}" % ", ".join(["0x%02x" % ord(C) for C in String[1:-1]]) + else: + return "{%s, 0x00,0x00}" % ", ".join(["0x%02x" % ord(C) for C in String[1:-1]]) + elif String.startswith('{'): + StringLen = len(String.split(",")) + if StringLen % 2: + return "{%s, 0x00}" % ", ".join([ C for C in String[1:-1].split(',')]) + else: + return "{%s}" % ", ".join([ C for C in String[1:-1].split(',')]) + else: - return '{%s, 0}' % ', '.join(String.split()) + if len(String.split()) % 2: + return '{%s, 0}' % ', '.join(String.split()) + else: + return '{%s, 0,0}' % ', '.join(String.split()) def StringArrayLength(String): if isinstance(String, unicode): -- cgit v1.2.3