Skip to content

Commit

Permalink
Merge pull request #7 from geary/master
Browse files Browse the repository at this point in the history
Fix issues #5 (compilation error with no MFC) and #6 (truncation of version fields to 8 bits)
  • Loading branch information
zcbenz committed Jan 29, 2016
2 parents f2e68e8 + ea0a45b commit 660b805
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ bool print_error(const char* message) {
return 1;
}

bool parse_version_string(const wchar_t* str, int *v1, int *v2, int *v3, int *v4) {
bool parse_version_string(const wchar_t* str, unsigned short *v1, unsigned short *v2, unsigned short *v3, unsigned short *v4) {
*v1 = *v2 = *v3 = *v4 = 0;
if (swscanf_s(str, L"%d.%d.%d.%d", v1, v2, v3, v4) == 4)
if (swscanf_s(str, L"%hu.%hu.%hu.%hu", v1, v2, v3, v4) == 4)
return true;
if (swscanf_s(str, L"%d.%d.%d", v1, v2, v3) == 3)
if (swscanf_s(str, L"%hu.%hu.%hu", v1, v2, v3) == 3)
return true;
if (swscanf_s(str, L"%d.%d", v1, v2) == 2)
if (swscanf_s(str, L"%hu.%hu", v1, v2) == 2)
return true;
if (swscanf_s(str, L"%d", v1) == 1)
if (swscanf_s(str, L"%hu", v1) == 1)
return true;

return false;
Expand All @@ -46,7 +46,7 @@ int wmain(int argc, const wchar_t* argv[]) {
if (argc - i < 2)
return print_error("--set-file-version requires a version string");

int v1, v2, v3, v4;
unsigned short v1, v2, v3, v4;
if (!parse_version_string(argv[++i], &v1, &v2, &v3, &v4))
return print_error("Unable to parse version string");

Expand All @@ -61,7 +61,7 @@ int wmain(int argc, const wchar_t* argv[]) {
if (argc - i < 2)
return print_error("--set-product-version requires a version string");

int v1, v2, v3, v4;
unsigned short v1, v2, v3, v4;
if (!parse_version_string(argv[++i], &v1, &v2, &v3, &v4))
return print_error("Unable to parse version string");

Expand Down
Binary file modified src/rcedit.rc
Binary file not shown.
8 changes: 4 additions & 4 deletions src/rescle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ bool ResourceUpdater::SetVersionString(const WCHAR* name, const WCHAR* value) {
}
}

bool ResourceUpdater::SetProductVersion(const WORD& languageId, const UINT& id, const unsigned char& v1, const unsigned char& v2, const unsigned char& v3, const unsigned char& v4) {
bool ResourceUpdater::SetProductVersion(const WORD& languageId, const UINT& id, const unsigned short& v1, const unsigned short& v2, const unsigned short& v3, const unsigned short& v4) {
if (versionStampMap.find(languageId) == versionStampMap.end()) {
return false;
}
Expand All @@ -218,15 +218,15 @@ bool ResourceUpdater::SetProductVersion(const WORD& languageId, const UINT& id,
return true;
}

bool ResourceUpdater::SetProductVersion(const unsigned char& v1, const unsigned char& v2, const unsigned char& v3, const unsigned char& v4) {
bool ResourceUpdater::SetProductVersion(const unsigned short& v1, const unsigned short& v2, const unsigned short& v3, const unsigned short& v4) {
if (versionStampMap.size() < 1) {
return false;
} else {
return SetProductVersion(versionStampMap.begin()->first, 1, v1, v2, v3, v4);
}
}

bool ResourceUpdater::SetFileVersion(const WORD& languageId, const UINT& id, const unsigned char& v1, const unsigned char& v2, const unsigned char& v3, const unsigned char& v4) {
bool ResourceUpdater::SetFileVersion(const WORD& languageId, const UINT& id, const unsigned short& v1, const unsigned short& v2, const unsigned short& v3, const unsigned short& v4) {
if (versionStampMap.find(languageId) == versionStampMap.end()) {
return false;
}
Expand All @@ -243,7 +243,7 @@ bool ResourceUpdater::SetFileVersion(const WORD& languageId, const UINT& id, con
return true;
}

bool ResourceUpdater::SetFileVersion(const unsigned char& v1, const unsigned char& v2, const unsigned char& v3, const unsigned char& v4) {
bool ResourceUpdater::SetFileVersion(const unsigned short& v1, const unsigned short& v2, const unsigned short& v3, const unsigned short& v4) {
if (versionStampMap.size() < 1) {
return false;
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/rescle.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ class ResourceUpdater {
bool Load(const char* filename);
bool SetVersionString(const WORD& languageId, const WCHAR* name, const WCHAR* value);
bool SetVersionString(const WCHAR* name, const WCHAR* value);
bool SetProductVersion(const WORD& languageId, const UINT& id, const unsigned char& v1, const unsigned char& v2, const unsigned char& v3, const unsigned char& v4);
bool SetProductVersion(const unsigned char& v1, const unsigned char& v2, const unsigned char& v3, const unsigned char& v4);
bool SetFileVersion(const WORD& languageId, const UINT& id, const unsigned char& v1, const unsigned char& v2, const unsigned char& v3, const unsigned char& v4);
bool SetFileVersion(const unsigned char& v1, const unsigned char& v2, const unsigned char& v3, const unsigned char& v4);
bool SetProductVersion(const WORD& languageId, const UINT& id, const unsigned short& v1, const unsigned short& v2, const unsigned short& v3, const unsigned short& v4);
bool SetProductVersion(const unsigned short& v1, const unsigned short& v2, const unsigned short& v3, const unsigned short& v4);
bool SetFileVersion(const WORD& languageId, const UINT& id, const unsigned short& v1, const unsigned short& v2, const unsigned short& v3, const unsigned short& v4);
bool SetFileVersion(const unsigned short& v1, const unsigned short& v2, const unsigned short& v3, const unsigned short& v4);
bool ChangeString(const WORD& languageId, const UINT& id, const WCHAR* value);
bool ChangeString(const UINT& id, const WCHAR* value);
bool SetIcon(const WCHAR* path);
Expand Down

0 comments on commit 660b805

Please sign in to comment.