| 553 | } |
| 554 | |
| 555 | static std::string normalizeEOL(Reader::Location begin, Reader::Location end) { |
| 556 | std::string normalized; |
| 557 | normalized.reserve(end - begin); |
| 558 | Reader::Location current = begin; |
| 559 | while (current != end) { |
| 560 | char c = *current++; |
| 561 | if (c == '\r') { |
| 562 | if (current != end && *current == '\n') |
| 563 | // convert dos EOL |
| 564 | ++current; |
| 565 | // convert Mac EOL |
| 566 | normalized += '\n'; |
| 567 | } else { |
| 568 | normalized += c; |
| 569 | } |
| 570 | } |
| 571 | return normalized; |
| 572 | } |
| 573 | |
| 574 | void |
| 575 | Reader::addComment(Location begin, Location end, CommentPlacement placement) { |