Fixed: #888 CSString::find and CSString::findNS broken

This commit is contained in:
kervala 2010-05-12 11:10:28 +02:00
parent a4671b1f88
commit 6bfba3d85b
2 changed files with 16 additions and 16 deletions

View file

@ -333,10 +333,10 @@ public:
CSString replace(const char *toFind,const char *replacement) const;
/// Find index at which a sub-string starts (case not sensitive) - if sub-string not found then returns string::npos
unsigned find(const char *toFind,unsigned startLocation=0) const;
std::string::size_type find(const char *toFind, std::string::size_type startLocation=0) const;
/// Find index at which a sub-string starts (case NOT sensitive) - if sub-string not found then returns string::npos
unsigned findNS(const char *toFind,unsigned startLocation=0) const;
std::string::size_type findNS(const char *toFind, std::string::size_type startLocation=0) const;
/// Return true if this contains given sub string
bool contains(const char *toFind) const;
@ -346,8 +346,8 @@ public:
/// Handy atoi routines...
int atoi() const;
signed atosi() const;
unsigned atoui() const;
sint32 atosi() const;
uint32 atoui() const;
sint64 atoi64() const;
sint64 atosi64() const;
uint64 atoui64() const;

View file

@ -1325,7 +1325,7 @@ namespace NLMISC
if (toFind==NULL || *toFind==0)
return *this;
unsigned i,j;
std::string::size_type i,j;
CSString result;
for (i=0;i<size();)
{
@ -1349,15 +1349,15 @@ namespace NLMISC
return result;
}
unsigned CSString::find(const char *toFind,unsigned startLocation) const
std::string::size_type CSString::find(const char *toFind, std::string::size_type startLocation) const
{
// const char *constStr = c_str();
// just bypass the problems that can cause a crash...
if (toFind==NULL || *toFind==0 || startLocation>=size())
return (unsigned)std::string::npos;
return std::string::npos;
unsigned i,j;
std::string::size_type i,j;
for (i=startLocation;i<size();++i)
{
// string compare toFind against (*this)+i ...
@ -1368,19 +1368,19 @@ namespace NLMISC
if (toFind[j]==0)
return i;
}
return (unsigned)std::string::npos;
return std::string::npos;
}
/// Find index at which a sub-string starts (case NOT sensitive) - if sub-string not found then returns string::npos
unsigned CSString::findNS(const char *toFind,unsigned startLocation) const
std::string::size_type CSString::findNS(const char *toFind, std::string::size_type startLocation) const
{
const char *constStr = c_str();
// just bypass the problems that can cause a crash...
if (toFind==NULL || *toFind==0 || startLocation>=size())
return (unsigned)std::string::npos;
return std::string::npos;
unsigned i,j;
std::string::size_type i,j;
for (i=startLocation;i<size();++i)
{
// string compare toFind against (*this)+i ...
@ -1391,12 +1391,12 @@ namespace NLMISC
if (toFind[j]==0)
return i;
}
return (unsigned)std::string::npos;
return std::string::npos;
}
bool CSString::contains(const char *toFind) const
{
return find(toFind)!=(unsigned)std::string::npos;
return find(toFind)!=std::string::npos;
}
bool CSString::contains(int character) const
@ -1482,7 +1482,7 @@ namespace NLMISC
return neg? -(sint32)result: (sint32)result;
}
int CSString::atosi() const
sint32 CSString::atosi() const
{
if (empty())
return 0;
@ -1533,7 +1533,7 @@ namespace NLMISC
return neg? -(sint32)result: (sint32)result;
}
unsigned CSString::atoui() const
uint32 CSString::atoui() const
{
uint32 result=0;
for (const_iterator it=begin();it!=end();++it)