BUG: Attempt to fix sorting stability using more deterministic compare function

This commit is contained in:
Andy Cedilnik 2005-03-02 11:48:58 -05:00
parent 66a61e9c74
commit 1b68c76b19
1 changed files with 12 additions and 8 deletions

View File

@ -158,17 +158,20 @@ struct cmOrderLinkDirectoriesCompare
const cmStdString& right const cmStdString& right
) const ) const
{ {
bool ret = This->CanBeBefore(left, right); bool LBeforeR= This->CanBeBefore(left, right);
if(!ret) bool RBeforeL= This->CanBeBefore(right, left);
if ( !LBeforeR && !RBeforeL )
{ {
// check for the case when both libraries have to come // check for the case when both libraries have to come
// before each other // before each other
if(!This->CanBeBefore(right, left)) This->AddImpossible(right, left);
{
This->AddImpossible(right, left);
}
} }
return ret; if ( LBeforeR == RBeforeL )
{
return strcmp(left.c_str(), right.c_str()) < 0;
}
return LBeforeR;
} }
cmOrderLinkDirectories* This; cmOrderLinkDirectories* This;
}; };
@ -189,7 +192,8 @@ void cmOrderLinkDirectories::OrderPaths(std::vector<cmStdString>&
comp.This = this; comp.This = this;
// for some reason when cmake is run on InsightApplication // for some reason when cmake is run on InsightApplication
// if std::sort is used here cmake crashes, but stable_sort works // if std::sort is used here cmake crashes, but stable_sort works
std::stable_sort(orderedPaths.begin(), orderedPaths.end(), comp); //
std::sort(orderedPaths.begin(), orderedPaths.end(), comp);
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------