summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/UPT
diff options
context:
space:
mode:
authorHess Chen <hesheng.chen@intel.com>2018-10-16 14:04:00 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-10-24 08:41:05 +0800
commit90c64aada8a14dca551aa48bc5a5763a39933525 (patch)
treea07b5a880db90a65f8aade0f9cce7028a41c8619 /BaseTools/Source/Python/UPT
parent7a57490c2ebafa5411d7fef62710d8778f17c9b1 (diff)
downloadedk2-90c64aada8a14dca551aa48bc5a5763a39933525.tar.gz
edk2-90c64aada8a14dca551aa48bc5a5763a39933525.tar.bz2
edk2-90c64aada8a14dca551aa48bc5a5763a39933525.zip
BaseTools/UPT: Fix an issue of UNI string checking.
The tool now can detect the error that the content between double quotes contains another double quotes or enter key. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/UPT')
-rw-r--r--BaseTools/Source/Python/UPT/Library/UniClassObject.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
index 670cf3b4ee..cd575d5a34 100644
--- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py
+++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
@@ -567,6 +567,22 @@ class UniFileClassObject(object):
MultiLineFeedExits = True
#
+ # Check the situation that there only has one '"' for the language entry
+ #
+ if Line.startswith(u'#string') and Line.find(u'#language') > 0 and Line.count(u'"') == 1:
+ EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,
+ ExtraData='''The line %s misses '"' at the end of it in file %s'''
+ % (LineCount, File.Path))
+
+ #
+ # Check the situation that there has more than 2 '"' for the language entry
+ #
+ if Line.startswith(u'#string') and Line.find(u'#language') > 0 and Line.replace(u'\\"', '').count(u'"') > 2:
+ EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,
+ ExtraData='''The line %s has more than 2 '"' for language entry in file %s'''
+ % (LineCount, File.Path))
+
+ #
# Between two String entry, can not contain line feed
#
if Line.startswith(u'"'):
@@ -727,6 +743,13 @@ class UniFileClassObject(object):
else:
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
elif Line.startswith(u'"'):
+ #
+ # Check the situation that there has more than 2 '"' for the language entry
+ #
+ if Line.replace(u'\\"', '').count(u'"') > 2:
+ EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,
+ ExtraData='''The line %s has more than 2 '"' for language entry in file %s'''
+ % (LineCount, File.Path))
if u'#string' in Line or u'#language' in Line:
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
NewLines.append(Line)