BaseTools: GenFds - simplify testing for Hex number

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
Carsey, Jaben 2018-04-20 23:51:44 +08:00 committed by Yonghong Zhu
parent 992fbe3519
commit 6553c61724
2 changed files with 2 additions and 8 deletions

View File

@ -62,6 +62,7 @@ gGuidPatternEnd = re.compile(r'{}$'.format(_GuidPattern))
## Regular expressions for HEX matching ## Regular expressions for HEX matching
g4HexChar = re.compile(r'{}{{4}}'.format(_HexChar)) g4HexChar = re.compile(r'{}{{4}}'.format(_HexChar))
gHexPattern = re.compile(r'0[xX]{}+'.format(_HexChar)) gHexPattern = re.compile(r'0[xX]{}+'.format(_HexChar))
gHexPatternAll = re.compile(r'0[xX]{}+$'.format(_HexChar))
## Regular expressions for string identifier checking ## Regular expressions for string identifier checking
gIdentifierPattern = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$', re.UNICODE) gIdentifierPattern = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$', re.UNICODE)

View File

@ -1183,13 +1183,6 @@ class FdfParser:
self.__GetOneChar() self.__GetOneChar()
def __IsHex(self, HexStr):
if not HexStr.upper().startswith("0X"):
return False
if len(self.__Token) <= 2:
return False
return True if all(x in string.hexdigits for x in HexStr[2:]) else False
## __GetNextHexNumber() method ## __GetNextHexNumber() method
# #
# Get next HEX data before a seperator # Get next HEX data before a seperator
@ -1202,7 +1195,7 @@ class FdfParser:
def __GetNextHexNumber(self): def __GetNextHexNumber(self):
if not self.__GetNextToken(): if not self.__GetNextToken():
return False return False
if self.__IsHex(self.__Token): if gHexPatternAll.match(self.__Token):
return True return True
else: else:
self.__UndoToken() self.__UndoToken()