Removes //-comments and single-line C-style /* */ comments. Args: line: A line of C++ source. Returns: The line with single-line comments removed.
(line)
| 1411 | |
| 1412 | |
| 1413 | def CleanseComments(line): |
| 1414 | """Removes //-comments and single-line C-style /* */ comments. |
| 1415 | |
| 1416 | Args: |
| 1417 | line: A line of C++ source. |
| 1418 | |
| 1419 | Returns: |
| 1420 | The line with single-line comments removed. |
| 1421 | """ |
| 1422 | commentpos = line.find('//') |
| 1423 | if commentpos != -1 and not IsCppString(line[:commentpos]): |
| 1424 | line = line[:commentpos].rstrip() |
| 1425 | # get rid of /* ... */ |
| 1426 | return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) |
| 1427 | |
| 1428 | |
| 1429 | class CleansedLines(object): |
no test coverage detected