Skip to content

Commit

Permalink
removed remaining stream usage from checking
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Sep 23, 2024
1 parent df92530 commit d225248
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,7 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string
{
return checkInternal(file, cfgname,
[&file](TokenList& list) {
std::ifstream in(file.spath());
list.createTokens(in, file.spath());
list.createTokens(file.spath());
},
[&file](std::vector<std::string>& files, simplecpp::OutputList* outputList) {
return simplecpp::TokenList{file.spath(), files, outputList};
Expand Down
8 changes: 4 additions & 4 deletions lib/tokenlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,13 @@ void TokenList::insertTokens(Token *dest, const Token *src, nonneg int n)
// Tokenize - tokenizes a given file.
//---------------------------------------------------------------------------

bool TokenList::createTokens(std::istream &code, const std::string& file0)
bool TokenList::createTokens(const std::string& file0)
{
ASSERT_LANG(!file0.empty());

appendFileIfNew(file0);

return createTokensInternal(code, file0);
return createTokensInternal(file0);
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -371,10 +371,10 @@ bool TokenList::createTokens(const uint8_t* data, size_t size, Standards::Langua

//---------------------------------------------------------------------------

bool TokenList::createTokensInternal(std::istream &code, const std::string& file0)
bool TokenList::createTokensInternal(const std::string& file0)
{
simplecpp::OutputList outputList;
simplecpp::TokenList tokens(code, mFiles, file0, &outputList);
simplecpp::TokenList tokens(file0, mFiles, &outputList);

createTokens(std::move(tokens));

Expand Down
5 changes: 2 additions & 3 deletions lib/tokenlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ class CPPCHECKLIB TokenList {
* - multiline strings are not handled.
* - UTF in the code are not handled.
* - comments are not handled.
* @param code input stream for code
* @param file0 source file name
*/
bool createTokens(std::istream &code, const std::string& file0);
bool createTokens(const std::string& file0);
bool createTokens(const uint8_t* data, size_t size, const std::string& file0);
bool createTokens(const char* data, size_t size, const std::string& file0) {
return createTokens(reinterpret_cast<const uint8_t*>(data), size, file0);
Expand Down Expand Up @@ -219,7 +218,7 @@ class CPPCHECKLIB TokenList {
private:
void determineCppC();

bool createTokensInternal(std::istream &code, const std::string& file0);
bool createTokensInternal(const std::string& file0);
bool createTokensInternal(const uint8_t* data, std::size_t size, const std::string& file0);

/** Token list */
Expand Down

0 comments on commit d225248

Please sign in to comment.