\r
self._GenOffsetValue ()\r
\r
- ## Analyze the string value to judge the PCD's datum type euqal to Boolean or not.\r
+ ## Analyze the string value to judge the PCD's datum type equal to Boolean or not.\r
# \r
# @param ValueString PCD's value\r
# @param Size PCD's size\r
## Pack VOID* type VPD PCD's value form string to binary type.\r
#\r
# The VOID* type of string divided into 3 sub-type:\r
- # 1: L"String", Unicode type string.\r
- # 2: "String", Ascii type string.\r
+ # 1: L"String"/L'String', Unicode type string.\r
+ # 2: "String"/'String', Ascii type string.\r
# 3: {bytearray}, only support byte-array.\r
#\r
# @param ValueString The Integer type string for pack.\r
# \r
def _PackPtrValue(self, ValueString, Size):\r
- if ValueString.startswith('L"'):\r
+ if ValueString.startswith('L"') or ValueString.startswith("L'"):\r
self._PackUnicode(ValueString, Size)\r
elif ValueString.startswith('{') and ValueString.endswith('}'):\r
self._PackByteArray(ValueString, Size)\r
- elif ValueString.startswith('"') and ValueString.endswith('"'):\r
+ elif (ValueString.startswith('"') and ValueString.endswith('"')) or (ValueString.startswith("'") and ValueString.endswith("'")):\r
self._PackString(ValueString, Size)\r
else:\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,\r
\r
## Pack an Ascii PCD value.\r
# \r
- # An Ascii string for a PCD should be in format as "".\r
+ # An Ascii string for a PCD should be in format as ""/''.\r
# \r
def _PackString(self, ValueString, Size):\r
if (Size < 0):\r
"Invalid parameter Size %s of PCD %s!(File: %s Line: %s)" % (self.PcdBinSize, self.PcdCName, self.FileName, self.Lineno))\r
if (ValueString == ""):\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter ValueString %s of PCD %s!(File: %s Line: %s)" % (self.PcdUnpackValue, self.PcdCName, self.FileName, self.Lineno))\r
- if (len(ValueString) < 2):\r
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "For PCD: %s ,ASCII string %s at least contains two!(File: %s Line: %s)" % (self.PcdCName, self.PcdUnpackValue, self.FileName, self.Lineno))\r
+\r
+ QuotedFlag = True\r
+ if ValueString.startswith("'"):\r
+ QuotedFlag = False\r
\r
ValueString = ValueString[1:-1]\r
- if len(ValueString) + 1 > Size:\r
+ # No null-terminator in 'string' \r
+ if (QuotedFlag and len(ValueString) + 1 > Size) or (not QuotedFlag and len(ValueString) > Size):\r
EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW,\r
"PCD value string %s is exceed to size %d(File: %s Line: %s)" % (ValueString, Size, self.FileName, self.Lineno))\r
try:\r
\r
## Pack a unicode PCD value into byte array.\r
# \r
- # A unicode string for a PCD should be in format as L"".\r
+ # A unicode string for a PCD should be in format as L""/L''.\r
#\r
def _PackUnicode(self, UnicodeString, Size):\r
if (Size < 0):\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter Size %s of PCD %s!(File: %s Line: %s)" % \\r
(self.PcdBinSize, self.PcdCName, self.FileName, self.Lineno))\r
- if (len(UnicodeString) < 3):\r
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "For PCD: %s ,ASCII string %s at least contains two!(File: %s Line: %s)" % \\r
- (self.PcdCName, self.PcdUnpackValue, self.FileName, self.Lineno))\r
\r
+ QuotedFlag = True\r
+ if UnicodeString.startswith("L'"):\r
+ QuotedFlag = False \r
UnicodeString = UnicodeString[2:-1]\r
\r
- if (len(UnicodeString) + 1) * 2 > Size:\r
+ # No null-terminator in L'string'\r
+ if (QuotedFlag and (len(UnicodeString) + 1) * 2 > Size) or (not QuotedFlag and len(UnicodeString) * 2 > Size):\r
EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW,\r
"The size of unicode string %s is too larger for size %s(File: %s Line: %s)" % \\r
(UnicodeString, Size, self.FileName, self.Lineno))\r
## @file\r
# Common routines used by all tools\r
#\r
-# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2018, 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
if Type == "VOID*":\r
ValueRe = re.compile(r'\s*L?\".*\"\s*$')\r
if not (((Value.startswith('L"') or Value.startswith('"')) and Value.endswith('"'))\r
- or (Value.startswith('{') and Value.endswith('}'))\r
+ or (Value.startswith('{') and Value.endswith('}')) or (Value.startswith("L'") or Value.startswith("'") and Value.endswith("'"))\r
):\r
return False, "Invalid value [%s] of type [%s]; must be in the form of {...} for array"\\r
- ", or \"...\" for string, or L\"...\" for unicode string" % (Value, Type)\r
+ ", \"...\" or \'...\' for string, L\"...\" or L\'...\' for unicode string" % (Value, Type)\r
elif ValueRe.match(Value):\r
# Check the chars in UnicodeString or CString is printable\r
if Value.startswith("L"):\r