From fba4c4d34254e2003ee2ecd58f62d50896422116 Mon Sep 17 00:00:00 2001 From: kichik Date: Thu, 5 Dec 2002 14:49:00 +0000 Subject: [PATCH] Type mismatches git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1884 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/DialogTemplate.cpp | 38 +++++++++++++++++++------------------- Source/ResourceEditor.cpp | 16 ++++++++-------- Source/lang.cpp | 14 +++++++------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Source/DialogTemplate.cpp b/Source/DialogTemplate.cpp index f4916773..7f0fa5bf 100644 --- a/Source/DialogTemplate.cpp +++ b/Source/DialogTemplate.cpp @@ -210,7 +210,7 @@ CDialogTemplate::~CDialogTemplate() { if (m_szFont) delete [] m_szTitle; - for (int i = 0; i < m_vItems.size(); i++) { + for (unsigned int i = 0; i < m_vItems.size(); i++) { if (m_vItems[i]->szClass && !IS_INTRESOURCE(m_vItems[i]->szClass)) delete [] m_vItems[i]->szClass; if (m_vItems[i]->szTitle && !IS_INTRESOURCE(m_vItems[i]->szTitle)) @@ -226,7 +226,7 @@ CDialogTemplate::~CDialogTemplate() { // Returns info about the item with the id wId DialogItemTemplate* CDialogTemplate::GetItem(WORD wId) { - for (int i = 0; i < m_vItems.size(); i++) + for (unsigned int i = 0; i < m_vItems.size(); i++) if (m_vItems[i]->wId == wId) return m_vItems[i]; return 0; @@ -240,7 +240,7 @@ DialogItemTemplate* CDialogTemplate::GetItemByIdx(DWORD i) { // Removes an item void CDialogTemplate::RemoveItem(WORD wId) { - for (int i = 0; i < m_vItems.size(); i++) + for (unsigned int i = 0; i < m_vItems.size(); i++) if (m_vItems[i]->wId == wId) m_vItems.erase(m_vItems.begin() + i); } @@ -283,7 +283,7 @@ void CDialogTemplate::AddItem(DialogItemTemplate item) { // Moves all of the items in the dialog by (x,y) and resizes the dialog by (x,y) void CDialogTemplate::MoveAllAndResize(short x, short y) { // Move all items - for (int i = 0; i < m_vItems.size(); i++) { + for (unsigned int i = 0; i < m_vItems.size(); i++) { m_vItems[i]->sX += x; m_vItems[i]->sY += y; } @@ -311,8 +311,8 @@ void CDialogTemplate::PixelsToDlgUnits(short& x, short& y) { MapDialogRect(hDlg, &r); DestroyWindow(hDlg); - x = float(x) / (float(r.right)/10000); - y = float(y) / (float(r.bottom)/10000); + x = short(float(x) / (float(r.right)/10000)); + y = short(float(y) / (float(r.bottom)/10000)); } // Converts pixels to this dialog's units @@ -322,8 +322,8 @@ void CDialogTemplate::DlgUnitsToPixels(short& x, short& y) { MapDialogRect(hDlg, &r); DestroyWindow(hDlg); - x = float(x) * (float(r.right)/10000); - y = float(y) * (float(r.bottom)/10000); + x = short(float(x) * (float(r.right)/10000)); + y = short(float(y) * (float(r.bottom)/10000)); } // Returns the size of a string in the dialog (in dialog units) @@ -359,8 +359,8 @@ void CDialogTemplate::RTrimToString(WORD id, char *str, int margins) { size.cx += margins; size.cy += 2; - item->sWidth = size.cx; - item->sHeight = size.cy; + item->sWidth = short(size.cx); + item->sHeight = short(size.cy); } // Trims the left margins of a control to fit a given text string size. @@ -373,9 +373,9 @@ void CDialogTemplate::LTrimToString(WORD id, char *str, int margins) { size.cx += margins; size.cy += 2; - item->sX += item->sWidth - size.cx; - item->sWidth = size.cx; - item->sHeight = size.cy; + item->sX += item->sWidth - short(size.cx); + item->sWidth = short(size.cx); + item->sHeight = short(size.cy); } // Trims the left and right margins of a control to fit a given text string size. @@ -388,14 +388,14 @@ void CDialogTemplate::CTrimToString(WORD id, char *str, int margins) { size.cx += margins; size.cy += 2; - item->sX += item->sWidth/2 - size.cx/2; - item->sWidth = size.cx; - item->sHeight = size.cy; + item->sX += item->sWidth/2 - short(size.cx/2); + item->sWidth = short(size.cx); + item->sHeight = short(size.cy); } // Moves every item right and gives it the WS_EX_RIGHT extended style void CDialogTemplate::ConvertToRTL() { - for (int i = 0; i < m_vItems.size(); i++) { + for (unsigned int i = 0; i < m_vItems.size(); i++) { bool addExStyle = false; if (m_vItems[i]->dwExtStyle & WS_EX_LEFT) addExStyle = true; @@ -486,7 +486,7 @@ BYTE* CDialogTemplate::Save(DWORD& dwSize) { } // Write all of the items - for (int i = 0; i < m_vItems.size(); i++) { + for (unsigned int i = 0; i < m_vItems.size(); i++) { // DLGITEMTEMPLATE[EX]s must be aligned on DWORD boundry if (DWORD(seeker - pbDlg) % sizeof(DWORD)) seeker += sizeof(WORD); @@ -559,7 +559,7 @@ DWORD CDialogTemplate::GetSize() { AddStringOrIdSize(m_szFont); } - for (int i = 0; i < m_vItems.size(); i++) { + for (unsigned int i = 0; i < m_vItems.size(); i++) { // DLGITEMTEMPLATE[EX]s must be aligned on DWORD boundry ALIGN(dwSize, sizeof(DWORD)); diff --git a/Source/ResourceEditor.cpp b/Source/ResourceEditor.cpp index 0741638e..e93a65c0 100644 --- a/Source/ResourceEditor.cpp +++ b/Source/ResourceEditor.cpp @@ -201,7 +201,7 @@ BYTE* CResourceEditor::GetResource(char* szType, char* szName, LANGID wLanguage) // Saves the edited PE into a buffer and returns it. BYTE* CResourceEditor::Save(DWORD &dwSize) { - int i; + unsigned int i; DWORD dwRsrcSize = m_cResDir->GetSize(); // Size of new resource section DWORD dwRsrcSizeAligned = RALIGN(dwRsrcSize, m_ntHeaders->OptionalHeader.FileAlignment); // Align it to FileAlignment @@ -513,8 +513,8 @@ IMAGE_RESOURCE_DIRECTORY CResourceDirectory::GetInfo() { return m_rdDir; } -CResourceDirectoryEntry* CResourceDirectory::GetEntry(int i) { - if (m_vEntries.size() < i || i < 0) +CResourceDirectoryEntry* CResourceDirectory::GetEntry(unsigned int i) { + if (m_vEntries.size() < i) return 0; return m_vEntries[i]; } @@ -571,9 +571,9 @@ int CResourceDirectory::Find(char* szName) { return Find(WORD(szName)); else if (szName[0] == '#') - return Find(atol(szName+1)); + return Find(WORD(atoi(szName+1))); - for (int i = 0; i < m_vEntries.size(); i++) { + for (unsigned int i = 0; i < m_vEntries.size(); i++) { if (!m_vEntries[i]->HasName()) continue; @@ -591,7 +591,7 @@ int CResourceDirectory::Find(char* szName) { // Returns the index of a directory entry with the specified id // Returns -1 if can not be found int CResourceDirectory::Find(WORD wId) { - for (int i = 0; i < m_vEntries.size(); i++) { + for (unsigned int i = 0; i < m_vEntries.size(); i++) { if (m_vEntries[i]->HasName()) continue; @@ -605,7 +605,7 @@ int CResourceDirectory::Find(WORD wId) { // Get the size of this resource directory (including all of its children) DWORD CResourceDirectory::GetSize() { DWORD dwSize = sizeof(IMAGE_RESOURCE_DIRECTORY); - for (int i = 0; i < m_vEntries.size(); i++) { + for (unsigned int i = 0; i < m_vEntries.size(); i++) { dwSize += sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY); if (m_vEntries[i]->HasName()) dwSize += sizeof(IMAGE_RESOURCE_DIR_STRING_U) + m_vEntries[i]->GetNameLength()*sizeof(WCHAR); @@ -622,7 +622,7 @@ DWORD CResourceDirectory::GetSize() { // Destroys this directory and all of its children void CResourceDirectory::Destroy() { - for (int i = 0; i < m_vEntries.size(); i++) { + for (unsigned int i = 0; i < m_vEntries.size(); i++) { if (m_vEntries[i]->IsDataDirectory()) { m_vEntries[i]->GetSubDirectory()->Destroy(); delete m_vEntries[i]->GetSubDirectory(); diff --git a/Source/lang.cpp b/Source/lang.cpp index 8864e612..c7f8cb52 100644 --- a/Source/lang.cpp +++ b/Source/lang.cpp @@ -71,7 +71,7 @@ StringTable* CEXEBuild::GetTable(LANGID &lang) { lang=lang?lang:last_used_lang; last_used_lang=lang; StringTable *table = 0; - for (int i = 0; i < string_tables.size(); i++) { + for (unsigned int i = 0; i < string_tables.size(); i++) { if (lang == string_tables[i]->lang_id) { table = string_tables[i]; break; @@ -89,7 +89,7 @@ StringTable* CEXEBuild::GetTable(LANGID &lang) { int zero = 0; // make sure all of the user's strings tables are the same size - for (int j = 0; j < string_tables.size(); j++) { + for (unsigned int j = 0; j < string_tables.size(); j++) { int i = build_userlangstrings.getnum(); i -= table->user_strings.getlen() / sizeof(int); while (i--) table->user_strings.add(&zero, sizeof(int)); @@ -224,13 +224,13 @@ int CEXEBuild::SetUserString(char *name, LANGID lang, char *string, int process/ } #define MAX(a, b) (a > b ? a : b) - user_strings->resize(MAX(user_strings->getlen(), (idx+1)*sizeof(int))); + user_strings->resize(MAX(user_strings->getlen(), (unsigned int)(idx+1)*sizeof(unsigned int))); ((int*)user_strings->get())[idx] = uninst ? add_string_uninst(string,process) : add_string_main(string,process); int zero = 0; // make sure all of the user's strings tables are the same size - for (int j = 0; j < string_tables.size(); j++) { + for (unsigned int j = 0; j < string_tables.size(); j++) { int i = user_strings_list->getnum(); if (uninst) i -= string_tables[j]->user_ustrings.getlen() / sizeof(int); else i -= string_tables[j]->user_strings.getlen() / sizeof(int); @@ -247,7 +247,7 @@ bool CEXEBuild::_IsSet(int *str, LANGID lang) { if (!str) return false; lang = lang?lang:build_nlfs.size()?build_nlfs[build_nlfs.size()-1]->GetLang():0; lang = lang?lang:string_tables.size()?string_tables[0]->lang_id:1033; // Default is English (1033) - int i; + unsigned int i; for (i = 0; i < string_tables.size(); i++) { if (lang == string_tables[i]->lang_id) { break; @@ -302,7 +302,7 @@ int CEXEBuild::WriteStringTables() { void CEXEBuild::FillDefaultsIfNeeded(StringTable *table, NLF *nlf/*=0*/) { if (!nlf) { - for (int i = 0; i < build_nlfs.size(); i++) { + for (unsigned int i = 0; i < build_nlfs.size(); i++) { if (build_nlfs[i]->GetLang() == table->lang_id) { nlf = build_nlfs[i]; break; @@ -546,7 +546,7 @@ void CEXEBuild::FillDefaultsIfNeeded(StringTable *table, NLF *nlf/*=0*/) { bool CEXEBuild::_IsNotSet(int *str) { if (!str) return true; - for (int i = 0; i < string_tables.size(); i++) { + for (unsigned int i = 0; i < string_tables.size(); i++) { if (*(int*)(int(str)-int(string_tables[0])+int(string_tables[i]))) { return false; }