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