ECC: ignore restricted packages and not wipe off comments in c files.
authorjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 29 Jan 2008 11:04:51 +0000 (11:04 +0000)
committerjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 29 Jan 2008 11:04:51 +0000 (11:04 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@991 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Ecc/CodeFragmentCollector.py
Source/Python/Ecc/c.py

index 6c88705..2f9798d 100644 (file)
@@ -330,10 +330,10 @@ class CodeFragmentCollector:
             # check for */ comment end\r
             elif InComment and not DoubleSlashComment and not HashComment and self.__CurrentChar() == T_CHAR_STAR and self.__NextChar() == T_CHAR_SLASH:\r
                 CommentObj.Content += self.__CurrentChar()\r
-                self.__SetCurrentCharValue(T_CHAR_SPACE)\r
+#                self.__SetCurrentCharValue(T_CHAR_SPACE)\r
                 self.__GetOneChar()\r
                 CommentObj.Content += self.__CurrentChar()\r
-                self.__SetCurrentCharValue(T_CHAR_SPACE)\r
+#                self.__SetCurrentCharValue(T_CHAR_SPACE)\r
                 CommentObj.EndPos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine)\r
                 FileProfile.CommentList.append(CommentObj)\r
                 CommentObj = None\r
@@ -352,9 +352,10 @@ class CodeFragmentCollector:
                         continue\r
                     else:\r
                         PPDirectiveObj.Content += self.__CurrentChar()\r
+                    self.__SetCurrentCharValue(T_CHAR_SPACE)\r
                 else:\r
                     CommentObj.Content += self.__CurrentChar()\r
-                self.__SetCurrentCharValue(T_CHAR_SPACE)\r
+#                self.__SetCurrentCharValue(T_CHAR_SPACE)\r
                 self.__GetOneChar()\r
             # check for // comment\r
             elif self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_SLASH:\r
@@ -364,19 +365,16 @@ class CodeFragmentCollector:
             # check for '#' comment\r
             elif self.__CurrentChar() == T_CHAR_HASH and not InString and not InCharLiteral:\r
                 InComment = True\r
-                HashComment = True\r
-                #insert ',' at hash line to workaround PP effects on C grammar check. C parser also adjusted to accomodate the inserted comma.\r
-                #self.__InsertComma(self.CurrentLineNumber) \r
+                HashComment = True \r
                 PPDirectiveObj = PP_Directive('', (self.CurrentLineNumber, self.CurrentOffsetWithinLine), None)\r
-                #self.CurrentOffsetWithinLine += 1\r
             # check for /* comment start\r
             elif self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_STAR:\r
                 CommentObj = Comment('', (self.CurrentLineNumber, self.CurrentOffsetWithinLine), None, T_COMMENT_SLASH_STAR)\r
                 CommentObj.Content += self.__CurrentChar()\r
-                self.__SetCurrentCharValue( T_CHAR_SPACE)\r
+#                self.__SetCurrentCharValue( T_CHAR_SPACE)\r
                 self.__GetOneChar()\r
                 CommentObj.Content += self.__CurrentChar()\r
-                self.__SetCurrentCharValue( T_CHAR_SPACE)\r
+#                self.__SetCurrentCharValue( T_CHAR_SPACE)\r
                 self.__GetOneChar()\r
                 InComment = True\r
             else:\r
index fa44f37..0a97f40 100644 (file)
@@ -1,13 +1,15 @@
 import sys\r
 import os\r
+import re\r
 import CodeFragmentCollector\r
 import FileProfile\r
 from CommonDataClass import DataClass\r
 import Database\r
 from Common import EdkLogger\r
 \r
-def GetIgnoredDirList():\r
-    return ('Build', 'IntelRestrictedPkg', 'IntelRestrictedTools')\r
+def GetIgnoredDirListPattern():\r
+    p = re.compile(r'.*[\\/](?:BUILD|INTELRESTRICTEDTOOLS|INTELRESTRICTEDPKG)[\\/].*')\r
+    return p\r
 \r
 def GetIdType(Str):\r
     Type = DataClass.MODEL_UNKNOWN\r
@@ -135,13 +137,12 @@ if __name__ == '__main__':
 \r
     FileObjList = []\r
     tuple = os.walk(sys.argv[1])\r
-\r
+    IgnoredPattern = GetIgnoredDirListPattern()\r
     ParseErrorFileList = []\r
 \r
     for dirpath, dirnames, filenames in tuple:\r
-        for d in dirnames:\r
-            if d.startswith('.') or d in GetIgnoredDirList():\r
-                dirnames.remove(d)\r
+        if IgnoredPattern.match(dirpath.upper()):\r
+            continue\r
         for f in filenames:\r
             FullName = os.path.join(dirpath, f)\r
             \r
@@ -168,7 +169,6 @@ if __name__ == '__main__':
     EdkLogger.SetLevel(EdkLogger.QUIET)\r
     Db = Database.Database(Database.DATABASE_PATH)\r
     Db.InitDatabase()\r
-    Db.QueryTable(Db.TblDataModel)\r
     \r
     for file in FileObjList:    \r
         Db.InsertOneFile(file)\r