Removes //-comments and single-line C-style /* */ comments. Args: line: A line of C++ source. Returns: The line with single-line comments removed.
(line)
| 1887 | |
| 1888 | |
| 1889 | def CleanseComments(line): |
| 1890 | """Removes //-comments and single-line C-style /* */ comments. |
| 1891 | |
| 1892 | Args: |
| 1893 | line: A line of C++ source. |
| 1894 | |
| 1895 | Returns: |
| 1896 | The line with single-line comments removed. |
| 1897 | """ |
| 1898 | commentpos = line.find('//') |
| 1899 | if commentpos != -1 and not IsCppString(line[:commentpos]): |
| 1900 | line = line[:commentpos].rstrip() |
| 1901 | # get rid of /* ... */ |
| 1902 | return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) |
| 1903 | |
| 1904 | |
| 1905 | class CleansedLines(object): |
no test coverage detected