Commits

senex committed 859cf19

Fixed bug 3569663: Crashes parsing indented #define

Comments (0)

Files changed (2)

CppHeaderParser/CppHeaderParser.py

 
         # Strip out #defines
         # Based from http://stackoverflow.com/questions/2424458/regular-expression-to-match-cs-multiline-preprocessor-statements
-        matches = re.findall(r'(?m)^#[Dd][Ee][Ff][Ii][Nn][Ee] (?:.*\\\r?\n)*.*$', headerFileStr)
+        matches = re.findall(r'(?m)^[ \t\v]*#[Dd][Ee][Ff][Ii][Nn][Ee] (?:.*\\\r?\n)*.*$', headerFileStr)
         for m in matches:
             #Keep the newlines so that linecount doesnt break
-            self._precomp_macro_buf.append(m)
             num_newlines = len(filter(lambda a: a=="\n", m))
             new_m = m.replace("\n", "<CppHeaderParser_newline_temp_replacement>\\n")
             if (num_newlines > 1):

CppHeaderParser/test/test_CppHeaderParser.py

 
 
 
-# Bug 3567217
+# Bug 3567217 and 3569663
 class Macro_TestCase(unittest.TestCase):
 
     def setUp(self):
 #define TWO_NUM_N_NAME "2 (TWO)"
 #pragma once
 
-#define DEBUG_PRINT(x)           \
+ #define DEBUG_PRINT(x)           \
     printf("---------------\n"); \
     printf("DEBUG: %d\n", x);    \
     printf("---------------\n");""", "string")