X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FUPT%2FLibrary%2FUniClassObject.py;h=0014a7561ba88b1b02b735ecc04ba2b334571f0c;hp=1e73d3e9a8d9ea3991f5003afc28fd76510df471;hb=b3fa393f477a12fe0e1aedb36395ca9b345ae110;hpb=4a21fb3b67a0ef1655b43e9368b6b697bbf327af diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py b/BaseTools/Source/Python/UPT/Library/UniClassObject.py index 1e73d3e9a8..0014a7561b 100644 --- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py +++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py @@ -1,7 +1,7 @@ ## @file # Collect all defined strings in multiple uni files. # -# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials are licensed and made available # under the terms and conditions of the BSD License which accompanies this @@ -47,8 +47,6 @@ NULL = u'\u0000' TAB = u'\t' BACK_SPLASH = u'\\' -gINCLUDE_PATTERN = re.compile("^!include[\s]+([\S]+)[\s]*$", re.MULTILINE | re.UNICODE) - gLANG_CONV_TABLE = {'eng':'en', 'fra':'fr', \ 'aar':'aa', 'abk':'ab', 'ave':'ae', 'afr':'af', 'aka':'ak', 'amh':'am', \ 'arg':'an', 'ara':'ar', 'asm':'as', 'ava':'av', 'aym':'ay', 'aze':'az', \ @@ -328,11 +326,11 @@ class UniFileClassObject(object): Lang = distutils.util.split_quoted((Line.split(u"//")[0])) if len(Lang) != 3: try: - FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').read() + FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').readlines() except UnicodeError, Xstr: - FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16').read() + FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16').readlines() except UnicodeError, Xstr: - FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16_le').read() + FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16_le').readlines() except: EdkLogger.Error("Unicode File Parser", ToolError.FILE_OPEN_FAILURE, @@ -437,7 +435,7 @@ class UniFileClassObject(object): # ExtraData='The file %s is either invalid UTF-16LE or it is missing the BOM.' % File.Path) try: - FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').read() + FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').readlines() except UnicodeError, Xstr: FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16').readlines() except UnicodeError: @@ -543,22 +541,15 @@ class UniFileClassObject(object): Line = Line.replace(u'\t', u' ') Line = Line.replace(u'\u0006', u'\\') - # IncList = gINCLUDE_PATTERN.findall(Line) - IncList = [] - if len(IncList) == 1: - for Dir in [File.Dir] + self.IncludePathList: - IncFile = PathClass(str(IncList[0]), Dir) - self.IncFileList.append(IncFile) - if os.path.isfile(IncFile.Path): - Lines.extend(self.PreProcess(IncFile, True)) - break - else: - EdkLogger.Error("Unicode File Parser", - ToolError.FILE_NOT_FOUND, - Message="Cannot find include file", - ExtraData=str(IncList[0])) - continue - + # + # Check if single line has correct '"' + # + if Line.startswith(u'#string') and Line.find(u'#language') > -1 and Line.find('"') > Line.find(u'#language'): + if not Line.endswith('"'): + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, + ExtraData='''The line %s misses '"' at the end of it in file %s''' + % (LineCount, File.Path)) + # # Between Name entry and Language entry can not contain line feed # @@ -579,9 +570,9 @@ class UniFileClassObject(object): # if Line.startswith(u'"'): if StringEntryExistsFlag == 2: - EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, Message=ST.ERR_UNIPARSE_LINEFEED_UP_EXIST % Line, ExtraData=File.Path) - + StringEntryExistsFlag = 1 if not Line.endswith('"'): EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, @@ -589,7 +580,7 @@ class UniFileClassObject(object): % (LineCount, File.Path)) elif Line.startswith(u'#language'): if StringEntryExistsFlag == 2: - EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, Message=ST.ERR_UNI_MISS_STRING_ENTRY % Line, ExtraData=File.Path) StringEntryExistsFlag = 0 else: @@ -1050,7 +1041,7 @@ class UniFileClassObject(object): ToolError.FILE_NOT_FOUND, ExtraData=FilaPath) try: - FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_8').read() + FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_8').readlines() except UnicodeError, Xstr: FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_16').readlines() except UnicodeError: