]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: GenFds - simplify testing for Hex number
authorCarsey, Jaben <jaben.carsey@intel.com>
Fri, 20 Apr 2018 15:51:44 +0000 (23:51 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Thu, 26 Apr 2018 06:44:35 +0000 (14:44 +0800)
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>
BaseTools/Source/Python/Common/GlobalData.py
BaseTools/Source/Python/GenFds/FdfParser.py

index f58dc5a8dda225a973f57c20abdb2508c28e866c..e3131b86cc60fe4226cb8c99328b65d9bb2a858d 100644 (file)
@@ -62,6 +62,7 @@ gGuidPatternEnd = re.compile(r'{}$'.format(_GuidPattern))
 ## Regular expressions for HEX matching\r
 g4HexChar = re.compile(r'{}{{4}}'.format(_HexChar))\r
 gHexPattern = re.compile(r'0[xX]{}+'.format(_HexChar))\r
+gHexPatternAll = re.compile(r'0[xX]{}+$'.format(_HexChar))\r
 \r
 ## Regular expressions for string identifier checking\r
 gIdentifierPattern = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$', re.UNICODE)\r
index 6baf875833a8ce4858f8876ce9861ff68963f18a..25755a9778f241a771cb242b597d5072bf9889e8 100644 (file)
@@ -1183,13 +1183,6 @@ class FdfParser:
 \r
         self.__GetOneChar()\r
 \r
-    def __IsHex(self, HexStr):\r
-        if not HexStr.upper().startswith("0X"):\r
-            return False\r
-        if len(self.__Token) <= 2:\r
-            return False\r
-        return True if all(x in string.hexdigits for x in HexStr[2:]) else False\r
-\r
     ## __GetNextHexNumber() method\r
     #\r
     #   Get next HEX data before a seperator\r
@@ -1202,7 +1195,7 @@ class FdfParser:
     def __GetNextHexNumber(self):\r
         if not self.__GetNextToken():\r
             return False\r
-        if self.__IsHex(self.__Token):\r
+        if gHexPatternAll.match(self.__Token):\r
             return True\r
         else:\r
             self.__UndoToken()\r