MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / stringify_source_spacing

Function stringify_source_spacing

internal/cbm/preprocessor.cpp:410–432  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

408// QN dedup (strcmp) missing it. A gap that held whitespace or a comment is still
409// one space, as before.
410static 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
434static bool build_line_map(const std::string &expanded, const std::string &main_file,
435 uint32_t *original_line_by_expanded_line,

Callers 1

cbm_preprocess_with_mapFunction · 0.85

Calls 1

tokens_source_adjacentFunction · 0.85

Tested by

no test coverage detected