]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Library/UniClassObject.py
BaseTools/UPT:merge UPT Tool use Python2 and Python3
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Library / UniClassObject.py
index 670cf3b4eeac19a9f945f06c575b593eed6463d0..bd7804b7533bb856f37da56f04b61de845826d5d 100644 (file)
@@ -119,10 +119,12 @@ def UniToHexList(Uni):
 # @retval NewUni:  The converted unicode string\r
 #\r
 def ConvertSpecialUnicodes(Uni):\r
-    NewUni = Uni\r
+    OldUni = NewUni = Uni\r
     NewUni = NewUni.replace(u'\u00A9', '(c)')\r
     NewUni = NewUni.replace(u'\u00AE', '(r)')\r
     NewUni = NewUni.replace(u'\u2122', '(tm)')\r
+    if OldUni == NewUni:\r
+        NewUni = OldUni\r
     return NewUni\r
 \r
 ## GetLanguageCode1766\r
@@ -513,7 +515,7 @@ class UniFileClassObject(object):
                     FileIn[LineCount-1] = Line\r
                     FileIn[LineCount] = '\r\n'\r
                     LineCount -= 1\r
-                    for Index in xrange (LineCount + 1, len (FileIn) - 1):\r
+                    for Index in range (LineCount + 1, len (FileIn) - 1):\r
                         if (Index == len(FileIn) -1):\r
                             FileIn[Index] = '\r\n'\r
                         else:\r
@@ -566,6 +568,22 @@ class UniFileClassObject(object):
             if Line.startswith(u'#language') and len(Line.split()) == 2:\r
                 MultiLineFeedExits = True\r
 \r
+            #\r
+            # Check the situation that there only has one '"' for the language entry\r
+            #\r
+            if Line.startswith(u'#string') and Line.find(u'#language') > 0 and Line.count(u'"') == 1:\r
+                EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,\r
+                                ExtraData='''The line %s misses '"' at the end of it in file %s'''\r
+                                % (LineCount, File.Path))\r
+\r
+            #\r
+            # Check the situation that there has more than 2 '"' for the language entry\r
+            #\r
+            if Line.startswith(u'#string') and Line.find(u'#language') > 0 and Line.replace(u'\\"', '').count(u'"') > 2:\r
+                EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,\r
+                                ExtraData='''The line %s has more than 2 '"' for language entry in file %s'''\r
+                                % (LineCount, File.Path))\r
+\r
             #\r
             # Between two String entry, can not contain line feed\r
             #\r
@@ -727,6 +745,13 @@ class UniFileClassObject(object):
                 else:\r
                     EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)\r
             elif Line.startswith(u'"'):\r
+                #\r
+                # Check the situation that there has more than 2 '"' for the language entry\r
+                #\r
+                if Line.replace(u'\\"', '').count(u'"') > 2:\r
+                    EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,\r
+                                    ExtraData='''The line %s has more than 2 '"' for language entry in file %s'''\r
+                                    % (LineCount, File.Path))\r
                 if u'#string' in Line  or u'#language' in Line:\r
                     EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)\r
                 NewLines.append(Line)\r