From e8a47801a1dfdb148b1bfcd5bdc8ebc3bf51f92d Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Mon, 18 Nov 2013 07:41:21 +0000 Subject: Sync BaseTool trunk (version r2610) into EDKII BaseTools. Signed-off-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14856 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'BaseTools/Source/Python/PatchPcdValue') diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py index 3f6c575128..69c8244790 100644 --- a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py +++ b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py @@ -72,7 +72,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0): elif TypeName == 'VOID*': if MaxSize == 0: return OPTION_MISSING, "PcdMaxSize is not specified for VOID* type PCD." - ValueLength = MaxSize + ValueLength = int(MaxSize) else: return PARAMETER_INVALID, "PCD type %s is not valid." %(CommandOptions.PcdTypeName) # @@ -97,6 +97,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0): # # Patch value into offset # + SavedStr = ValueString ValueString = ValueString.upper() ValueNumber = 0 if TypeName == 'BOOLEAN': @@ -109,9 +110,9 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0): elif ValueString == 'FALSE': ValueNumber = 0 elif ValueString.startswith('0X'): - ValueNumber = int (Value, 16) + ValueNumber = int (ValueString, 16) else: - ValueNumber = int (Value) + ValueNumber = int (ValueString) if ValueNumber != 0: ValueNumber = 1 except: @@ -138,12 +139,13 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0): ByteList[ValueOffset + Index] = ValueNumber % 0x100 ValueNumber = ValueNumber / 0x100 elif TypeName == 'VOID*': - if ValueString.startswith("L "): + ValueString = SavedStr + if ValueString.startswith('L"'): # # Patch Unicode String # Index = 0 - for ByteString in ValueString[2:]: + for ByteString in ValueString[2:-1]: # # Reserve zero as unicode tail # @@ -177,7 +179,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0): # Patch ascii string # Index = 0 - for ByteString in ValueString: + for ByteString in ValueString[1:-1]: # # Reserve zero as string tail # -- cgit v1.2.3