ECC: CParser remove \ in string.
[people/mcb30/basetools.git] / Source / Python / Ecc / CodeFragmentCollector.py
index 30e6c5e..6c88705 100644 (file)
@@ -218,6 +218,16 @@ class CodeFragmentCollector:
     def __SetCurrentCharValue(self, Value):\r
         self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine] = Value\r
         \r
+    ## __SetCharValue() method\r
+    #\r
+    #   Modify the value of current char\r
+    #\r
+    #   @param  self        The object pointer\r
+    #   @param  Value       The new value of current char\r
+    #\r
+    def __SetCharValue(self, Line, Offset, Value):\r
+        self.Profile.FileLinesList[Line - 1][Offset] = Value\r
+        \r
     ## __CurrentLine() method\r
     #\r
     #   Get the list that contains current line contents\r
@@ -278,10 +288,10 @@ class CodeFragmentCollector:
 \r
         while not self.__EndOfFile():\r
             \r
-            if self.__CurrentChar() == T_CHAR_DOUBLE_QUOTE:\r
+            if self.__CurrentChar() == T_CHAR_DOUBLE_QUOTE and not InComment:\r
                 InString = not InString\r
                 \r
-            if self.__CurrentChar() == T_CHAR_SINGLE_QUOTE:\r
+            if self.__CurrentChar() == T_CHAR_SINGLE_QUOTE and not InComment:\r
                 InCharLiteral = not InCharLiteral\r
             # meet new line, then no longer in a comment for // and '#'\r
             if self.__CurrentChar() == T_CHAR_LF:\r
@@ -293,8 +303,7 @@ class CodeFragmentCollector:
                         PPExtend = False\r
                         \r
                 EndLinePos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine)\r
-                self.CurrentLineNumber += 1\r
-                self.CurrentOffsetWithinLine = 0\r
+                \r
                 if InComment and DoubleSlashComment:\r
                     InComment = False\r
                     DoubleSlashComment = False\r
@@ -309,7 +318,15 @@ class CodeFragmentCollector:
                     PPDirectiveObj.EndPos = EndLinePos\r
                     FileProfile.PPDirectiveList.append(PPDirectiveObj)\r
                     PPDirectiveObj = None\r
-                    \r
+                \r
+                if InString or InCharLiteral:\r
+                    CurrentLine = "".join(self.__CurrentLine())\r
+                    if CurrentLine.rstrip(T_CHAR_LF).rstrip(T_CHAR_CR).endswith(T_CHAR_BACKSLASH):\r
+                        SlashIndex = CurrentLine.rindex(T_CHAR_BACKSLASH)\r
+                        self.__SetCharValue(self.CurrentLineNumber, SlashIndex, T_CHAR_SPACE)\r
+                \r
+                self.CurrentLineNumber += 1\r
+                self.CurrentOffsetWithinLine = 0    \r
             # 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