diff options
Diffstat (limited to 'include/version.cpp')
-rw-r--r-- | include/version.cpp | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/include/version.cpp b/include/version.cpp index 7b7ff321e..1c0ade7d7 100644 --- a/include/version.cpp +++ b/include/version.cpp @@ -1,12 +1,20 @@ -/* Build bumper +/* + * Anope IRC Services * - * (C) 2003-2017 Anope Team - * Contact us at team@anope.org + * Copyright (C) 2010-2017 Anope Team <team@anope.org> * - * Please read COPYING and README for further details. + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ #include <cstdlib> @@ -28,7 +36,7 @@ static std::string get_git_hash(const std::string &git_dir) fd.close(); return ""; } - + fd.close(); filebuf = filebuf.substr(5); @@ -77,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()) @@ -106,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(); |