Skip to content

Commit

Permalink
Merge pull request #51 from RyDroid/cpp-minor
Browse files Browse the repository at this point in the history
Minor changes to C++ source code
  • Loading branch information
thewtex committed Feb 23, 2018
2 parents 163bcbe + 4ce28de commit 12657e1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 74 deletions.
1 change: 0 additions & 1 deletion circle.yml
Expand Up @@ -12,4 +12,3 @@ test:
override:
- mkdir ~/KWStyle-build
- docker run -v ~/KWStyle:/usr/src/KWStyle -v ~/KWStyle-build:/usr/src/KWStyle-build kitware/kwstyle-testing /usr/src/KWStyle/Testing/Docker/test.sh

4 changes: 2 additions & 2 deletions kwsCheckIndent.cxx
Expand Up @@ -727,8 +727,8 @@ bool Parser::InitIndentation()
while(posClass != std::string::npos)
{
// We count the number of { and } before posClass
int nOpen = 0;
int nClose = 0;
unsigned int nOpen = 0;
unsigned int nClose = 0;

size_t open = m_BufferNoComment.find('{',0);
while(open!=std::string::npos && open<posClass)
Expand Down
38 changes: 15 additions & 23 deletions kwsGenerator.cxx
Expand Up @@ -22,11 +22,7 @@ struct DirectorySorting
{
bool operator()(const std::string& a,const std::string& b)
{
if(a.compare(b)>=0)
{
return false;
}
return true;
return a.compare(b) < 0;
}
};

Expand All @@ -36,11 +32,7 @@ struct FilenameSorting
{
std::string nameA = kwssys::SystemTools::GetFilenameName(a);
std::string nameB = kwssys::SystemTools::GetFilenameName(b);
if(nameA.compare(nameB)>=0)
{
return false;
}
return true;
return nameA.compare(nameB) < 0;
}
};

Expand Down Expand Up @@ -102,7 +94,7 @@ bool Generator::GenerateDescription(const char* dir)
}
this->CreateHeader(&file,title.c_str());

file << "<br>" << std::endl;
file << "<br />" << std::endl;

