| 516 | } |
| 517 | |
| 518 | static std::string normalizeEOL(Reader::Location begin, Reader::Location end) { |
| 519 | std::string normalized; |
| 520 | normalized.reserve(end - begin); |
| 521 | Reader::Location current = begin; |
| 522 | while (current != end) { |
| 523 | char c = *current++; |
| 524 | if (c == '\r') { |
| 525 | if (current != end && *current == '\n') |
| 526 | // convert dos EOL |
| 527 | ++current; |
| 528 | // convert Mac EOL |
| 529 | normalized += '\n'; |
| 530 | } else { |
| 531 | normalized += c; |
| 532 | } |
| 533 | } |
| 534 | return normalized; |
| 535 | } |
| 536 | |
| 537 | void |
| 538 | Reader::addComment(Location begin, Location end, CommentPlacement placement) { |