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=jaben.carsey@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 5F08121E08168 for ; Tue, 3 Apr 2018 15:34:11 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2018 15:34:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,403,1517904000"; d="scan'208";a="44656111" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga001.jf.intel.com with ESMTP; 03 Apr 2018 15:34:09 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Liming Gao , Yonghong Zhu Date: Tue, 3 Apr 2018 15:34:05 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [PATCH v1 4/5] BaseTools: AutoGen - use the new shared RegEx 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: Tue, 03 Apr 2018 22:34:11 -0000 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/IdfClassObject.py | 3 ++- BaseTools/Source/Python/AutoGen/UniClassObject.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py b/BaseTools/Source/Python/AutoGen/IdfClassObject.py index cb72219b40d5..a028aceee927 100644 --- a/BaseTools/Source/Python/AutoGen/IdfClassObject.py +++ b/BaseTools/Source/Python/AutoGen/IdfClassObject.py @@ -21,6 +21,7 @@ from Common.Misc import PathClass from Common.LongFilePathSupport import LongFilePath import re import os +from Common.GlobalData import gIdentifierPattern IMAGE_TOKEN = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE) @@ -105,7 +106,7 @@ class IdfFileClassObject(object): EdkLogger.error("Image Definition File Parser", PARSER_ERROR, 'The format is not match #image IMAGE_ID [TRANSPARENT] ImageFileName in Line %s of File %s.' % (LineNo, File.Path)) if Len == 4 and LineDetails[2] != 'TRANSPARENT': EdkLogger.error("Image Definition File Parser", PARSER_ERROR, 'Please use the keyword "TRANSPARENT" to describe the transparency setting in Line %s of File %s.' % (LineNo, File.Path)) - MatchString = re.match('^[a-zA-Z][a-zA-Z0-9_]*$', LineDetails[1], re.UNICODE) + MatchString = gIdentifierPattern.match(LineDetails[1]) if MatchString is None or MatchString.end(0) != len(LineDetails[1]): EdkLogger.error('Image Definition File Parser', FORMAT_INVALID, 'The Image token name %s defined in Idf file %s contains the invalid character.' % (LineDetails[1], File.Path)) if LineDetails[1] not in self.ImageIDList: diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py index 242402dfaeeb..8b0c563a8c88 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -351,7 +351,7 @@ class UniFileClassObject(object): Name = Item.split()[1] # Check the string name if Name != '': - MatchString = re.match('^[a-zA-Z][a-zA-Z0-9_]*$', Name, re.UNICODE) + MatchString = gIdentifierPattern.match(Name) if MatchString is None or MatchString.end(0) != len(Name): EdkLogger.error('Unicode File Parser', FORMAT_INVALID, 'The string token name %s defined in UNI file %s contains the invalid character.' % (Name, self.File)) LanguageList = Item.split(u'#language ') @@ -521,7 +521,7 @@ class UniFileClassObject(object): Language = GetLanguageCode(Language, self.IsCompatibleMode, self.File) # Check the string name if not self.IsCompatibleMode and Name != '': - MatchString = re.match('^[a-zA-Z][a-zA-Z0-9_]*$', Name, re.UNICODE) + MatchString = gIdentifierPattern.match(Name) if MatchString is None or MatchString.end(0) != len(Name): EdkLogger.error('Unicode File Parser', FORMAT_INVALID, 'The string token name %s defined in UNI file %s contains the invalid character.' % (Name, self.File)) self.AddStringToList(Name, Language, Value) -- 2.16.2.windows.1