Hi Samer,

Thanks for your patch, after take a look at the issue, I found another bug in 
FDF parser. Following patch fixed both issues:

If there are two continuous !include lines, the second !include is ignored.
Also if the last line in !include file is not ends with '\r' or '\n', a '\n' 
should be appended, otherwise index out of range exceptions is raised.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yingke Liu <yingke.d....@intel.com>
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index ffc54ab..2313174 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -149,6 +149,8 @@ class IncludeFileProfile :
             fsock = open(FileName, "rb", 0)
             try:
                 self.FileLinesList = fsock.readlines()
+                if self.FileLinesList and self.FileLinesList[-1][-1] not in 
('\r', '\n'):
+                    self.FileLinesList[-1] = self.FileLinesList[-1] + '\n'
             finally:
                 fsock.close()
 
@@ -627,6 +629,8 @@ class FdfParser:
                         IncFileProfile.InsertAdjust += 1
                         self.CurrentLineNumber += 1
                         self.CurrentOffsetWithinLine = 0
+                    else:
+                        self.__UndoToken()
 
                 for Line in IncFileProfile.FileLinesList:
                     self.Profile.FileLinesList.insert(InsertAtLine, Line)
-- 
1.9.5.msysgit.0

Dennis

-----Original Message-----
From: Samer El-Haj-Mahmoud [mailto:samer.el-haj-mahm...@hp.com] 
Sent: Thursday, July 02, 2015 9:12
To: edk2-devel@lists.sourceforge.net
Cc: Liu, Yingke D; Samer El-Haj-Mahmoud
Subject: [PATCH] BaseTools: Fix back-to-back !include in FDF files

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud <samer.el-haj-mahm...@hp.com>
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index 8091a51..15ec886 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1,6 +1,7 @@
 ## @file
 # parse FDF file
 #
+#  (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
 #  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>  #  
#  This program and the accompanying materials @@ -639,6 +640,14 @@ class 
FdfParser:
                 TempList.insert(IncludeOffset, '#')
                 self.Profile.FileLinesList[IncludeLine - 1] = ''.join(TempList)
 
+                #  
+                #  Fix back-to-back !include in fdf parsing
+                #  For example:
+                #    !include Nt32Pkg/a.fdf
+                #    !include Nt32Pkg/b.fdf
+                #  Without this change the preprocessor will not expand b.fdf.
+                #
+                self.CurrentOffsetWithinLine = 0
         self.Rewind()
         
     def __GetIfListCurrentItemStat(self, IfList):
--
1.9.5.msysgit.1


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to