From: jljusten Date: Tue, 30 Oct 2007 20:01:17 +0000 (+0000) Subject: BaseTools/Source/Python/Trim/Trim.py: X-Git-Url: http://git.etherboot.org/people/mcb30/basetools.git/commitdiff_plain/4c99b99f34a1eaa7268d2baee1473d714b9a782b BaseTools/Source/Python/Trim/Trim.py: Fix trim failure for source files with a zero length. For example edk2 => MdePkg/Library/BaseLib/X64/Thunk16.S currently has a zero length. Code also reviewed by Javen (jwang36). git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@859 7335b38e-4728-0410-8992-fb3ffe349368 --- diff --git a/Source/Python/Trim/Trim.py b/Source/Python/Trim/Trim.py index 6cf2ab8..3f5fd60 100644 --- a/Source/Python/Trim/Trim.py +++ b/Source/Python/Trim/Trim.py @@ -57,6 +57,7 @@ def TrimPreprocessedFile(Source, Target, Convert): InjectedFile = "" LineIndexOfOriginalFile = None NewLines = [] + LineControlDirectiveFound = False for Index in range(len(Lines)): Line = Lines[Index].replace("\r", "") # @@ -72,6 +73,7 @@ def TrimPreprocessedFile(Source, Target, Convert): # The first injetcted file must be the preprocessed file itself if PreprocessedFile == "": PreprocessedFile = InjectedFile + LineControlDirectiveFound = True continue elif PreprocessedFile == "" or InjectedFile != PreprocessedFile: continue @@ -106,7 +108,7 @@ def TrimPreprocessedFile(Source, Target, Convert): NewLines.append(Line) # in case there's no line directive or linemarker found - if NewLines == []: + if (not LineControlDirectiveFound) and NewLines == []: NewLines = Lines # save to file