1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 22:46:39 +02:00

Fixed version.cpp to work ok if we are on a tag, and

prevent version.cpp from prepending version.sh's VERSION_EXTRA on every build
This commit is contained in:
Adam
2010-12-24 20:05:52 -05:00
parent e54cffd9b7
commit faf1e3710e
2 changed files with 12 additions and 5 deletions
+8 -1
View File
@@ -54,12 +54,19 @@ int main(int argc, char *argv[])
std::string version_build = "#define VERSION_BUILD 1";
std::string build = "#define BUILD 1";
std::string version_extra;
if (fd.is_open())
{
while (getline(fd, filebuf))
{
if (!filebuf.find("#define VERSION_BUILD"))
version_build = filebuf;
else if (!filebuf.find("#define VERSION_EXTRA"))
{
size_t q = filebuf.find('"');
version_extra = filebuf.substr(q + 1, filebuf.length() - q - 2);
}
else if (!filebuf.find("#define BUILD"))
{
size_t tab = filebuf.find(' ');
@@ -89,7 +96,7 @@ int main(int argc, char *argv[])
for (std::list<std::pair<std::string, std::string> >::iterator it = versions.begin(), it_end = versions.end(); it != it_end; ++it)
{
if (it->first == "EXTRA")
fd << "#define VERSION_EXTRA \"" << it->second << "\"" << std::endl;
fd << "#define VERSION_EXTRA \"" << (!version_extra.empty() ? version_extra : "") << (version_extra.find(it->second) == std::string::npos ? it->second : "") << "\"" << std::endl;
else
fd << "#define VERSION_" << it->first << " " << it->second << std::endl;
}