if(m_Parsers->size() > 0)
{
Expand All @@ -115,7 +107,7 @@ bool Generator::GenerateDescription(const char* dir)
file << ErrorTag[i] << std::endl;
file << "</font> : " << std::endl;
file << (*it).GetTestDescription(i).c_str() << std::endl;
file << "<br>" << std::endl;
file << "<br />" << std::endl;
}
}
}
Expand Down Expand Up @@ -776,14 +768,14 @@ bool Generator::GenerateHTML(const char* dir,bool showAllErrors)
bool Generator::CreateHeader(std::ostream * file,const char* title)
{
*file << "<html>" << std::endl;
*file << "<HEAD>" << std::endl;
*file << "<META name=\"description\" content=\"kitware.com\">" << std::endl;
*file << "<META name=\"keywords\" content=\"kwstyle,Kitware,Style,Checker,Dart\">" << std::endl;
*file << "<META name=\"author\" content=\"Kitware\">" << std::endl;
*file << "<META name=\"revisit-after\" content=\"2 days\">" << std::endl;
*file << "<META name=\"robots\" content=\"all\">" << std::endl;
*file << "<title>KWStyle - " << title << "</title>" << std::endl;
*file << "</HEAD>" << std::endl;
*file << "<head>" << std::endl;
*file << " <meta name=\"description\" content=\"kitware.com\" />" << std::endl;
*file << " <meta name=\"keywords\" content=\"kwstyle,Kitware,Style,Checker,Dart\" />" << std::endl;
*file << " <meta name=\"author\" content=\"Kitware\" />" << std::endl;
*file << " <meta name=\"revisit-after\" content=\"2 days\" />" << std::endl;
*file << " <meta name=\"robots\" content=\"all\" />" << std::endl;
*file << " <title>KWStyle - " << title << "</title>" << std::endl;
*file << "</head>" << std::endl;

// Now create the top frame
*file << "<table width=\"100%\" border=\"0\">" << std::endl;
Expand Down Expand Up @@ -833,19 +825,19 @@ bool Generator::CreateFooter(std::ostream * file)
*file << "<hr size=\"1\">";
*file << "<table width=\"100%\" border=\"0\">";
*file << "<tr>";
*file << "<td>Generated by <a href=\"http://public.kitware.com/KWStyle\">KWStyle</a> 1.0b on <i>" << kwssys::SystemTools::GetCurrentDateTime("%A %B,%d at %I:%M:%S%p") << "</i></td>";
*file << "<td>Generated by <a href=\"https://public.kitware.com/KWStyle\">KWStyle</a> 1.0b on <i>" << kwssys::SystemTools::GetCurrentDateTime("%A %B,%d at %I:%M:%S%p") << "</i></td>";
*file << "<td>";
if(m_KWStyleLogo.size()>0)
{
*file << "<div align=\"center\"><img src=\"images/" << kwssys::SystemTools::GetFilenameName(m_KWStyleLogo.c_str())
<< "\" height=\"49\"></div>" << std::endl;
<< "\" height=\"49\" /></div>" << std::endl;
}
*file << "</td>";
*file << "<td>";
*file << "<div align=\"right\"><a href=\"http://www.kitware.com\">&copy; Kitware Inc.</a></div></td>";
*file << "</tr>";
*file << "</table>";
*file << "<br>";
*file << "<br />";

*file << "</html>" << std::endl;

Expand Down
68 changes: 25 additions & 43 deletions kwsParser.cxx
Expand Up @@ -45,11 +45,7 @@ Parser::~Parser()
/** To be able to use std::sort we provide the < operator */
bool Parser::operator<(const Parser& a) const
{
if(m_Filename.compare(a.m_Filename))
{
return false;
}
return true;
return !m_Filename.compare(a.m_Filename);
}

/** Given the name of the check to perform and the default value perform the check */
Expand All @@ -60,12 +56,12 @@ bool Parser::Check(const char* name, const char* value)
this->CheckLineLength(atoi(value));
return true;
}
else if(!strcmp(name,"DeclarationOrder"))
if(!strcmp(name,"DeclarationOrder"))
{
this->CheckDeclarationOrder(atoi(&value[0]),atoi(&value[2]),atoi(&value[4]));
return true;
}
else if(!strcmp(name,"Typedefs"))
if(!strcmp(name,"Typedefs"))
{
bool alignment = true; // check alignment by default
std::string val = value;
Expand Down Expand Up @@ -97,7 +93,7 @@ bool Parser::Check(const char* name, const char* value)
this->CheckTypedefs(val.c_str(),alignment);
return true;
}
else if(!strcmp(name,"InternalVariables"))
if(!strcmp(name,"InternalVariables"))
{
bool alignment = true; // check alignment by default
bool checkProtected = false; // check protected by default
Expand Down Expand Up @@ -151,17 +147,17 @@ bool Parser::Check(const char* name, const char* value)

return true;
}
else if(!strcmp(name,"Variables"))
if(!strcmp(name,"Variables"))
{
this->CheckVariables(value);
return true;
}
else if(!strcmp(name,"Struct"))
if(!strcmp(name,"Struct"))
{
this->CheckStruct(value);
return true;
}
else if(!strcmp(name,"MemberFunctions"))
if(!strcmp(name,"MemberFunctions"))
{
std::string val = value;
std::string v1 = value;
Expand All @@ -175,7 +171,7 @@ bool Parser::Check(const char* name, const char* value)
this->CheckMemberFunctions(v1.c_str(),atoi(v2.c_str()));
return true;
}
else if(!strcmp(name,"Functions"))
if(!strcmp(name,"Functions"))
{
std::string val = value;
std::string v1 = value;
Expand All @@ -189,27 +185,27 @@ bool Parser::Check(const char* name, const char* value)
this->CheckFunctions(v1.c_str(),atoi(v2.c_str()));
return true;
}
else if(!strcmp(name,"SemicolonSpace"))
if(!strcmp(name,"SemicolonSpace"))
{
this->CheckSemicolonSpace(atoi(value));
return true;
}
else if(!strcmp(name,"EndOfFileNewLine"))
if(!strcmp(name,"EndOfFileNewLine"))
{
this->CheckEndOfFileNewLine();
return true;
}
else if(!strcmp(name,"Tabs"))
if(!strcmp(name,"Tabs"))
{
this->CheckTabs();
return true;
}
else if(!strcmp(name,"Spaces"))
if(!strcmp(name,"Spaces"))
{
this->CheckExtraSpaces(atoi(value));
return true;
}
else if(!strcmp(name,"StatementPerLine"))
if(!strcmp(name,"StatementPerLine"))
{
std::string val = value;
std::string v1 = value;
Expand All @@ -228,24 +224,17 @@ bool Parser::Check(const char* name, const char* value)
this->CheckStatementPerLine(atoi(v1.c_str()),checkInlineFunctions);
return true;
}
else if(!strcmp(name,"BadCharacters"))
if(!strcmp(name,"BadCharacters"))
{
if(!strcmp(value,"true"))
{
this->CheckBadCharacters(true);
}
else
{
this->CheckBadCharacters(false);
}
this->CheckBadCharacters(!strcmp(value,"true"));
return true;
}
else if(!strcmp(name,"VariablePerLine"))
if(!strcmp(name,"VariablePerLine"))
{
this->CheckVariablePerLine(atoi(value));
return true;
}
else if(!strcmp(name,"Comments"))
if(!strcmp(name,"Comments"))
{
std::string val = value;
long pos = static_cast<long>(val.find(",",0));
Expand Down Expand Up @@ -282,11 +271,7 @@ bool Parser::Check(const char* name, const char* value)
v4 = val.substr(pos+1,pos1-pos-1);
}

