[edk2] [PATCH v1 5/5] BaseTools: remove redundant check

Jaben Carsey posted 5 patches 6 years, 7 months ago
[edk2] [PATCH v1 5/5] BaseTools: remove redundant check
Posted by Jaben Carsey 6 years, 7 months ago
The RegEx matches begining and end of the string, dont then check length.

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>
---
 BaseTools/Source/Python/AutoGen/IdfClassObject.py | 2 +-
 BaseTools/Source/Python/AutoGen/UniClassObject.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py b/BaseTools/Source/Python/AutoGen/IdfClassObject.py
index a028aceee927..6953854a5247 100644
--- a/BaseTools/Source/Python/AutoGen/IdfClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/IdfClassObject.py
@@ -107,7 +107,7 @@ class IdfFileClassObject(object):
                 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 = gIdentifierPattern.match(LineDetails[1])
-                if MatchString is None or MatchString.end(0) != len(LineDetails[1]):
+                if MatchString is None:
                     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:
                     self.ImageIDList.append(LineDetails[1])
diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py
index 8b0c563a8c88..5b879d784d9c 100644
--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py
@@ -352,7 +352,7 @@ class UniFileClassObject(object):
         # Check the string name
         if Name != '':
             MatchString = gIdentifierPattern.match(Name)
-            if MatchString is None or MatchString.end(0) != len(Name):
+            if MatchString is None:
                 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 ')
         for IndexI in range(len(LanguageList)):
@@ -522,7 +522,7 @@ class UniFileClassObject(object):
                 # Check the string name
                 if not self.IsCompatibleMode and Name != '':
                     MatchString = gIdentifierPattern.match(Name)
-                    if MatchString is None or MatchString.end(0) != len(Name):
+                    if MatchString is None:
                         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)
                 continue
-- 
2.16.2.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel