astyle formatting

[ci skip]
This commit is contained in:
Daniel Marjamäki 2020-02-23 18:04:47 +01:00
parent 5479c7340b
commit 5ed5bf935f
2 changed files with 12 additions and 23 deletions

View File

@ -92,8 +92,7 @@ static void parseCommentToken(const simplecpp::Token *tok, std::list<Suppression
if (!(*iter).errorId.empty()) if (!(*iter).errorId.empty())
inlineSuppressions.push_back(*iter); inlineSuppressions.push_back(*iter);
} }
} } else { //single suppress format
else { //single suppress format
std::string errmsg; std::string errmsg;
Suppressions::Suppression s; Suppressions::Suppression s;
if (!s.parseComment(tok->str(), &errmsg)) if (!s.parseComment(tok->str(), &errmsg))

View File

@ -130,11 +130,10 @@ std::vector<Suppressions::Suppression> Suppressions::parseMultiSuppressComment(s
const std::size_t start_position = comment.find("[", suppress_position); const std::size_t start_position = comment.find("[", suppress_position);
const std::size_t end_position = comment.find("]", suppress_position); const std::size_t end_position = comment.find("]", suppress_position);
if ( start_position == std::string::npos if (start_position == std::string::npos
|| end_position == std::string::npos || end_position == std::string::npos
|| start_position != suppress_position+17 //there must be no space before "[" || start_position != suppress_position+17 //there must be no space before "["
|| start_position >= end_position) || start_position >= end_position) {
{
if (errorMessage && errorMessage->empty()) if (errorMessage && errorMessage->empty())
*errorMessage = "Bad multi suppression '" + comment + "'. legal format is cppcheck-suppress[errorId, errorId symbolName=arr, ...]"; *errorMessage = "Bad multi suppression '" + comment + "'. legal format is cppcheck-suppress[errorId, errorId symbolName=arr, ...]";
return suppressions; return suppressions;
@ -144,19 +143,15 @@ std::vector<Suppressions::Suppression> Suppressions::parseMultiSuppressComment(s
std::size_t current_comma_position = 0; std::size_t current_comma_position = 0;
//multi_suppressions_word maybe "[errorId1, errorId2 symbolName=arr", who just has left bracket //multi_suppressions_word maybe "[errorId1, errorId2 symbolName=arr", who just has left bracket
std::string multi_suppressions_word = comment.substr(start_position, end_position-start_position); std::string multi_suppressions_word = comment.substr(start_position, end_position-start_position);
do do {
{
std::string suppression_word; std::string suppression_word;
//single suppression word //single suppression word
const std::size_t previous_comma_position=current_comma_position; const std::size_t previous_comma_position=current_comma_position;
current_comma_position=multi_suppressions_word.find(",", previous_comma_position+1); //find "," after previous comma current_comma_position=multi_suppressions_word.find(",", previous_comma_position+1); //find "," after previous comma
if (current_comma_position == std::string::npos) if (current_comma_position == std::string::npos) {
{
suppression_word = multi_suppressions_word.substr(previous_comma_position+1); suppression_word = multi_suppressions_word.substr(previous_comma_position+1);
} } else {
else
{
suppression_word = multi_suppressions_word.substr(previous_comma_position+1, current_comma_position-previous_comma_position-1); suppression_word = multi_suppressions_word.substr(previous_comma_position+1, current_comma_position-previous_comma_position-1);
} }
@ -168,27 +163,22 @@ std::vector<Suppressions::Suppression> Suppressions::parseMultiSuppressComment(s
std::istringstream iss(suppression_word); std::istringstream iss(suppression_word);
iss >> errorId; iss >> errorId;
if (!iss) if (!iss) {
{
if (errorMessage && errorMessage->empty()) if (errorMessage && errorMessage->empty())
*errorMessage = "Bad multi suppression '" + comment + "'. legal format is cppcheck-suppress[errorId, errorId symbolName=arr, ...]"; *errorMessage = "Bad multi suppression '" + comment + "'. legal format is cppcheck-suppress[errorId, errorId symbolName=arr, ...]";
suppressions.clear(); suppressions.clear();
return suppressions; return suppressions;
} }
while (iss) while (iss) {
{
iss >> word; iss >> word;
if (!iss) if (!iss)
break; break;
if (word.find_first_not_of("+-*/%#;") == std::string::npos) if (word.find_first_not_of("+-*/%#;") == std::string::npos)
break; break;
if (word.compare(0, 11, "symbolName=") == 0) if (word.compare(0, 11, "symbolName=") == 0) {
{
symbolName = word.substr(11); symbolName = word.substr(11);
} } else {
else
{
if (errorMessage && errorMessage->empty()) if (errorMessage && errorMessage->empty())
*errorMessage = "Bad multi suppression '" + comment + "'. legal format is cppcheck-suppress[errorId, errorId symbolName=arr, ...]"; *errorMessage = "Bad multi suppression '" + comment + "'. legal format is cppcheck-suppress[errorId, errorId symbolName=arr, ...]";
suppressions.clear(); suppressions.clear();
@ -200,7 +190,7 @@ std::vector<Suppressions::Suppression> Suppressions::parseMultiSuppressComment(s
s.symbolName = symbolName; s.symbolName = symbolName;
suppressions.push_back(s); suppressions.push_back(s);
} while(current_comma_position!=std::string::npos); } while (current_comma_position!=std::string::npos);
return suppressions; return suppressions;
} }