bool allowEmptyLine = false;
if(!strcmp(v4.c_str(),"true"))
{
allowEmptyLine = true;
}
bool allowEmptyLine = !strcmp(v4.c_str(),"true");

// Check if we should check the comments misspeling
pos = static_cast<long>(val.find(",",pos1+1));
Expand Down Expand Up @@ -1262,7 +1247,7 @@ size_t Parser::FindFunction(size_t pos,const char* buffer) const
{
return beg;
}
else if(i != std::string::npos)// check if we have a const
if(i != std::string::npos)// check if we have a const
{
if(buf.substr(i,beg-i).find("]") == std::string::npos &&
buf.substr(i,beg-i).find("const") != std::string::npos
Expand Down Expand Up @@ -1466,11 +1451,7 @@ bool Parser::IsValidQuote(std::string & stream,size_t pos) const
i--;
}

if(n%2==0)
{
return true;
}
return false;
return n % 2 == 0;
}

/** return true if the position pos is between ' ' */
Expand Down Expand Up @@ -1893,10 +1874,7 @@ size_t Parser::FindConstructor(const std::string & buffer, const std::string & c
{
return pos5;
}
else
{
return std::string::npos;
}
return std::string::npos;
}
}
std::string localconstructor = "";
Expand Down Expand Up @@ -2093,6 +2071,10 @@ size_t Parser::FindOpeningChar(char closeChar, char openChar,size_t pos,bool noC
{
close--;
}
else
{
continue;
}
if(close == 0)
{
return i;
Expand Down
7 changes: 2 additions & 5 deletions metaCommand.h
Expand Up @@ -106,10 +106,7 @@ class MetaCommand
{
return this->AddField(name,description,type,DATA_IN);
}
else
{
return this->AddField(name,description,type,DATA_NONE);
}
return this->AddField(name,description,type,DATA_NONE);
}


Expand Down Expand Up @@ -252,4 +249,4 @@ class MetaCommand
};
#endif

#endif
#endif

0 comments on commit 12657e1

Please sign in to comment.