Skip to content
Snippets Groups Projects
Commit 5885d648 authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Fixed cppcheck issue

I fixed a complain of cppcheck which discourage using
find()==0

This will allow upgrading to latest cppcheck.
parent 4bcc5a1e
No related branches found
No related tags found
No related merge requests found
...@@ -94,7 +94,7 @@ bool CLTool::readCommandLineArgs( int argc, char**argv, FILE*out ){ ...@@ -94,7 +94,7 @@ bool CLTool::readCommandLineArgs( int argc, char**argv, FILE*out ){
if( a==thiskey ){ if( a==thiskey ){
prefix=thiskey+"="; found=true; prefix=thiskey+"="; found=true;
inputData.insert(std::pair<std::string,std::string>(thiskey,"")); inputData.insert(std::pair<std::string,std::string>(thiskey,""));
} else if( a.find(thiskey+"=")==0){ } else if(Tools::startWith(a,thiskey+"=")){
a.erase(0,a.find("=")+1); prefix=""; found=true; a.erase(0,a.find("=")+1); prefix=""; found=true;
if(inputData.count(thiskey)==0){ if(inputData.count(thiskey)==0){
inputData.insert(std::pair<std::string,std::string>(thiskey,a)); inputData.insert(std::pair<std::string,std::string>(thiskey,a));
......
...@@ -144,7 +144,7 @@ int CLToolMain::run(int argc, char **argv,FILE*in,FILE*out,Communicator& pc){ ...@@ -144,7 +144,7 @@ int CLToolMain::run(int argc, char **argv,FILE*in,FILE*out,Communicator& pc){
} }
} else if(a=="--standalone-executable"){ } else if(a=="--standalone-executable"){
standalone_executable=true; standalone_executable=true;
} else if(a.find("--load=")==0){ } else if(Tools::startWith(a,"--load=")){
a.erase(0,a.find("=")+1); a.erase(0,a.find("=")+1);
prefix=""; prefix="";
void *p=dlloader.load(a); void *p=dlloader.load(a);
......
...@@ -322,4 +322,9 @@ std::string Tools::extension(const std::string&s){ ...@@ -322,4 +322,9 @@ std::string Tools::extension(const std::string&s){
return ext; return ext;
} }
bool Tools::startWith(const std::string & full,const std::string &start){
return (full.substr(0,start.length())==start);
}
} }
...@@ -121,6 +121,9 @@ public: ...@@ -121,6 +121,9 @@ public:
static std::string extension(const std::string&); static std::string extension(const std::string&);
/// Fast int power /// Fast int power
static double fastpow(double base,int exp); static double fastpow(double base,int exp);
/// Check if a string full starts with string start.
/// Same as full.find(start)==0
static bool startWith(const std::string & full,const std::string &start);
}; };
template <class T> template <class T>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment