Removes //-comments and single-line C-style /* */ comments. Args: line: A line of C++ source. Returns: The line with single-line comments removed.
(line)
| 2059 | |
| 2060 | |
| 2061 | def CleanseComments(line): |
| 2062 | """Removes //-comments and single-line C-style /* */ comments. |
| 2063 | |
| 2064 | Args: |
| 2065 | line: A line of C++ source. |
| 2066 | |
| 2067 | Returns: |
| 2068 | The line with single-line comments removed. |
| 2069 | """ |
| 2070 | commentpos = line.find("//") |
| 2071 | if commentpos != -1 and not IsCppString(line[:commentpos]): |
| 2072 | line = line[:commentpos].rstrip() |
| 2073 | # get rid of /* ... */ |
| 2074 | return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub("", line) |
| 2075 | |
| 2076 | |
| 2077 | def ReplaceAlternateTokens(line): |
no test coverage detected