MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / stringify

Method stringify

externals/simplecpp/simplecpp.cpp:567–601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

565}
566
567std::string simplecpp::TokenList::stringify(bool linenrs) const
568{
569 std::ostringstream ret;
570 Location loc;
571 loc.line = 1;
572 bool filechg = true;
573 for (const Token *tok = cfront(); tok; tok = tok->next) {
574 if (tok->location.line < loc.line || tok->location.fileIndex != loc.fileIndex) {
575 ret << "\n#line " << tok->location.line << " \"" << file(tok->location) << "\"\n";
576 loc = tok->location;
577 filechg = true;
578 }
579
580 if (linenrs && filechg) {
581 ret << loc.line << ": ";
582 filechg = false;
583 }
584
585 while (tok->location.line > loc.line) {
586 ret << '\n';
587 loc.line++;
588 if (linenrs)
589 ret << loc.line << ": ";
590 }
591
592 if (sameline(tok->previous, tok))
593 ret << ' ';
594
595 ret << tok->str();
596
597 loc.adjust(tok->str());
598 }
599
600 return ret.str();
601}
602
603static bool isNameChar(int ch)
604{

Callers

nothing calls this directly

Calls 4

cfrontFunction · 0.85
adjustMethod · 0.80
samelineFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected