X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FUPT%2FLibrary%2FParserValidate.py;h=028cf9a54f84cc569397ab5bd590a96653618129;hb=06eb35402e456066c86f621e566160967b7740ad;hp=860fb4f1dcdfa3fa797809d729557be7b40d80d9;hpb=9508d0fa4fb2cd2ff03604bc3b1b1abf8f69ccb6;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/UPT/Library/ParserValidate.py b/BaseTools/Source/Python/UPT/Library/ParserValidate.py index 860fb4f1dc..028cf9a54f 100644 --- a/BaseTools/Source/Python/UPT/Library/ParserValidate.py +++ b/BaseTools/Source/Python/UPT/Library/ParserValidate.py @@ -1,6 +1,7 @@ ## @file ParserValidate.py +# Functions for parser validation # -# Copyright (c) 2011, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2014, 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 @@ -26,6 +27,7 @@ from Library.DataType import TAB_SPACE_SPLIT from Library.String import GetSplitValueList from Library.ExpressionValidate import IsValidBareCString from Library.ExpressionValidate import IsValidFeatureFlagExp +from Common.MultipleWorkspace import MultipleWorkspace as mws ## __HexDigit() method # @@ -235,7 +237,7 @@ def IsValidPath(Path, Root): Path = os.path.normpath(Path).replace('\\', '/') Root = os.path.normpath(Root).replace('\\', '/') - FullPath = os.path.normpath(os.path.join(Root, Path)).replace('\\', '/') + FullPath = mws.join(Root, Path) if not os.path.exists(FullPath): return False @@ -566,7 +568,7 @@ def IsValidPcdValue(PcdValue): for Char in PcdValue: if Char == '\n' or Char == '\t' or Char == '\f': return False - + # # # @@ -582,7 +584,7 @@ def IsValidPcdValue(PcdValue): if IsValidHex(PcdValue): return True - ReIsValidIntegerSingle = re.compile(r"^\s*[0-9]\s*$", re.DOTALL) + ReIsValidIntegerSingle = re.compile(r"^\s*[0-9]\s*$", re.DOTALL) if ReIsValidIntegerSingle.match(PcdValue) != None: return True @@ -590,7 +592,6 @@ def IsValidPcdValue(PcdValue): if ReIsValidIntegerMulti.match(PcdValue) != None: return True - # # ::= {} {} {"$(" ")"} # ::= {} {} @@ -721,3 +722,12 @@ def IsValidUserId(UserId): return False return True +# +# Check if a UTF16-LE file has a BOM header +# +def CheckUTF16FileHeader(File): + FileIn = open(File, 'rb').read(2) + if FileIn != '\xff\xfe': + return False + + return True