| @@ 1578-1591 (lines=14) @@ | ||
| 1575 | lineix = lineix_end + 1 |
|
| 1576 | ||
| 1577 | ||
| 1578 | def CleanseComments(line): |
|
| 1579 | """Removes //-comments and single-line C-style /* */ comments. |
|
| 1580 | ||
| 1581 | Args: |
|
| 1582 | line: A line of C++ source. |
|
| 1583 | ||
| 1584 | Returns: |
|
| 1585 | The line with single-line comments removed. |
|
| 1586 | """ |
|
| 1587 | commentpos = line.find('//') |
|
| 1588 | if commentpos != -1 and not IsCppString(line[:commentpos]): |
|
| 1589 | line = line[:commentpos].rstrip() |
|
| 1590 | # get rid of /* ... */ |
|
| 1591 | return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) |
|
| 1592 | ||
| 1593 | ||
| 1594 | class CleansedLines(object): |
|
| @@ 1578-1591 (lines=14) @@ | ||
| 1575 | lineix = lineix_end + 1 |
|
| 1576 | ||
| 1577 | ||
| 1578 | def CleanseComments(line): |
|
| 1579 | """Removes //-comments and single-line C-style /* */ comments. |
|
| 1580 | ||
| 1581 | Args: |
|
| 1582 | line: A line of C++ source. |
|
| 1583 | ||
| 1584 | Returns: |
|
| 1585 | The line with single-line comments removed. |
|
| 1586 | """ |
|
| 1587 | commentpos = line.find('//') |
|
| 1588 | if commentpos != -1 and not IsCppString(line[:commentpos]): |
|
| 1589 | line = line[:commentpos].rstrip() |
|
| 1590 | # get rid of /* ... */ |
|
| 1591 | return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) |
|
| 1592 | ||
| 1593 | ||
| 1594 | class CleansedLines(object): |
|