diff options
author | Adam <Adam@anope.org> | 2016-12-06 21:02:48 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2016-12-06 21:02:48 -0500 |
commit | 87ec095a89bbc73a4dd16858bea499f466066212 (patch) | |
tree | 776129c883242ae6b6c27884b128a336b801999b /include/version.cpp | |
parent | 1ff4719ea70cfead41bd91d7b78cfdcb5b84b8cc (diff) |
Remove many more old C style format strings in the protocol functions
Diffstat (limited to 'include/version.cpp')
-rw-r--r-- | include/version.cpp | 20 |
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(); |