The expanded buffer in the source's own spelling. Mirrors simplecpp::TokenList::stringify() line for line — the same newlines and #line directives, so build_line_map and every line-based remap are unchanged — except that tokens which touched in the source stay touching. stringify() joins every same-line pair with one space, so the second pass spelled a multi-token name differently from the raw pas
| 408 | // QN dedup (strcmp) missing it. A gap that held whitespace or a comment is still |
| 409 | // one space, as before. |
| 410 | static std::string stringify_source_spacing(const simplecpp::TokenList &tokens) { |
| 411 | std::ostringstream ret; |
| 412 | simplecpp::Location loc; |
| 413 | loc.line = 1; |
| 414 | for (const simplecpp::Token *tok = tokens.cfront(); tok; tok = tok->next) { |
| 415 | if (tok->location.line < loc.line || tok->location.fileIndex != loc.fileIndex) { |
| 416 | ret << "\n#line " << tok->location.line << " \"" << tokens.file(tok->location) |
| 417 | << "\"\n"; |
| 418 | loc = tok->location; |
| 419 | } |
| 420 | while (tok->location.line > loc.line) { |
| 421 | ret << '\n'; |
| 422 | loc.line++; |
| 423 | } |
| 424 | const simplecpp::Token *prev = tok->previous; |
| 425 | if (prev && prev->location.sameline(tok->location) && !tokens_source_adjacent(prev, tok)) { |
| 426 | ret << ' '; |
| 427 | } |
| 428 | ret << tok->str(); |
| 429 | loc.adjust(tok->str()); |
| 430 | } |
| 431 | return ret.str(); |
| 432 | } |
| 433 | |
| 434 | static bool build_line_map(const std::string &expanded, const std::string &main_file, |
| 435 | uint32_t *original_line_by_expanded_line, |
no test coverage detected