Merge pull request #1089 from SpecLad:contract-violations

This commit is contained in:
Roman Donchenko 2013-07-04 18:25:39 +04:00 committed by OpenCV Buildbot
commit 4d45b3e7f9
2 changed files with 6 additions and 9 deletions

View File

@ -580,6 +580,8 @@ String::~String()
inline inline
String& String::operator=(const String& str) String& String::operator=(const String& str)
{ {
if (&str == this) return *this;
deallocate(); deallocate();
if (str.cstr_) CV_XADD(((int*)str.cstr_)-1, 1); if (str.cstr_) CV_XADD(((int*)str.cstr_)-1, 1);
cstr_ = str.cstr_; cstr_ = str.cstr_;

View File

@ -136,18 +136,13 @@ void CommandLineParser::getByIndex(int index, bool space_delete, int type, void*
static bool cmp_params(const CommandLineParserParams & p1, const CommandLineParserParams & p2) static bool cmp_params(const CommandLineParserParams & p1, const CommandLineParserParams & p2)
{ {
if (p1.number < p2.number)
return true;
if (p1.number > p2.number) if (p1.number > p2.number)
return false; return false;
if (p1.number == -1 && p2.number == -1) return p1.keys[0].compare(p2.keys[0]) < 0;
{
if (p1.keys[0].compare(p2.keys[0]) > 0)
{
return false;
}
}
return true;
} }
CommandLineParser::CommandLineParser(int argc, const char* const argv[], const String& keys) CommandLineParser::CommandLineParser(int argc, const char* const argv[], const String& keys)