int compare_no_case(string const & s, string const & s2)
{
- // ANSI C
string::const_iterator p = s.begin();
string::const_iterator p2 = s2.begin();
++p;
++p2;
}
-
+
if (s.size() == s2.size())
return 0;
if (s.size() < s2.size())
++p;
++p2;
}
- if (s.size() == s2.size())
+
+ if (s.size() >= len && s2.size() >= len)
return 0;
if (s.size() < s2.size())
return -1;
string::size_type const prelen = pre.length();
string::size_type const alen = a.length();
- if (prelen < alen || a.empty())
+ if (prelen > alen || a.empty())
return false;
else {
#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
Assert(suf);
size_t const suflen = strlen(suf);
- if (suflen > a.length())
+ string::size_type const alen = a.length();
+
+ if (suflen > alen)
return false;
else {
#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
// Delete this code when the compilers get a bit better.
- string tmp(a, a.length() - suflen);
+ string tmp(a, alen - suflen);
return ::strncmp(tmp.c_str(), suf, suflen) == 0;
#else
// This is the code that we really want to use
// but until gcc ships with a basic_string that
// implements std::string correctly we have to
// use the code above.
- return a.compare(a.length() - suflen, suflen, suf) == 0;
+ return a.compare(alen - suflen, suflen, suf) == 0;
#endif
}
}