mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-26 03:39:53 +01:00
slightly faster regexp for replacing c/c++ comments
This commit is contained in:
parent
b0bae3baa1
commit
7af8b2f268
@ -84,9 +84,7 @@ re_pragma_once = re.compile('^\s*once\s*', re.IGNORECASE)
|
||||
re_nl = re.compile('\\\\\r*\n', re.MULTILINE)
|
||||
"""Match newlines"""
|
||||
|
||||
re_cpp = re.compile(
|
||||
r"""(/\*[^*]*\*+([^/*][^*]*\*+)*/)|//[^\n]*|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)""",
|
||||
re.MULTILINE)
|
||||
re_cpp = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE )
|
||||
"""Filter C/C++ comments"""
|
||||
|
||||
trig_def = [('??'+a, b) for a, b in zip("=-/!'()<>", r'#~\|^[]{}')]
|
||||
@ -138,10 +136,10 @@ skipped = 's'
|
||||
|
||||
def repl(m):
|
||||
"""Replace function used with :py:attr:`waflib.Tools.c_preproc.re_cpp`"""
|
||||
s = m.group(1)
|
||||
if s:
|
||||
s = m.group(0)
|
||||
if s.startswith('/'):
|
||||
return ' '
|
||||
return m.group(3) or ''
|
||||
return s
|
||||
|
||||
def filter_comments(filename):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user