| 507 | } |
| 508 | |
| 509 | static std::string normalizeEOL(Reader::Location begin, Reader::Location end) { |
| 510 | std::string normalized; |
| 511 | normalized.reserve(end - begin); |
| 512 | Reader::Location current = begin; |
| 513 | while (current != end) { |
| 514 | char c = *current++; |
| 515 | if (c == '\r') { |
| 516 | if (current != end && *current == '\n') |
| 517 | // convert dos EOL |
| 518 | ++current; |
| 519 | // convert Mac EOL |
| 520 | normalized += '\n'; |
| 521 | } else { |
| 522 | normalized += c; |
| 523 | } |
| 524 | } |
| 525 | return normalized; |
| 526 | } |
| 527 | |
| 528 | void Reader::addComment(Location begin, Location end, CommentPlacement placement) { |
| 529 | assert(collectComments_); |