]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/UniClassObject.py
BaseTools: Structure Pcd in CommandLine.
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / UniClassObject.py
index 02a15cc0f0d4cd3877d5b6c54d85860b4d13ffba..856d19cda270cdc64b84812f578860f2a35a4c1f 100644 (file)
@@ -4,7 +4,7 @@
 #\r
 # Copyright (c) 2014 Hewlett-Packard Development Company, L.P.<BR>\r
 #\r
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -248,7 +248,7 @@ class UniFileClassObject(object):
                 EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=File);\r
             LineNo = GetLineNo(FileIn, Line, False)\r
             EdkLogger.error("Unicode File Parser", PARSER_ERROR, "Wrong language definition",\r
-                            ExtraData="""%s\n\t*Correct format is like '#langdef en-US "English"'""" % Line, File = File, Line = LineNo)\r
+                            ExtraData="""%s\n\t*Correct format is like '#langdef en-US "English"'""" % Line, File=File, Line=LineNo)\r
         else:\r
             LangName = GetLanguageCode(Lang[1], self.IsCompatibleMode, self.File)\r
             LangPrintName = Lang[2]\r
@@ -348,11 +348,11 @@ class UniFileClassObject(object):
         Value = ''\r
 \r
         Name = Item.split()[1]\r
-        # Check the string name is the upper character\r
+        # Check the string name\r
         if Name != '':\r
-            MatchString = re.match('[A-Z0-9_]+', Name, re.UNICODE)\r
+            MatchString = re.match('^[a-zA-Z][a-zA-Z0-9_]*$', Name, re.UNICODE)\r
             if MatchString == 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 lower case character.' %(Name, self.File))\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
         for IndexI in range(len(LanguageList)):\r
             if IndexI == 0:\r
@@ -432,9 +432,19 @@ class UniFileClassObject(object):
             Line = Line.replace(u"\\'", u"'") \r
             Line = Line.replace(BACK_SLASH_PLACEHOLDER, u'\\')\r
 \r
-#           if Line.find(u'\\x'):\r
-#               hex = Line[Line.find(u'\\x') + 2 : Line.find(u'\\x') + 6]\r
-#               hex = "u'\\u" + hex + "'"\r
+            StartPos = Line.find(u'\\x')\r
+            while (StartPos != -1):\r
+                EndPos = Line.find(u'\\', StartPos + 1, StartPos + 7)\r
+                if EndPos != -1 and EndPos - StartPos == 6 :\r
+                    if re.match('[a-fA-F0-9]{4}', Line[StartPos + 2 : EndPos], re.UNICODE):\r
+                        EndStr = Line[EndPos: ]\r
+                        UniStr = ('\u' + (Line[StartPos + 2 : EndPos])).decode('unicode_escape')\r
+                        if EndStr.startswith(u'\\x') and len(EndStr) >= 7:\r
+                            if EndStr[6] == u'\\' and re.match('[a-fA-F0-9]{4}', EndStr[2 : 6], re.UNICODE):\r
+                                Line = Line[0 : StartPos] + UniStr + EndStr\r
+                        else:\r
+                            Line = Line[0 : StartPos] + UniStr + EndStr[1:]\r
+                StartPos = Line.find(u'\\x', StartPos + 1)\r
 \r
             IncList = gIncludePattern.findall(Line)\r
             if len(IncList) == 1:\r
@@ -508,11 +518,11 @@ class UniFileClassObject(object):
                         break\r
                 # Value = Value.replace(u'\r\n', u'')\r
                 Language = GetLanguageCode(Language, self.IsCompatibleMode, self.File)\r
-                # Check the string name is the upper character\r
+                # Check the string name\r
                 if not self.IsCompatibleMode and Name != '':\r
-                    MatchString = re.match('[A-Z0-9_]+', Name, re.UNICODE)\r
+                    MatchString = re.match('^[a-zA-Z][a-zA-Z0-9_]*$', Name, re.UNICODE)\r
                     if MatchString == 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 lower case character.' %(Name, self.File))\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
                 continue\r
 \r
@@ -571,7 +581,7 @@ class UniFileClassObject(object):
                 ItemIndexInList = self.OrderedStringDict[Language][Name]\r
                 Item = self.OrderedStringList[Language][ItemIndexInList]\r
                 Item.UpdateValue(Value)\r
-                Item.UseOtherLangDef = ''   \r
+                Item.UseOtherLangDef = ''\r
 \r
         if IsAdded:\r
             Token = len(self.OrderedStringList[Language])\r