diff options
author | Fan, ZhijuX <zhijux.fan@intel.com> | 2019-05-06 10:35:07 +0800 |
---|---|---|
committer | Feng, Bob C <bob.c.feng@intel.com> | 2019-05-08 09:41:42 +0800 |
commit | 0cb3f77153b7fde612ed49dddd986cf8421be7ba (patch) | |
tree | a0318f804e852d7175e13d686634a6f056502a1a /BaseTools/Source/Python/Ecc/CodeFragmentCollector.py | |
parent | 8b4b2fb9a1839f719a8a4045fefafa66ddc52e63 (diff) | |
download | edk2-0cb3f77153b7fde612ed49dddd986cf8421be7ba.tar.gz edk2-0cb3f77153b7fde612ed49dddd986cf8421be7ba.tar.bz2 edk2-0cb3f77153b7fde612ed49dddd986cf8421be7ba.zip |
BaseTools:ECC report errors on account of analyze special characters
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1751
In case that a C function body contains the string of L'', L'\"',
L"\"", L''', L""", L"\"\"", L"\"^", L" \"", L"\" \"", ('L",\\\""')
ECC tool running under python3 interpreter will report error.
The antlr4 module misidentified this character
This patch is going to fix that issue.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Ecc/CodeFragmentCollector.py')
-rw-r--r-- | BaseTools/Source/Python/Ecc/CodeFragmentCollector.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py index c428752c05..d8d6aff08a 100644 --- a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py +++ b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py @@ -73,7 +73,7 @@ class CodeFragmentCollector: self.FileName = FileName
self.CurrentLineNumber = 1
self.CurrentOffsetWithinLine = 0
-
+ self.TokenReleaceList = []
self.__Token = ""
self.__SkippedChars = ""
@@ -503,6 +503,9 @@ class CodeFragmentCollector: FileStringContents = ''
for fileLine in self.Profile.FileLinesList:
FileStringContents += fileLine
+ for Token in self.TokenReleaceList:
+ if Token in FileStringContents:
+ FileStringContents = FileStringContents.replace(Token, 'TOKENSTRING')
cStream = antlr.InputStream(FileStringContents)
lexer = CLexer(cStream)
tStream = antlr.CommonTokenStream(lexer)
|