From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 890E6226612A4 for ; Wed, 25 Apr 2018 01:51:39 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2018 01:51:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,325,1520924400"; d="scan'208";a="219225481" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 25 Apr 2018 01:51:38 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 25 Apr 2018 01:51:38 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.210]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.240]) with mapi id 14.03.0319.002; Wed, 25 Apr 2018 16:51:36 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number Thread-Index: AQHT2L+IwDuJ+jsHfEeKICVsQoOcQ6QRM7iQ Date: Wed, 25 Apr 2018 08:51:35 +0000 Message-ID: References: <4d420ce32eff48b14794ef86420af7ba9b417d73.1524239028.git.jaben.carsey@intel.com> In-Reply-To: <4d420ce32eff48b14794ef86420af7ba9b417d73.1524239028.git.jaben.carsey@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 08:51:39 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben=20 Sent: Friday, April 20, 2018 11:52 PM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Zhu, Yonghong Subject: [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex numb= er Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Common/GlobalData.py | 1 + BaseTools/Source/Pytho= n/GenFds/FdfParser.py | 9 +-------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Sourc= e/Python/Common/GlobalData.py index f58dc5a8dda2..e3131b86cc60 100644 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -62,6 +62,7 @@ gGuidPatternEnd =3D re.compile(r'{}$'.format(_GuidPattern= )) ## Regular expressions for HEX matching g4HexChar =3D re.compile(r'{}{{4}= }'.format(_HexChar)) gHexPattern =3D re.compile(r'0[xX]{}+'.format(_HexChar)) +gHexPatternAll =3D re.compile(r'0[xX]{}+$'.format(_HexChar)) =20 ## Regular expressions for string identifier checking gIdentifierPattern = =3D re.compile('^[a-zA-Z][a-zA-Z0-9_]*$', re.UNICODE) diff --git a/BaseTool= s/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfPar= ser.py index b8848a25b4b2..fe4f2df0e1e1 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -1183,13 +1183,6 @@ class FdfParser: =20 self.__GetOneChar() =20 - def __IsHex(self, HexStr): - if not HexStr.upper().startswith("0X"): - return False - if len(self.__Token) <=3D 2: - return False - return True if all(x in string.hexdigits for x in HexStr[2:]) else= False - ## __GetNextHexNumber() method # # Get next HEX data before a seperator @@ -1202,7 +1195,7 @@ class FdfParser: def __GetNextHexNumber(self): if not self.__GetNextToken(): return False - if self.__IsHex(self.__Token): + if gHexPatternAll.match(self.__Token): return True else: self.__UndoToken() -- 2.16.2.windows.1