Skip to content

Commit

Permalink
COMP: Improve type size correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
dzenanz committed Jan 14, 2025
1 parent 2b53cb5 commit eb1e46d
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 34 deletions.
4 changes: 2 additions & 2 deletions kwsCheckHeader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ bool Parser::CheckHeader(const char* filename, bool considerSpaceEOL,bool useCVS

unsigned int pos = 0;
unsigned int posh = 0;
int line = -1;
long line = -1;


while((ith != buffer.end()) && (it != m_Buffer.end()))
Expand Down Expand Up @@ -245,7 +245,7 @@ bool Parser::CheckHeader(const char* filename, bool considerSpaceEOL,bool useCVS
//hasError = true;

// We report the wrong word and the line
int l = this->GetLineNumber(pos);
long l = this->GetLineNumber(pos);
if(l != line)
{
line = l;
Expand Down
4 changes: 2 additions & 2 deletions kwsCheckIndent.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ bool Parser::CheckIndent(IndentType itype,
isCheckingComment = false;
}

unsigned int poswithoutcomment = static_cast<long int>(this->GetPositionWithoutComments(pos));
size_t poswithoutcomment = this->GetPositionWithoutComments(pos);

if((currentIndent != wantedIndent)
&& ((inComment
Expand All @@ -435,7 +435,7 @@ bool Parser::CheckIndent(IndentType itype,
auto bracket = static_cast<long int>(m_Buffer.find_last_of('{', pos));
if(bracket != -1)
{
unsigned int l = static_cast<long int>(this->FindPreviousWord(bracket-1,true).size());
size_t l = this->FindPreviousWord(bracket-1,true).size();
if(this->FindPreviousWord(bracket-l-2,true) == "enum")
{
isInsideEnum = true;
Expand Down
2 changes: 1 addition & 1 deletion kwsCheckVariablePerLine.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ bool Parser::CheckVariablePerLine(unsigned long max)
}
// Check if we are not at the end of the line
bool endofline = true;
int eof = pos+1;
long eof = pos+1;
while(eof < (int)line.size())
{
if(line[eof] != ' ' && line[eof] != '\n'
Expand Down
8 changes: 4 additions & 4 deletions kwsGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,13 @@ bool Generator::GenerateHTML(const char* dir,bool showAllErrors)
file << R"(<table width="100%" border="0" height="1">)" << std::endl;

// To speedup the process we list the lines that have errors
using ErrorLineType = std::pair<int, std::vector<int>>;
using ErrorLineType = std::pair<long, std::vector<long>>;
std::vector<ErrorLineType> errorLines;

const Parser::ErrorVectorType errors = (*it).GetErrors();
auto itError = errors.begin();
while (itError != errors.end()) {
for (unsigned int index = (*itError).line; index <= (*itError).line2;
for (unsigned long index = (*itError).line; index <= (*itError).line2;
index++) {
ErrorLineType errLine;
errLine.first = index;
Expand Down Expand Up @@ -588,7 +588,7 @@ bool Generator::GenerateHTML(const char* dir,bool showAllErrors)
for(i=0;i<nLines;i++)
{
// Look in the errors if there is a match for this line
int error = -1;
long error = -1;
std::string errorTag = "";

std::vector<ErrorLineType>::const_iterator errorLineIt = errorLines.begin();
Expand Down Expand Up @@ -859,7 +859,7 @@ void Generator::ExportHTML(std::ostream & output)
for(unsigned int i=0;i<(*it).GetNumberOfLines();i++)
{
// Look in the errors if there is a match for this line
int error = -1;
long error = -1;
std::string errorTag = "";

const Parser::ErrorVectorType errors = (*it).GetErrors();
Expand Down
6 changes: 3 additions & 3 deletions kwsParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ bool Parser::Check(const char* name, const char* value)
}
std::string v1 = val.substr(0,pos);
std::string v2 = val.substr(pos+1,val.length()-pos-1);
this->CheckOperator(std::stoul(v1.c_str()),std::stoul(v2.c_str()));
this->CheckOperator(std::stoul(v1),std::stoul(v2));
}
else if(!strcmp(name,"Comma"))
{
Expand All @@ -467,7 +467,7 @@ bool Parser::Check(const char* name, const char* value)
}
std::string v1 = val.substr(0,pos);
std::string v2 = val.substr(pos+1,val.length()-pos-1);
this->CheckComma(std::stoul(v1.c_str()),std::stoul(v2.c_str()));
this->CheckComma(std::stoul(v1),std::stoul(v2));
}
else if(!strcmp(name,"Parenthesis"))
{
Expand Down Expand Up @@ -506,7 +506,7 @@ bool Parser::HasBeenPerformed(unsigned int test) const
}

/** Return the test description given the erro number) */
std::string Parser::GetTestDescription(unsigned int test) const
std::string Parser::GetTestDescription(size_t test) const
{
return m_TestsDescription[test];
}
Expand Down
2 changes: 1 addition & 1 deletion kwsParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class Parser
bool HasBeenPerformed(unsigned int test) const;

/** Return the test description given the error number) */
std::string GetTestDescription(unsigned int test) const;
std::string GetTestDescription(size_t test) const;

/** Given the name of the check to perform and the default value perform the check */
bool Check(const char* name, const char* value);
Expand Down
28 changes: 13 additions & 15 deletions kwsXMLReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ std::string XMLReader::GetTag()
comment_start = static_cast<long int>(m_Buffer.find("<!--",m_CurrentPos));
if(begin_tag_start == comment_start)
{
auto comment_end =
static_cast<long int>(m_Buffer.find("-->", comment_start));
if(comment_end!=-1)
auto comment_end = m_Buffer.find("-->", comment_start);
if(comment_end != std::string::npos)
{
m_CurrentPos=comment_end+3;
}
Expand All @@ -104,9 +103,8 @@ std::string XMLReader::GetTag()

std::string m_EndTag = "</";
m_EndTag += m_Tag;
auto end_tag_begin =
static_cast<long int>(m_Buffer.find(m_EndTag, begin_tag_end + 1));
if(end_tag_begin == -1)
auto end_tag_begin = m_Buffer.find(m_EndTag, begin_tag_end + 1);
if(end_tag_begin == std::string::npos)
{
std::cout << "XML parsing error, cannot find close tag for "
<< m_Tag.c_str() << std::endl;
Expand All @@ -122,26 +120,26 @@ std::string XMLReader::GetTag()
// by comas. This assume that the order of the tags is correct and present and
// that we only have 1 level in the XML tree.
unsigned int i=0;
auto pos1 = static_cast<long int>(value.find("<", 0));
while(pos1 != -1)
auto pos1 = value.find("<", 0);
while(pos1 != std::string::npos)
{
if(i>0)
{
m_Value += ",";
}
auto pos2 = static_cast<long int>(value.find(">", pos1));
auto pos3 = static_cast<long int>(value.find("<", pos2));

if (i == 0) {
m_Value = value.substr(pos2 + 1, pos3 - pos2 - 1);
auto pos2 = value.find(">", pos1);
auto pos3 = value.find("<", pos2);

if (i == 0)
{
m_Value = value.substr(pos2 + 1, pos3 - pos2 - 1);
}
else
{
m_Value += value.substr(pos2+1,pos3-pos2-1);
m_Value += value.substr(pos2 + 1, pos3 - pos2 - 1);
}

pos1 = static_cast<long int>(value.find("<",pos3+1));
pos1 = value.find("<",pos3 + 1);
i++;
}
return m_Tag;
Expand Down
2 changes: 1 addition & 1 deletion kwsXMLReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class XMLReader
std::string m_Value;
std::string m_Tag;
std::string m_Buffer;
unsigned int m_CurrentPos;
size_t m_CurrentPos;

};

Expand Down
10 changes: 5 additions & 5 deletions metaCommand.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1195,9 +1195,9 @@ bool MetaCommand::Parse(int argc, const char* argv[])
bool inArgument = false;
METAIO_STL::string tag = "";

unsigned int currentField = 0; // current field position
int currentOption = 0; // id of the option to fill
unsigned int valuesRemaining=0;
long currentField = 0; // current field position
long currentOption = 0; // id of the option to fill
size_t valuesRemaining=0;
bool isComplete = false; // check if the option should be parse until the next tag is found
METAIO_STL::string completeString = "";

Expand Down Expand Up @@ -1239,7 +1239,7 @@ bool MetaCommand::Parse(int argc, const char* argv[])
if(this->OptionExistsByMinusTag(tag))
{
inArgument = true;
valuesRemaining = static_cast<unsigned int>(this->GetOptionByMinusTag(tag)->fields.size());
valuesRemaining = this->GetOptionByMinusTag(tag)->fields.size();
currentOption = this->GetOptionId(this->GetOptionByMinusTag(tag));

if(currentOption < 0)
Expand Down Expand Up @@ -1290,7 +1290,7 @@ bool MetaCommand::Parse(int argc, const char* argv[])
{
// Look for the field to add
auto it = m_OptionVector.begin();
unsigned long pos = 0;
long pos = 0;
bool found = false;
while(it != m_OptionVector.end())
{
Expand Down

0 comments on commit eb1e46d

Please sign in to comment.