Remove trailing space, git doesn't like it
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12797 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
+75
-75
@@ -38,10 +38,10 @@ namespace StringUtils
|
||||
// While this is basically correct, it fails with older
|
||||
// g++ versions (at least 2.95.3), which have a wrong template. To
|
||||
// avoid this issue, a more C-traditional way is used.
|
||||
return strcmp(lhs.c_str()+(lhs.length()-rhs.length()),
|
||||
return strcmp(lhs.c_str()+(lhs.length()-rhs.length()),
|
||||
rhs.c_str() )==0;
|
||||
} // hasSuffix
|
||||
|
||||
|
||||
bool startsWith(const std::string& str, const std::string& prefix)
|
||||
{
|
||||
if (str.length() < prefix.length())
|
||||
@@ -49,7 +49,7 @@ namespace StringUtils
|
||||
else
|
||||
return strncmp(str.c_str(), prefix.c_str(), prefix.size())==0;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/** Returns the path of a filename, i.e. everything till the last '/'.
|
||||
*/
|
||||
@@ -64,7 +64,7 @@ namespace StringUtils
|
||||
}
|
||||
return "";
|
||||
} // getPath
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/** Returns the basename of a filename, i.e. everything after the last "/".
|
||||
*/
|
||||
@@ -79,7 +79,7 @@ namespace StringUtils
|
||||
}
|
||||
return filename;
|
||||
} // getBasename
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/** Removes the extension, i.e. everything after the last ".".
|
||||
*/
|
||||
@@ -94,7 +94,7 @@ namespace StringUtils
|
||||
}
|
||||
return filename;
|
||||
} // removeExtension
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/** Returns the extension, i.e. everything after the last "."
|
||||
*/
|
||||
@@ -109,7 +109,7 @@ namespace StringUtils
|
||||
}
|
||||
return filename;
|
||||
} // getExtension
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/** Returns a string converted to upper case.
|
||||
*/
|
||||
@@ -119,7 +119,7 @@ namespace StringUtils
|
||||
std::transform(name.begin(), name.end(), name.begin(), ::toupper);
|
||||
return name;
|
||||
} // toUpperCase
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/** Returns a string converted to lower case.
|
||||
*/
|
||||
@@ -131,17 +131,17 @@ namespace StringUtils
|
||||
} // toLowerCase
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/** Splits a string into substrings separated by a certain character, and
|
||||
/** Splits a string into substrings separated by a certain character, and
|
||||
* returns a std::vector of all those substring. E.g.:
|
||||
* split("a b=c d=e",' ') --> ["a", "b=c", "d=e"]
|
||||
* \param s The string to split.
|
||||
* \param c The character by which the string is split.
|
||||
*/
|
||||
std::vector<std::string> split(const std::string& s, char c,
|
||||
std::vector<std::string> split(const std::string& s, char c,
|
||||
bool keepSplitChar)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
std::string::size_type start=0;
|
||||
@@ -158,14 +158,14 @@ namespace StringUtils
|
||||
result.push_back(std::string(s, from, i-from));
|
||||
}
|
||||
else result.push_back(std::string(s,start, i-start));
|
||||
|
||||
|
||||
start=i+1;
|
||||
}
|
||||
}
|
||||
else // end of string reached
|
||||
{
|
||||
if (keepSplitChar)
|
||||
if (keepSplitChar)
|
||||
result.push_back(std::string(s,start-1));
|
||||
else
|
||||
else
|
||||
result.push_back(std::string(s,start));
|
||||
start = i;
|
||||
}
|
||||
@@ -174,36 +174,36 @@ namespace StringUtils
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
fprintf(stderr,
|
||||
fprintf(stderr,
|
||||
"Fatal error in split(std::string) : %s @ line %i : %s\n",
|
||||
__FILE__, __LINE__, e.what());
|
||||
printf("Splitting %s\n", s.c_str());
|
||||
|
||||
|
||||
for (int n=0; n<(int)result.size(); n++)
|
||||
{
|
||||
printf("Split : %s\n", result[n].c_str());
|
||||
}
|
||||
|
||||
|
||||
assert(false); // in debug mode, trigger debugger
|
||||
exit(1);
|
||||
}
|
||||
} // split
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/** Splits a string into substrings separated by a certain character, and
|
||||
/** Splits a string into substrings separated by a certain character, and
|
||||
* returns a std::vector of all those substring. E.g.:
|
||||
* split("a b=c d=e",' ') --> ["a", "b=c", "d=e"]
|
||||
* This is the version for wide strings.
|
||||
* \param s The string to split.
|
||||
* \param c The character by which the string is split.
|
||||
*/
|
||||
std::vector<irr::core::stringw> split(const irr::core::stringw& s, char c,
|
||||
std::vector<irr::core::stringw> split(const irr::core::stringw& s, char c,
|
||||
bool keepSplitChar)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::vector<irr::core::stringw> result;
|
||||
|
||||
|
||||
irr::s32 start = 0;
|
||||
while (start < (irr::s32)s.size())
|
||||
{
|
||||
@@ -218,15 +218,15 @@ namespace StringUtils
|
||||
}
|
||||
else result.push_back( s.subString(start, i-start) );
|
||||
start = i+1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keepSplitChar)
|
||||
result.push_back( s.subString(start - 1,
|
||||
if (keepSplitChar)
|
||||
result.push_back( s.subString(start - 1,
|
||||
s.size()-start + 1) );
|
||||
else
|
||||
else
|
||||
result.push_back( s.subString(start, s.size()-start) );
|
||||
|
||||
|
||||
return result;
|
||||
//start = i+1;
|
||||
}
|
||||
@@ -236,15 +236,15 @@ namespace StringUtils
|
||||
catch (std::exception& e)
|
||||
{
|
||||
(void)e; // avoid warning about unused variable
|
||||
fprintf(stderr,
|
||||
"Fatal error in split(stringw) : %s @ line %i : %s\n",
|
||||
fprintf(stderr,
|
||||
"Fatal error in split(stringw) : %s @ line %i : %s\n",
|
||||
__FILE__, __LINE__, e.what());
|
||||
assert(false); // in dbug mode, trigger debugger
|
||||
exit(1);
|
||||
}
|
||||
} // split
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Splits a : separated string (like PATH) into its individual components.
|
||||
* It especially handles Windows-style paths (c:/mydir1:d:/mydir2)
|
||||
@@ -293,23 +293,23 @@ namespace StringUtils
|
||||
catch (std::exception& e)
|
||||
{
|
||||
(void)e; // avoid warning about unused variable
|
||||
fprintf(stderr, "Fatal error in splitPath : %s @ line %i\n",
|
||||
fprintf(stderr, "Fatal error in splitPath : %s @ line %i\n",
|
||||
__FILE__, __LINE__);
|
||||
exit(1);
|
||||
}
|
||||
} // splitPath
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
std::string insertValues(const std::string &s,
|
||||
std::string insertValues(const std::string &s,
|
||||
std::vector<std::string>& all_vals)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::vector<std::string> sv = StringUtils::split(s, '%', true);
|
||||
std::string new_string="";
|
||||
|
||||
|
||||
unsigned int insertValID = 0;
|
||||
|
||||
|
||||
const unsigned int item_count = sv.size();
|
||||
for (unsigned int i=0; i<item_count; i++)
|
||||
{
|
||||
@@ -323,15 +323,15 @@ namespace StringUtils
|
||||
{
|
||||
if (insertValID >= all_vals.size())
|
||||
{
|
||||
fprintf(stderr,
|
||||
fprintf(stderr,
|
||||
"[StringUtils::insertValues] ERROR: "
|
||||
"Invalid number of arguments in '%s'\n",
|
||||
"Invalid number of arguments in '%s'\n",
|
||||
s.c_str());
|
||||
new_string += "??" + sv[i].substr(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_string += all_vals[insertValID]
|
||||
new_string += all_vals[insertValID]
|
||||
+ sv[i].substr(2);
|
||||
}
|
||||
insertValID++;
|
||||
@@ -367,20 +367,20 @@ namespace StringUtils
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
irr::core::stringw insertValues(const irr::core::stringw &s,
|
||||
irr::core::stringw insertValues(const irr::core::stringw &s,
|
||||
std::vector<irr::core::stringw>& all_vals)
|
||||
{
|
||||
try
|
||||
{
|
||||
unsigned int insertValID = 0;
|
||||
|
||||
const std::vector<irr::core::stringw> sv =
|
||||
const std::vector<irr::core::stringw> sv =
|
||||
StringUtils::split(s, '%', true);
|
||||
|
||||
|
||||
irr::core::stringw new_string="";
|
||||
|
||||
|
||||
const unsigned int size = sv.size();
|
||||
for (unsigned int i=0; i<size; i++)
|
||||
{
|
||||
@@ -410,25 +410,25 @@ namespace StringUtils
|
||||
}
|
||||
else if(irr::core::isdigit(sv[i][1]))
|
||||
{
|
||||
irr::core::stringw rest =
|
||||
irr::core::stringw rest =
|
||||
sv[i].subString(2, sv[i].size()-2);
|
||||
int delta = 0;
|
||||
|
||||
|
||||
if (sv[i].size() >= 4 && sv[i][2]=='$')
|
||||
{
|
||||
rest = sv[i].subString(4, sv[i].size()-4);
|
||||
delta = -1;
|
||||
}
|
||||
|
||||
const unsigned int index =
|
||||
irr::core::stringc(sv[i].c_str()).c_str()[1]
|
||||
|
||||
const unsigned int index =
|
||||
irr::core::stringc(sv[i].c_str()).c_str()[1]
|
||||
- '0' + delta;
|
||||
if (index >= all_vals.size())
|
||||
{
|
||||
fprintf(stderr,
|
||||
fprintf(stderr,
|
||||
"[StringUtils::insertValues] ERROR: "
|
||||
"Invalid argument ID in '%s' : %i\n",
|
||||
irr::core::stringc(s.c_str()).c_str(),
|
||||
irr::core::stringc(s.c_str()).c_str(),
|
||||
index);
|
||||
new_string += "??";
|
||||
new_string += rest;
|
||||
@@ -455,8 +455,8 @@ namespace StringUtils
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Converts a time in seconds into a string of the form mm:ss:hh (minutes,
|
||||
* seconds, 1/100 seconds.
|
||||
@@ -466,8 +466,8 @@ namespace StringUtils
|
||||
{
|
||||
int int_time = (int)(time*100.0f+0.5f);
|
||||
|
||||
// Avoid problems if time is negative or way too large (which
|
||||
// should only happen if something is broken in a track elsewhere,
|
||||
// Avoid problems if time is negative or way too large (which
|
||||
// should only happen if something is broken in a track elsewhere,
|
||||
// and an incorrect finishing time is estimated.
|
||||
if(int_time<0)
|
||||
return std::string("00:00:00");
|
||||
@@ -484,21 +484,21 @@ namespace StringUtils
|
||||
// <<std::setw(2)<<std::setfill(' ')<<hundredths;
|
||||
// return s.str();
|
||||
// but that appears to be awfully complicated and slow, compared to
|
||||
// which admittedly only works for min < 100000 - which is about 68
|
||||
// which admittedly only works for min < 100000 - which is about 68
|
||||
// days - good enough.
|
||||
char s[12];
|
||||
sprintf ( s, "%02d:%02d:%02d", min, sec, hundredths) ;
|
||||
return std::string(s);
|
||||
} // timeToString
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
std::string replace(const std::string& other, const std::string& from,
|
||||
std::string replace(const std::string& other, const std::string& from,
|
||||
const std::string& to)
|
||||
{
|
||||
std::string wip = other;
|
||||
|
||||
|
||||
|
||||
|
||||
while (true)
|
||||
{
|
||||
const int pos = wip.find(from);
|
||||
@@ -508,9 +508,9 @@ namespace StringUtils
|
||||
}
|
||||
wip.replace(pos, from.size(), to.c_str(), to.size());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Converts ASCII text with HTML entities (e.g. &xE9;) to unicode strings
|
||||
* \param input The input string which should be decoded.
|
||||
@@ -521,14 +521,14 @@ namespace StringUtils
|
||||
irr::core::stringw output;
|
||||
std::string entity;
|
||||
bool isHex = false;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
NORMAL,
|
||||
ENTITY_PREAMBLE,
|
||||
ENTITY_BODY
|
||||
} state = NORMAL;
|
||||
|
||||
|
||||
for (unsigned int n=0; n<input.size(); n++)
|
||||
{
|
||||
switch (state)
|
||||
@@ -545,7 +545,7 @@ namespace StringUtils
|
||||
output += wchar_t(input[n]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case ENTITY_PREAMBLE:
|
||||
if (input[n] != '#')
|
||||
{
|
||||
@@ -565,7 +565,7 @@ namespace StringUtils
|
||||
state = ENTITY_BODY;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case ENTITY_BODY:
|
||||
if (input[n] == 'x' && entity.size() == 0)
|
||||
{
|
||||
@@ -574,7 +574,7 @@ namespace StringUtils
|
||||
else if (input[n] == ';')
|
||||
{
|
||||
int c;
|
||||
|
||||
|
||||
const char* format = (isHex ? "%x" : "%i");
|
||||
if (sscanf(entity.c_str(), format, &c) == 1)
|
||||
{
|
||||
@@ -582,9 +582,9 @@ namespace StringUtils
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,
|
||||
fprintf(stderr,
|
||||
"[StringUtils] WARNING: non-numeric HTML "
|
||||
"entity not supported in '%s'\n",
|
||||
"entity not supported in '%s'\n",
|
||||
input.c_str());
|
||||
}
|
||||
state = NORMAL;
|
||||
@@ -596,7 +596,7 @@ namespace StringUtils
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
} // decodeFromHtmlEntities
|
||||
|
||||
@@ -629,7 +629,7 @@ namespace StringUtils
|
||||
} // encodeToHtmlEntities
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
unsigned int simpleHash(const char* input)
|
||||
{
|
||||
int hash = 0;
|
||||
@@ -637,7 +637,7 @@ namespace StringUtils
|
||||
{
|
||||
hash += (hash << (hash & 0xF)) ^ input[n];
|
||||
}
|
||||
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -651,19 +651,19 @@ namespace StringUtils
|
||||
// Special case: SVN
|
||||
if(version_string=="SVN" || version_string=="svn")
|
||||
// SVN version will be version 99.99.99i-rcJ
|
||||
return 1000000*99
|
||||
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
|
||||
// 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",
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user