Removes //-comments and single-line C-style /* */ comments. Args: line: A line of C++ source. Returns: The line with single-line comments removed.
(line)
| 1898 | |
| 1899 | |
| 1900 | def CleanseComments(line): |
| 1901 | """Removes //-comments and single-line C-style /* */ comments. |
| 1902 | |
| 1903 | Args: |
| 1904 | line: A line of C++ source. |
| 1905 | |
| 1906 | Returns: |
| 1907 | The line with single-line comments removed. |
| 1908 | """ |
| 1909 | commentpos = line.find('//') |
| 1910 | if commentpos != -1 and not IsCppString(line[:commentpos]): |
| 1911 | line = line[:commentpos].rstrip() |
| 1912 | # get rid of /* ... */ |
| 1913 | return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) |
| 1914 | |
| 1915 | |
| 1916 | class CleansedLines(object): |
no test coverage detected