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

Method simplifyMicrosoftStringFunctions

lib/tokenize.cpp:10512–10545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10510}
10511
10512void Tokenizer::simplifyMicrosoftStringFunctions()
10513{
10514 // skip if not Windows
10515 if (!mSettings.platform.isWindows())
10516 return;
10517
10518 const bool ansi = (mSettings.platform.type == Platform::Type::Win32A); // TODO: check for UNICODE define instead
10519 for (Token *tok = list.front(); tok; tok = tok->next()) {
10520 if (tok->strAt(1) != "(")
10521 continue;
10522
10523 const auto match = apis.find(tok->str());
10524 if (match!=apis.end()) {
10525 tok->str(ansi ? match->second.mbcs : match->second.unicode);
10526 tok->originalName(match->first);
10527 } else if (Token::Match(tok, "_T|_TEXT|TEXT ( %char%|%str% )")) {
10528 tok->deleteNext();
10529 tok->deleteThis();
10530 tok->deleteNext();
10531 if (!ansi) {
10532 tok->isLong(true);
10533 if (tok->str()[0] != 'L')
10534 tok->str("L" + tok->str());
10535 }
10536 while (Token::Match(tok->next(), "_T|_TEXT|TEXT ( %char%|%str% )")) {
10537 tok->next()->deleteNext();
10538 tok->next()->deleteThis();
10539 tok->next()->deleteNext();
10540 tok->concatStr(tok->strAt(1));
10541 tok->deleteNext();
10542 }
10543 }
10544 }
10545}
10546
10547// Remove Borland code
10548void Tokenizer::simplifyBorland()

Callers

nothing calls this directly

Calls 8

frontMethod · 0.80
nextMethod · 0.80
deleteNextMethod · 0.80
deleteThisMethod · 0.80
findMethod · 0.45
strMethod · 0.45
endMethod · 0.45
concatStrMethod · 0.45

Tested by

no test coverage detected