diff options
author | Robin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-10-07 23:38:25 +0000 |
---|---|---|
committer | Robin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-10-07 23:38:25 +0000 |
commit | 3324e62bae6f04e4f16f113b2e3352fae242f405 (patch) | |
tree | cfdd8d39e374619cad772aff317e2998fa078548 /include/version.sh.c | |
parent | 728fe3e1d42bf8cac353787480701b0a62559272 (diff) |
Merge branch 'anopeng' into anopeng-config
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1428 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'include/version.sh.c')
-rw-r--r-- | include/version.sh.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/include/version.sh.c b/include/version.sh.c index f69fe8992..a3d0ba7e4 100644 --- a/include/version.sh.c +++ b/include/version.sh.c @@ -16,6 +16,8 @@ #include <stdio.h> #include <string.h> +#include <cstdlib> +#include <cctype> #define CTRL "version.log" @@ -46,10 +48,10 @@ int main() load_ctrl(fd); fclose(fd); - _snprintf(version, 1024, "%d.%d.%d%s (%d)", version_major, version_minor, + _snprintf(version, 1024, "%ld.%ld.%ld%s (%ld)", version_major, version_minor, version_patch, (version_extra ? version_extra : ""), version_build); - _snprintf(version_dotted, 1024, "%d.%d.%d%s.%d", version_major, version_minor, + _snprintf(version_dotted, 1024, "%ld.%ld.%ld%s.%ld", version_major, version_minor, version_patch, (version_extra ? version_extra : ""), version_build); fd = fopen("version.h", "r"); @@ -106,7 +108,11 @@ char *strip(char *str) long get_value(char *string) { - return atol(get_value_str(string)); + // XXX : if the fields in version.log are empty strtok returns a double quote, dont try to atol it then + if (*string != '"') + return atol(get_value_str(string)); + else + return 0; } char *get_value_str(char *string) @@ -165,10 +171,12 @@ void write_version(FILE * fd) strip(buf); if (until_eof) + { if (!strcmp(buf, "EOF")) break; else parse_line(fd, buf); + } if (!strcmp(buf, "cat >version.h <<EOF")) until_eof = 1; @@ -197,18 +205,18 @@ void parse_line(FILE * fd, char *line) *var = 0; if (!strcmp(varbegin, "VERSION_MAJOR")) - fprintf(fd, "%d", version_major); + fprintf(fd, "%ld", version_major); else if (!strcmp(varbegin, "VERSION_MINOR")) - fprintf(fd, "%d", version_minor); + fprintf(fd, "%ld", version_minor); else if (!strcmp(varbegin, "VERSION_PATCH")) - fprintf(fd, "%d", version_patch); + fprintf(fd, "%ld", version_patch); else if (!strcmp(varbegin, "VERSION_EXTRA")) { if (version_extra) fprintf(fd, "%s", version_extra); } else if (!strcmp(varbegin, "VERSION_BUILD")) - fprintf(fd, "%d", version_build); + fprintf(fd, "%ld", version_build); else if (!strcmp(varbegin, "BUILD")) - fprintf(fd, "%d", build); + fprintf(fd, "%ld", build); else if (!strcmp(varbegin, "VERSION")) fprintf(fd, "%s", version); else if (!strcmp(varbegin, "VERSIONDOTTED")) |