summaryrefslogtreecommitdiff
path: root/include/version.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/version.cpp')
-rw-r--r--include/version.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/include/version.cpp b/include/version.cpp
index 7dc0b3402..b2340153b 100644
--- a/include/version.cpp
+++ b/include/version.cpp
@@ -85,26 +85,31 @@ static bool write_build_h(const std::string &buildh, const std::string &git_vers
{
std::fstream fd(buildh.c_str(), std::ios::in);
- std::string build = "#define BUILD 1";
+ std::string existing_version;
if (fd.is_open())
{
for (std::string filebuf; getline(fd, filebuf);)
{
- if (!filebuf.find("#define BUILD"))
+ if (!filebuf.find("#define VERSION_GIT"))
{
- size_t tab = filebuf.find(' ');
+ std::size_t q = filebuf.find('"');
+ if (q == std::string::npos)
+ break;
- int ibuild = atoi(filebuf.substr(tab + 1).c_str()) + 1;
+ std::size_t q2 = filebuf.find('"', q + 1);
+ if (q2 == std::string::npos)
+ break;
- std::stringstream ss;
- ss << "#define BUILD " << ibuild;
- build = ss.str();
+ existing_version = filebuf.substr(q + 1, q2 - q - 1);
}
}
fd.close();
}
+ if (existing_version == git_version)
+ return true;
+
fd.clear();
fd.open(buildh.c_str(), std::ios::out);
if (!fd.is_open())
@@ -114,7 +119,6 @@ static bool write_build_h(const std::string &buildh, const std::string &git_vers
}
fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << std::endl;
- fd << build << std::endl;
if (!git_version.empty())
fd << "#define VERSION_GIT \"" << git_version << "\"" << std::endl;
fd.close();