mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-25 14:22:54 -06:00
Added minimal support for new cpp parser when AndroidBuilder is active
git-svn-id: svn://ultimatepp.org/upp/trunk@8759 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1421c87e8c
commit
d112aac4bc
6 changed files with 131 additions and 3 deletions
|
|
@ -20,4 +20,75 @@ String Android::GetCmdExt()
|
|||
#endif
|
||||
}
|
||||
|
||||
void Android::NormalizeVersions(Vector<String>& versions)
|
||||
{
|
||||
String prefix = FindVersionsPrefix(versions);
|
||||
String longestVersion = FindLongestVersion(versions);
|
||||
|
||||
int longestVersionCount = longestVersion.GetCount();
|
||||
for(int i = 0; i < versions.GetCount(); i++) {
|
||||
int diff = longestVersionCount - versions[i].GetCount();
|
||||
if(diff <= 0)
|
||||
continue;
|
||||
|
||||
String version = versions[i];
|
||||
if(!prefix.IsEmpty())
|
||||
version.Replace(prefix, "");
|
||||
for(int j = 0; j < diff; j++)
|
||||
version = "0" + version;
|
||||
versions[i] = prefix + version;
|
||||
}
|
||||
}
|
||||
|
||||
void Android::RemoveVersionsNormalization(Vector<String>& versions)
|
||||
{
|
||||
String prefix = FindVersionsPrefix(versions);
|
||||
for(int i = 0; i < versions.GetCount(); i++) {
|
||||
String version = versions[i];
|
||||
if(!prefix.IsEmpty())
|
||||
version.Replace(prefix, "");
|
||||
for(;;) {
|
||||
if(!version.StartsWith("0"))
|
||||
break;
|
||||
version.Remove(0);
|
||||
}
|
||||
versions[i] = prefix + version;
|
||||
}
|
||||
}
|
||||
|
||||
String Android::FindVersionsPrefix(const Vector<String>& versions)
|
||||
{
|
||||
String prefix;
|
||||
for(int i = 0; i < versions.GetCount(); i++) {
|
||||
String currentPrefix;
|
||||
String version = versions[i];
|
||||
for(int j = 0; j < 10; j++) {
|
||||
int idx = version.Find(IntStr(j));
|
||||
if(idx < 0)
|
||||
continue;
|
||||
String left = version.Left(idx);
|
||||
if(currentPrefix.IsEmpty() || left.GetCount() < currentPrefix.GetCount())
|
||||
currentPrefix = left;
|
||||
}
|
||||
if(i == 0)
|
||||
prefix = currentPrefix;
|
||||
else
|
||||
if(i > 0 && currentPrefix != prefix)
|
||||
return "";
|
||||
}
|
||||
|
||||
return prefix;
|
||||
}
|
||||
|
||||
String Android::FindLongestVersion(const Vector<String>& versions)
|
||||
{
|
||||
String longest;
|
||||
for(int i = 0; i < versions.GetCount(); i++) {
|
||||
String current = versions[i];
|
||||
if(current.GetCount() > longest.GetCount())
|
||||
longest = current;
|
||||
}
|
||||
return longest;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue