inst_util.cc
// If less is a lower version number than right
If less is a lower version number than right
If less is a lower version number than right
bool VersionLess(const string& left,
                 const string& right) {
  std::vector<string> left_parts;
  std::vector<string> right_parts;
  SplitString(left, '.', &left_parts);
  SplitString(right, '.', &right_parts);
  if (left_parts.size() == 3 && right_parts.size() == 4)
    return false;
  if (left_parts.size() == 4 && right_parts.size() == 3)
    return true;
  for (unsigned int i = 0; i < left_parts.size(); i++) {
    int left_value = atoi(left_parts[i].c_str());
    int right_value = atoi(right_parts[i].c_str());
    if (left_value < right_value)
      return true;
    if (left_value > right_value)
      return false;
  }
  return false;
}
bool VersionLess ( const string & left , const string & right ) { std :: vector < string > left_parts ; std :: vector < string > right_parts ; SplitString ( left , ' ' , & left_parts ) ; SplitString ( right , ' ' , & right_parts ) ; if ( left_parts . size ( ) == 3 && right_parts . size ( ) == 4 ) return false ; if ( left_parts . size ( ) == 4 && right_parts . size ( ) == 3 ) return true ; for ( unsigned int i = 0 ; i < left_parts . size ( ) ; i ++ ) { int left_value = atoi ( left_parts [ i ] . c_str ( ) ) ; int right_value = atoi ( right_parts [ i ] . c_str ( ) ) ; if ( left_value < right_value ) return true ; if ( left_value > right_value ) return false ; } return false ; }
If less is a lower version number than right
If less is a lower version number than right
// We changed from 3 part versions to 4 part versions. // 3 part versions are always newer than 4 part versions // There should be no other way for the lengths to be different //assert(left_parts.length() == right_parts.length()); // They are equal, and thus not less than.