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