]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: AutoGen - use the new shared RegEx
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>
Tue, 3 Apr 2018 22:34:05 +0000 (06:34 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Sun, 8 Apr 2018 07:34:11 +0000 (15:34 +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/AutoGen/IdfClassObject.py
BaseTools/Source/Python/AutoGen/UniClassObject.py

index cb72219b40d5b19f7f01784726730bde99f327c9..a028aceee927af6d2a4edf040e44d96864817351 100644 (file)
@@ -21,6 +21,7 @@ from Common.Misc import PathClass
 from Common.LongFilePathSupport import LongFilePath\r
 import re\r
 import os\r
 from Common.LongFilePathSupport import LongFilePath\r
 import re\r
 import os\r
+from Common.GlobalData import gIdentifierPattern\r
 \r
 IMAGE_TOKEN = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)\r
 \r
 \r
 IMAGE_TOKEN = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)\r
 \r
@@ -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))\r
                 if Len == 4 and LineDetails[2] != 'TRANSPARENT':\r
                     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))\r
                     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))\r
                 if Len == 4 and LineDetails[2] != 'TRANSPARENT':\r
                     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))\r
-                MatchString = re.match('^[a-zA-Z][a-zA-Z0-9_]*$', LineDetails[1], re.UNICODE)\r
+                MatchString = gIdentifierPattern.match(LineDetails[1])\r
                 if MatchString is None or MatchString.end(0) != len(LineDetails[1]):\r
                     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))\r
                 if LineDetails[1] not in self.ImageIDList:\r
                 if MatchString is None or MatchString.end(0) != len(LineDetails[1]):\r
                     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))\r
                 if LineDetails[1] not in self.ImageIDList:\r
index 242402dfaeeb511f7bbf4420cbd7feafc8fe4d6f..8b0c563a8c8880a1b8e1905d43b5606888ee0a8f 100644 (file)
@@ -351,7 +351,7 @@ class UniFileClassObject(object):
         Name = Item.split()[1]\r
         # Check the string name\r
         if Name != '':\r
         Name = Item.split()[1]\r
         # Check the string name\r
         if Name != '':\r
-            MatchString = re.match('^[a-zA-Z][a-zA-Z0-9_]*$', Name, re.UNICODE)\r
+            MatchString = gIdentifierPattern.match(Name)\r
             if MatchString is None or MatchString.end(0) != len(Name):\r
                 EdkLogger.error('Unicode File Parser', FORMAT_INVALID, 'The string token name %s defined in UNI file %s contains the invalid character.' % (Name, self.File))\r
         LanguageList = Item.split(u'#language ')\r
             if MatchString is None or MatchString.end(0) != len(Name):\r
                 EdkLogger.error('Unicode File Parser', FORMAT_INVALID, 'The string token name %s defined in UNI file %s contains the invalid character.' % (Name, self.File))\r
         LanguageList = Item.split(u'#language ')\r
@@ -521,7 +521,7 @@ class UniFileClassObject(object):
                 Language = GetLanguageCode(Language, self.IsCompatibleMode, self.File)\r
                 # Check the string name\r
                 if not self.IsCompatibleMode and Name != '':\r
                 Language = GetLanguageCode(Language, self.IsCompatibleMode, self.File)\r
                 # Check the string name\r
                 if not self.IsCompatibleMode and Name != '':\r
-                    MatchString = re.match('^[a-zA-Z][a-zA-Z0-9_]*$', Name, re.UNICODE)\r
+                    MatchString = gIdentifierPattern.match(Name)\r
                     if MatchString is None or MatchString.end(0) != len(Name):\r
                         EdkLogger.error('Unicode File Parser', FORMAT_INVALID, 'The string token name %s defined in UNI file %s contains the invalid character.' % (Name, self.File))\r
                 self.AddStringToList(Name, Language, Value)\r
                     if MatchString is None or MatchString.end(0) != len(Name):\r
                         EdkLogger.error('Unicode File Parser', FORMAT_INVALID, 'The string token name %s defined in UNI file %s contains the invalid character.' % (Name, self.File))\r
                 self.AddStringToList(Name, Language, Value)\r