Removes //-comments and single-line C-style /* */ comments. Args: line: A line of C++ source. Returns: The line with single-line comments removed.
(line)
| 1165 | |
| 1166 | |
| 1167 | def CleanseComments(line): |
| 1168 | """Removes //-comments and single-line C-style /* */ comments. |
| 1169 | |
| 1170 | Args: |
| 1171 | line: A line of C++ source. |
| 1172 | |
| 1173 | Returns: |
| 1174 | The line with single-line comments removed. |
| 1175 | """ |
| 1176 | commentpos = line.find('//') |
| 1177 | if commentpos != -1 and not IsCppString(line[:commentpos]): |
| 1178 | line = line[:commentpos].rstrip() |
| 1179 | # get rid of /* ... */ |
| 1180 | return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) |
| 1181 | |
| 1182 | |
| 1183 | class CleansedLines(object): |
no test coverage detected