Merged with trunk, part 1 (due to previous failures I am splitting this

patch).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@14605 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2013-12-02 04:27:55 +00:00
parent c0783283e0
commit bced8cdb9f
559 changed files with 12644 additions and 27623 deletions
+50 -47
View File
@@ -1,7 +1,8 @@
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004 Steve Baker <sjbaker1@airmail.net>,
// Ingo Ruhnke <grumbel@gmx.de>
//
// Copyright (C) 2004-2013 Steve Baker <sjbaker1@airmail.net>,
// Copyright (C) 2004-2013 Ingo Ruhnke <grumbel@gmx.de>
// Copyright (C) 2006-2013 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -672,54 +673,56 @@ namespace StringUtils
// ------------------------------------------------------------------------
/** Converts a version string (in the form of 'X.Y.Za-rcU' into an
* integer number.
* \param s The version string to convert.
*/
* integer number.
* \param s The version string to convert.
*/
int versionToInt(const std::string &version_string)
{
// Special case: SVN
if(version_string=="SVN" || version_string=="svn")
// SVN version will be version 99.99.99i-rcJ
return 1000000*99
+ 10000*99
+ 100*99
+ 10* 9
+ 9;
// Special case: SVN
if(version_string=="SVN" || version_string=="svn")
{
// SVN version will be version 99.99.99i-rcJ
return 1000000*99
+ 10000*99
+ 100*99
+ 10* 9
+ 9;
}
std::string s=version_string;
// To guarantee that a release gets a higher version number than
// a release candidate, we assign a 'release_candidate' number
// of 9 to versions which are not a RC. We assert that any RC
// is less than 9 to guarantee the ordering.
int release_candidate=9;
if(s.length()>4 && sscanf(s.substr(s.length()-4, 4).c_str(), "-rc%d",
&release_candidate)==1)
{
s = s.substr(0, s.length()-4);
// Otherwise a RC can get a higher version number than
// the corresponding release! If this should ever get
// triggered, multiply all scaling factors above and
// below by 10, to get two digits for RC numbers.
assert(release_candidate<9);
}
int very_minor=0;
if(s.length()>0 && s[s.size()-1]>='a' && s[s.size()-1]<='z')
{
very_minor = s[s.size()-1]-'a'+1;
s = s.substr(0, s.size()-1);
}
std::vector<std::string> l = StringUtils::split(s, '.');
while(l.size()<3)
l.push_back("0");
int version = 1000000*atoi(l[0].c_str())
+ 10000*atoi(l[1].c_str())
+ 100*atoi(l[2].c_str())
+ 10*very_minor
+ release_candidate;
std::string s=version_string;
// To guarantee that a release gets a higher version number than
// a release candidate, we assign a 'release_candidate' number
// of 9 to versions which are not a RC. We assert that any RC
// is less than 9 to guarantee the ordering.
int release_candidate=9;
if(s.length()>4 && sscanf(s.substr(s.length()-4, 4).c_str(), "-rc%d",
&release_candidate)==1)
{
s = s.substr(0, s.length()-4);
// Otherwise a RC can get a higher version number than
// the corresponding release! If this should ever get
// triggered, multiply all scaling factors above and
// below by 10, to get two digits for RC numbers.
assert(release_candidate<9);
}
int very_minor=0;
if(s.length()>0 && s[s.size()-1]>='a' && s[s.size()-1]<='z')
{
very_minor = s[s.size()-1]-'a'+1;
s = s.substr(0, s.size()-1);
}
std::vector<std::string> l = StringUtils::split(s, '.');
while(l.size()<3)
l.push_back("0");
int version = 1000000*atoi(l[0].c_str())
+ 10000*atoi(l[1].c_str())
+ 100*atoi(l[2].c_str())
+ 10*very_minor
+ release_candidate;
if(version<=0)
printf("Invalid version string '%s'.\n", s.c_str());
return version;
if(version<=0)
printf("Invalid version string '%s'.\n", s.c_str());
return version;
} // versionToInt
const char* boolstr(bool b)