From 205a2678d7afd143096f99a41199ddceb0c416ee Mon Sep 17 00:00:00 2001 From: Michael Geary Date: Thu, 28 Jan 2016 16:01:32 -0800 Subject: [PATCH 1/2] Fix error RC1015 when MFC was not installed with Visual Studio rcedit.rc has #include "afxres.h" but this file is not present when Visual Studio was installed without the MFC option. rcedit does not actually use MFC, so the fix is simply to #include instead. --- src/rcedit.rc | Bin 3014 -> 3016 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/rcedit.rc b/src/rcedit.rc index 059b43da78b7c3672e521256780122c1dc882eb8..185d98dc821e1a588076f91a910992cc03b21b5f 100644 GIT binary patch delta 42 wcmX>menNah2$Q4@LpehxLmop4Lq3pI%%I1R!C=S0%fL0+ka6*5KIR=90OjQg`Tzg` delta 40 wcmX>heoTBr2$Q%HLn1>OLj^+-Ln=ctgC0W$gAxNT1J`6j#>JZjn0Igh0Lse=LI3~& From ea0a45b564c7e253dc773184a0e8b47375c144e7 Mon Sep 17 00:00:00 2001 From: Michael Geary Date: Thu, 28 Jan 2016 16:38:26 -0800 Subject: [PATCH 2/2] Fix erroneous truncation of version fields to 8 bits These fields are actually 16 bits. --- src/main.cc | 14 +++++++------- src/rescle.cc | 8 ++++---- src/rescle.h | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main.cc b/src/main.cc index 4b83bbd..f8cb30d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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; @@ -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"); @@ -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"); diff --git a/src/rescle.cc b/src/rescle.cc index d75d9ae..8ec7527 100644 --- a/src/rescle.cc +++ b/src/rescle.cc @@ -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; } @@ -218,7 +218,7 @@ 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 { @@ -226,7 +226,7 @@ bool ResourceUpdater::SetProductVersion(const unsigned char& v1, const unsigned } } -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; } @@ -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 { diff --git a/src/rescle.h b/src/rescle.h index d40a018..b71a5df 100644 --- a/src/rescle.h +++ b/src/rescle.h @@ -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);