Skip to content

Commit 24d96f4

Browse files
committed
Add newlines to strings passed to simplecpp readfile
1 parent d29586b commit 24d96f4

5 files changed

Lines changed: 8 additions & 7 deletions

File tree

lib/importproject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ namespace {
648648
}
649649

650650
static bool evalCondition(const std::string& condition, const ProjectConfiguration &p) {
651-
std::string c = '(' + condition + ")";
651+
std::string c = '(' + condition + ")\n";
652652
replaceAll(c, "$(Configuration)", p.configuration);
653653
replaceAll(c, "$(Platform)", p.platformStr);
654654

lib/library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static std::vector<std::string> getnames(const char *names)
177177

178178
static void gettokenlistfromvalid(const std::string& valid, TokenList& tokenList)
179179
{
180-
const std::string str(valid + ',');
180+
const std::string str(valid + ",\n");
181181
tokenList.createTokensFromBuffer(str.data(), str.size()); // TODO: check result?
182182
for (Token *tok = tokenList.front(); tok; tok = tok->next()) {
183183
if (Token::Match(tok,"- %num%")) {

lib/programmemory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@ static std::shared_ptr<Token> createTokenFromExpression(const std::string& retur
19371937
{
19381938
std::shared_ptr<TokenList> tokenList = std::make_shared<TokenList>(settings, cpp ? Standards::Language::CPP : Standards::Language::C);
19391939
{
1940-
const std::string code = "return " + returnValue + ";";
1940+
const std::string code = "return " + returnValue + ";\n";
19411941
if (!tokenList->createTokensFromBuffer(code.data(), code.size()))
19421942
return nullptr;
19431943
}

lib/symboldatabase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8093,7 +8093,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
80938093
if (!typestr.empty()) {
80948094
ValueType valuetype;
80958095
TokenList tokenList(mSettings, tok->isCpp() ? Standards::Language::CPP : Standards::Language::C);
8096-
const std::string str(typestr+";");
8096+
const std::string str(typestr+";\n");
80978097
tokenList.createTokensFromBuffer(str.data(), str.size()); // TODO: check result?
80988098
tokenList.simplifyStdType();
80998099
if (parsedecl(tokenList.front(), &valuetype, mDefaultSignedness, mSettings)) {
@@ -8186,7 +8186,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
81868186
continue;
81878187
}
81888188
TokenList tokenList(mSettings, tok->isCpp() ? Standards::Language::CPP : Standards::Language::C);
8189-
const std::string str(typestr+";");
8189+
const std::string str(typestr+";\n");
81908190
if (tokenList.createTokensFromBuffer(str.data(), str.size())) {
81918191
ValueType vt;
81928192
tokenList.simplifyPlatformTypes();

lib/valueflow.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,8 @@ static bool isNotEqual(std::pair<const Token*, const Token*> x, std::pair<const
18171817
static bool isNotEqual(std::pair<const Token*, const Token*> x, const std::string& y, bool cpp, const Settings& settings)
18181818
{
18191819
TokenList tokenList(settings, cpp ? Standards::Language::CPP : Standards::Language::C);
1820-
tokenList.createTokensFromBuffer(y.data(), y.size()); // TODO: check result?
1820+
const std::string str(y + "\n");
1821+
tokenList.createTokensFromBuffer(str.data(), str.size()); // TODO: check result?
18211822
return isNotEqual(x, std::make_pair(tokenList.front(), tokenList.back()));
18221823
}
18231824
static bool isNotEqual(std::pair<const Token*, const Token*> x, const ValueType* y, bool cpp, const Settings& settings)
@@ -7095,7 +7096,7 @@ static bool getMinMaxValues(const std::string& typestr,
70957096
MathLib::bigint& maxvalue)
70967097
{
70977098
TokenList typeTokens(settings, cpp ? Standards::Language::CPP : Standards::Language::C);
7098-
const std::string str(typestr + ";");
7099+
const std::string str(typestr + ";\n");
70997100
if (!typeTokens.createTokensFromBuffer(str.data(), str.size()))
71007101
return false;
71017102
typeTokens.simplifyPlatformTypes();

0 commit comments

Comments
 (0)