Skip to content
Snippets Groups Projects
Commit f1dc3dee authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

Merge pull request #6568 from dgquintas/fix-include-guards-long-names

Allow for multiline #endif guards
parents 305b0f4e 93466168
No related branches found
No related tags found
No related merge requests found
...@@ -56,7 +56,7 @@ class GuardValidator(object): ...@@ -56,7 +56,7 @@ class GuardValidator(object):
def __init__(self): def __init__(self):
self.ifndef_re = re.compile(r'#ifndef ([A-Z][A-Z_1-9]*)') self.ifndef_re = re.compile(r'#ifndef ([A-Z][A-Z_1-9]*)')
self.define_re = re.compile(r'#define ([A-Z][A-Z_1-9]*)') self.define_re = re.compile(r'#define ([A-Z][A-Z_1-9]*)')
self.endif_c_re = re.compile(r'#endif /\* ([A-Z][A-Z_1-9]*) \*/') self.endif_c_re = re.compile(r'#endif /\* ([A-Z][A-Z_1-9]*) (?:\\ *\n *)?\*/')
self.endif_cpp_re = re.compile(r'#endif // ([A-Z][A-Z_1-9]*)') self.endif_cpp_re = re.compile(r'#endif // ([A-Z][A-Z_1-9]*)')
self.failed = False self.failed = False
...@@ -132,7 +132,7 @@ class GuardValidator(object): ...@@ -132,7 +132,7 @@ class GuardValidator(object):
# Is there a properly commented #endif? # Is there a properly commented #endif?
endif_re = self.endif_cpp_re if cpp_header else self.endif_c_re endif_re = self.endif_cpp_re if cpp_header else self.endif_c_re
flines = fcontents.rstrip().splitlines() flines = fcontents.rstrip().splitlines()
match = endif_re.search(flines[-1]) match = endif_re.search('\n'.join(flines[-2:]))
if not match: if not match:
# No endif. Check if we have the last line as just '#endif' and if so # No endif. Check if we have the last line as just '#endif' and if so
# replace it with a properly commented one. # replace it with a properly commented one.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment