diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2012-08-01 18:12:05 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2012-08-01 18:12:05 +0000 |
commit | befbbe3b75cf8001b40fc5fa06d66f1d5b9614da (patch) | |
tree | 0f281a8f499516691634f91848e1656f19dbea26 /plugins/SpellChecker/src | |
parent | 369f8ac171c5268c2d8944aaeb7fc365e833a832 (diff) |
SpellChecker:
code cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@1309 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SpellChecker/src')
-rw-r--r-- | plugins/SpellChecker/src/ardialog.cpp | 8 | ||||
-rw-r--r-- | plugins/SpellChecker/src/autoreplace.cpp | 4 | ||||
-rw-r--r-- | plugins/SpellChecker/src/commons.h | 11 | ||||
-rw-r--r-- | plugins/SpellChecker/src/dictionary.cpp | 80 | ||||
-rw-r--r-- | plugins/SpellChecker/src/options.cpp | 18 | ||||
-rw-r--r-- | plugins/SpellChecker/src/spellchecker.cpp | 56 |
6 files changed, 86 insertions, 91 deletions
diff --git a/plugins/SpellChecker/src/ardialog.cpp b/plugins/SpellChecker/src/ardialog.cpp index 6a08585ea1..8ef67f06cb 100644 --- a/plugins/SpellChecker/src/ardialog.cpp +++ b/plugins/SpellChecker/src/ardialog.cpp @@ -112,7 +112,7 @@ static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP case WM_PASTE:
{
TCHAR text[256];
- GetWindowText(hwnd, text, MAX_REGS(text));
+ GetWindowText(hwnd, text, SIZEOF(text));
scoped_free<TCHAR> dest = data->dict->autoReplace->filterText(text);
SetWindowText(hwnd, dest);
@@ -250,16 +250,16 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa TCHAR find[256];
if (data->findReadOnly)
{
- lstrcpyn(find, data->find.c_str(), MAX_REGS(find));
+ lstrcpyn(find, data->find.c_str(), SIZEOF(find));
}
else
{
- GetDlgItemText(hwndDlg, IDC_OLD, find, MAX_REGS(find));
+ GetDlgItemText(hwndDlg, IDC_OLD, find, SIZEOF(find));
lstrtrim(find);
}
TCHAR replace[256];
- GetDlgItemText(hwndDlg, IDC_NEW, replace, MAX_REGS(replace));
+ GetDlgItemText(hwndDlg, IDC_NEW, replace, SIZEOF(replace));
lstrtrim(replace);
if (!data->findReadOnly && find[0] == 0)
diff --git a/plugins/SpellChecker/src/autoreplace.cpp b/plugins/SpellChecker/src/autoreplace.cpp index 2d257ccfec..a5481f7d9b 100644 --- a/plugins/SpellChecker/src/autoreplace.cpp +++ b/plugins/SpellChecker/src/autoreplace.cpp @@ -35,7 +35,7 @@ AutoReplacement::AutoReplacement(const TCHAR *replace, BOOL useVariables) AutoReplaceMap::AutoReplaceMap(TCHAR *aFilename, Dictionary *dict)
{
this->dict = dict;
- lstrcpyn(filename, aFilename, MAX_REGS(filename));
+ lstrcpyn(filename, aFilename, SIZEOF(filename));
loadAutoReplaceMap();
}
@@ -50,7 +50,7 @@ void AutoReplaceMap::loadAutoReplaceMap() int pos = 0;
while((c = fgetc(file)) != EOF)
{
- if (c == '\n' || c == '\r' || pos >= MAX_REGS(tmp) - 1)
+ if (c == '\n' || c == '\r' || pos >= SIZEOF(tmp) - 1)
{
if (pos > 0)
{
diff --git a/plugins/SpellChecker/src/commons.h b/plugins/SpellChecker/src/commons.h index 2ad53b6092..834c2ad21e 100644 --- a/plugins/SpellChecker/src/commons.h +++ b/plugins/SpellChecker/src/commons.h @@ -20,8 +20,7 @@ Boston, MA 02111-1307, USA. #ifndef __COMMONS_H__
# define __COMMONS_H__
-
-#define OEMRESOURCE
+#define OEMRESOURCE
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
@@ -31,9 +30,6 @@ Boston, MA 02111-1307, USA. #include <richole.h>
#include <commctrl.h>
-// Disable "...truncated to '255' characters in the debug information" warnings
-#pragma warning(disable: 4786)
-
#include <map>
#include <vector>
#include <string>
@@ -41,8 +37,7 @@ using namespace std; // Miranda headers
-#define MIRANDA_VER 0x0900
-#define MIRANDA_CUSTOM_LP
+#define MIRANDA_VER 0x0A00
#include <newpluginapi.h>
#include <m_system.h>
#include <m_system_cpp.h>
@@ -59,6 +54,7 @@ using namespace std; #include <m_message.h>
#include <m_icolib.h>
#include <m_hotkeys.h>
+#include <win2k.h>
//own includes
#include "m_folders.h"
@@ -95,7 +91,6 @@ extern BOOL uinfoex_enabled; extern BOOL variables_enabled;
-#define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]))
#define FREE(_m_) if (_m_ != NULL) { free(_m_); _m_ = NULL; }
diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp index ac24af66ea..84cb4955db 100644 --- a/plugins/SpellChecker/src/dictionary.cpp +++ b/plugins/SpellChecker/src/dictionary.cpp @@ -56,7 +56,7 @@ protected: void loadCustomDict()
{
TCHAR filename[1024];
- mir_sntprintf(filename, MAX_REGS(filename), _T("%s\\%s.cdic"), userPath, language);
+ mir_sntprintf(filename, SIZEOF(filename), _T("%s\\%s.cdic"), userPath, language);
FILE *file = _tfopen(filename, _T("rb"));
if (file != NULL)
@@ -66,7 +66,7 @@ protected: int pos = 0;
while((c = fgetc(file)) != EOF)
{
- if (c == '\n' || c == '\r' || pos >= MAX_REGS(tmp) - 1)
+ if (c == '\n' || c == '\r' || pos >= SIZEOF(tmp) - 1)
{
if (pos > 0)
{
@@ -91,13 +91,13 @@ protected: CreatePath(userPath);
TCHAR filename[1024];
- mir_sntprintf(filename, MAX_REGS(filename), _T("%s\\%s.cdic"), userPath, language);
+ mir_sntprintf(filename, SIZEOF(filename), _T("%s\\%s.cdic"), userPath, language);
FILE *file = _tfopen(filename, _T("ab"));
if (file != NULL)
{
char tmp[1024];
- toHunspell(tmp, word, MAX_REGS(tmp));
+ toHunspell(tmp, word, SIZEOF(tmp));
fprintf(file, "%s\n", tmp);
fclose(file);
}
@@ -109,7 +109,7 @@ protected: return;
char hunspell_word[1024];
- toHunspell(hunspell_word, word, MAX_REGS(hunspell_word));
+ toHunspell(hunspell_word, word, SIZEOF(hunspell_word));
hunspell->add(hunspell_word);
}
@@ -144,13 +144,13 @@ protected: public:
HunspellDictionary(TCHAR *aLanguage, TCHAR *aFileWithoutExtension, TCHAR *anUserPath, TCHAR *aSource)
{
- lstrcpyn(language, aLanguage, MAX_REGS(language));
- lstrcpyn(fileWithoutExtension, aFileWithoutExtension, MAX_REGS(fileWithoutExtension));
- lstrcpyn(userPath, anUserPath, MAX_REGS(userPath));
+ lstrcpyn(language, aLanguage, SIZEOF(language));
+ lstrcpyn(fileWithoutExtension, aFileWithoutExtension, SIZEOF(fileWithoutExtension));
+ lstrcpyn(userPath, anUserPath, SIZEOF(userPath));
if (aSource == NULL)
source[0] = _T('\0');
else
- lstrcpyn(source, aSource, MAX_REGS(source));
+ lstrcpyn(source, aSource, SIZEOF(source));
loaded = LANGUAGE_NOT_LOADED;
localized_name[0] = _T('\0');
@@ -230,8 +230,8 @@ public: char aff[1024];
- mir_snprintf(dic, MAX_REGS(dic), "%S.dic", fileWithoutExtension);
- mir_snprintf(aff, MAX_REGS(aff), "%S.aff", fileWithoutExtension);
+ mir_snprintf(dic, SIZEOF(dic), "%S.dic", fileWithoutExtension);
+ mir_snprintf(aff, SIZEOF(aff), "%S.aff", fileWithoutExtension);
hunspell = new Hunspell(aff, dic);
@@ -251,7 +251,7 @@ public: }
else
{
- for (int i = 0; i < MAX_REGS(codepages); i++)
+ for (int i = 0; i < SIZEOF(codepages); i++)
{
if (_strcmpi(codepages[i].name, dic_enc) == 0)
{
@@ -292,7 +292,7 @@ public: // TODO Check if it was generated by auto-replacement
char hunspell_word[1024];
- toHunspell(hunspell_word, word, MAX_REGS(hunspell_word));
+ toHunspell(hunspell_word, word, SIZEOF(hunspell_word));
return hunspell->spell(hunspell_word);
}
@@ -307,7 +307,7 @@ public: return ret;
char hunspell_word[1024];
- toHunspell(hunspell_word, word, MAX_REGS(hunspell_word));
+ toHunspell(hunspell_word, word, SIZEOF(hunspell_word));
char ** words = NULL;
ret.count = hunspell->suggest(&words, hunspell_word);
@@ -339,7 +339,7 @@ public: return ret;
char hunspell_word[1024];
- toHunspell(hunspell_word, word, MAX_REGS(hunspell_word));
+ toHunspell(hunspell_word, word, SIZEOF(hunspell_word));
char ** words;
int count = hunspell->suggest_auto(&words, hunspell_word);
@@ -369,7 +369,7 @@ public: return NULL;
char hunspell_word[1024];
- toHunspell(hunspell_word, word, MAX_REGS(hunspell_word));
+ toHunspell(hunspell_word, word, SIZEOF(hunspell_word));
char ** words;
int count = hunspell->suggest_auto(&words, hunspell_word);
@@ -454,11 +454,11 @@ BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) TCHAR ini[32];
TCHAR end[32];
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO639LANGNAME, ini, MAX_REGS(ini));
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO3166CTRYNAME, end, MAX_REGS(end));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO639LANGNAME, ini, SIZEOF(ini));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO3166CTRYNAME, end, SIZEOF(end));
TCHAR name[64];
- mir_sntprintf(name, MAX_REGS(name), _T("%s_%s"), ini, end);
+ mir_sntprintf(name, SIZEOF(name), _T("%s_%s"), ini, end);
for(int i = 0; i < tmp_dicts->getCount(); i++)
{
@@ -468,30 +468,30 @@ BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) #define LOCALE_SLOCALIZEDLANGUAGENAME 0x0000006f
#define LOCALE_SNATIVEDISPLAYNAME 0x00000073
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGLANGUAGE, dict->english_name, MAX_REGS(dict->english_name));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGLANGUAGE, dict->english_name, SIZEOF(dict->english_name));
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLANGUAGE, dict->localized_name, MAX_REGS(dict->localized_name));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLANGUAGE, dict->localized_name, SIZEOF(dict->localized_name));
if (dict->localized_name[0] == 0)
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLOCALIZEDLANGUAGENAME, dict->localized_name, MAX_REGS(dict->localized_name));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLOCALIZEDLANGUAGENAME, dict->localized_name, SIZEOF(dict->localized_name));
if (dict->localized_name[0] == 0)
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SNATIVEDISPLAYNAME, dict->localized_name, MAX_REGS(dict->localized_name));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SNATIVEDISPLAYNAME, dict->localized_name, SIZEOF(dict->localized_name));
if (dict->localized_name[0] == 0 && dict->english_name[0] != 0)
{
TCHAR country[1024];
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGCOUNTRY, country, MAX_REGS(country));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGCOUNTRY, country, SIZEOF(country));
TCHAR name[1024];
if (country[0] != 0)
- mir_sntprintf(name, MAX_REGS(name), _T("%s (%s)"), dict->english_name, country);
+ mir_sntprintf(name, SIZEOF(name), _T("%s (%s)"), dict->english_name, country);
else
- lstrcpyn(name, dict->english_name, MAX_REGS(name));
+ lstrcpyn(name, dict->english_name, SIZEOF(name));
- lstrcpyn(dict->localized_name, TranslateTS(name), MAX_REGS(dict->localized_name));
+ lstrcpyn(dict->localized_name, TranslateTS(name), SIZEOF(dict->localized_name));
}
if (dict->localized_name[0] != 0)
{
- mir_sntprintf(dict->full_name, MAX_REGS(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language);
+ mir_sntprintf(dict->full_name, SIZEOF(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language);
}
break;
}
@@ -519,17 +519,17 @@ void GetDictsInfo(LIST<Dictionary> &dicts) if (!DBGetContactSettingTString(NULL, MODULE_NAME, lang, &dbv))
{
- lstrcpyn(dict->localized_name, dbv.ptszVal, MAX_REGS(dict->localized_name));
+ lstrcpyn(dict->localized_name, dbv.ptszVal, SIZEOF(dict->localized_name));
DBFreeVariant(&dbv);
}
if (dict->localized_name[0] == _T('\0'))
{
- for(size_t j = 0; j < MAX_REGS(aditionalLanguages); j+=2)
+ for(size_t j = 0; j < SIZEOF(aditionalLanguages); j+=2)
{
if (lstrcmp(aditionalLanguages[j], dict->language) == 0)
{
- lstrcpyn(dict->localized_name, aditionalLanguages[j+1], MAX_REGS(dict->localized_name));
+ lstrcpyn(dict->localized_name, aditionalLanguages[j+1], SIZEOF(dict->localized_name));
break;
}
}
@@ -537,11 +537,11 @@ void GetDictsInfo(LIST<Dictionary> &dicts) if (dict->localized_name[0] != _T('\0'))
{
- mir_sntprintf(dict->full_name, MAX_REGS(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language);
+ mir_sntprintf(dict->full_name, SIZEOF(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language);
}
else
{
- lstrcpyn(dict->full_name, dict->language, MAX_REGS(dict->full_name));
+ lstrcpyn(dict->full_name, dict->language, SIZEOF(dict->full_name));
}
}
}
@@ -552,7 +552,7 @@ void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, TCHAR *path, TCH {
// Load the language files and create an array with then
TCHAR file[1024];
- mir_sntprintf(file, MAX_REGS(file), _T("%s\\*.dic"), path);
+ mir_sntprintf(file, SIZEOF(file), _T("%s\\*.dic"), path);
BOOL found = FALSE;
@@ -562,7 +562,7 @@ void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, TCHAR *path, TCH {
do
{
- mir_sntprintf(file, MAX_REGS(file), _T("%s\\%s"), path, ffd.cFileName);
+ mir_sntprintf(file, SIZEOF(file), _T("%s\\%s"), path, ffd.cFileName);
// Check .dic
DWORD attrib = GetFileAttributes(file);
@@ -620,16 +620,16 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_pa #define MUICACHE _T("Software\\Microsoft\\Windows\\ShellNoRoam\\MUICache")
// Get other apps dicts
- for (int i = 0; i < MAX_REGS(otherHunspellApps); i += 2)
+ for (int i = 0; i < SIZEOF(otherHunspellApps); i += 2)
{
TCHAR key[1024];
- mir_sntprintf(key, MAX_REGS(key), APPPATH, otherHunspellApps[i+1]);
+ mir_sntprintf(key, SIZEOF(key), APPPATH, otherHunspellApps[i+1]);
HKEY hKey = 0;
LONG lResult = 0;
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE, &hKey))
{
- DWORD size = MAX_REGS(key);
+ DWORD size = SIZEOF(key);
lResult = RegQueryValueEx(hKey, _T("Path"), NULL, NULL, (LPBYTE)key, &size);
RegCloseKey(hKey);
}
@@ -646,7 +646,7 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_pa lResult = ERROR_NO_MORE_ITEMS;
for (DWORD local = 0; local < numValues; local++)
{
- DWORD cchValue = MAX_REGS(key);
+ DWORD cchValue = SIZEOF(key);
if (ERROR_SUCCESS != RegEnumValue(hKey, local, key, &cchValue, NULL, NULL, NULL, NULL))
break;
key[cchValue] = 0;
@@ -668,7 +668,7 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_pa if (ERROR_SUCCESS == lResult)
{
TCHAR folder[1024];
- mir_sntprintf(folder, MAX_REGS(folder), _T("%s\\Dictionaries"), key);
+ mir_sntprintf(folder, SIZEOF(folder), _T("%s\\Dictionaries"), key);
GetHunspellDictionariesFromFolder(languages, folder, user_path, otherHunspellApps[i]);
}
diff --git a/plugins/SpellChecker/src/options.cpp b/plugins/SpellChecker/src/options.cpp index 28886b1126..ac2f236b5a 100644 --- a/plugins/SpellChecker/src/options.cpp +++ b/plugins/SpellChecker/src/options.cpp @@ -74,7 +74,7 @@ int InitOptionsCallback(WPARAM wParam,LPARAM lParam) odp.flags = ODPF_BOLDGROUPS;
odp.nIDBottomSimpleControl = IDC_SPELL_CHECKER;
odp.expertOnlyControls = optionsExpertControls;
- odp.nExpertOnlyControls = MAX_REGS(optionsExpertControls);
+ odp.nExpertOnlyControls = SIZEOF(optionsExpertControls);
Options_AddPage(wParam, &odp);
ZeroMemory(&odp,sizeof(odp));
@@ -106,8 +106,8 @@ void DeInitOptions() void LoadOptions()
{
- LoadOpts(optionsControls, MAX_REGS(optionsControls), MODULE_NAME);
- LoadOpts(autoReplaceControls, MAX_REGS(autoReplaceControls), MODULE_NAME);
+ LoadOpts(optionsControls, SIZEOF(optionsControls), MODULE_NAME);
+ LoadOpts(autoReplaceControls, SIZEOF(autoReplaceControls), MODULE_NAME);
if (languages.getCount() <= 0)
{
@@ -118,7 +118,7 @@ void LoadOptions() DBVARIANT dbv;
if (!DBGetContactSettingTString(NULL, MODULE_NAME, "DefaultLanguage", &dbv))
{
- lstrcpyn(opts.default_language, dbv.ptszVal, MAX_REGS(opts.default_language));
+ lstrcpyn(opts.default_language, dbv.ptszVal, SIZEOF(opts.default_language));
DBFreeVariant(&dbv);
}
@@ -290,7 +290,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP }
}
- return SaveOptsDlgProc(optionsControls, MAX_REGS(optionsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
+ return SaveOptsDlgProc(optionsControls, SIZEOF(optionsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
}
@@ -411,7 +411,7 @@ static void ShowAddReplacement(HWND hwndDlg, int item = -1) }
else
{
- ListView_GetItemText(GetDlgItem(hwndDlg, IDC_REPLACEMENTS), item, 0, find, MAX_REGS(find));
+ ListView_GetItemText(GetDlgItem(hwndDlg, IDC_REPLACEMENTS), item, 0, find, SIZEOF(find));
}
if (lstrlen(find) > 0)
@@ -438,7 +438,7 @@ static INT_PTR CALLBACK AutoreplaceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam {
case WM_INITDIALOG:
{
- BOOL ret = SaveOptsDlgProc(autoReplaceControls, MAX_REGS(autoReplaceControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
+ BOOL ret = SaveOptsDlgProc(autoReplaceControls, SIZEOF(autoReplaceControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
int sel = -1;
for(int i = 0; i < languages.getCount(); i++)
@@ -510,7 +510,7 @@ static INT_PTR CALLBACK AutoreplaceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam while(sel >= 0)
{
TCHAR tmp[256];
- ListView_GetItemText(hList, sel, 0, tmp, MAX_REGS(tmp));
+ ListView_GetItemText(hList, sel, 0, tmp, SIZEOF(tmp));
data->RemoveWord(tmp);
changed = TRUE;
@@ -599,7 +599,7 @@ static INT_PTR CALLBACK AutoreplaceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam }
- return SaveOptsDlgProc(autoReplaceControls, MAX_REGS(autoReplaceControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
+ return SaveOptsDlgProc(autoReplaceControls, SIZEOF(autoReplaceControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
}
diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp index a126070604..afbf7485a5 100644 --- a/plugins/SpellChecker/src/spellchecker.cpp +++ b/plugins/SpellChecker/src/spellchecker.cpp @@ -212,7 +212,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) sid.ptszSection = LPGENT("Spell Checker"); sid.ptszDefaultFile = path; - for (unsigned i = 0; i < MAX_REGS(iconList); ++i) + for (unsigned i = 0; i < SIZEOF(iconList); ++i) { sid.ptszDescription = iconList[i].szDescr; sid.pszName = iconList[i].szName; @@ -230,7 +230,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) { // Load flags dll TCHAR flag_file[1024]; - mir_sntprintf(flag_file, MAX_REGS(flag_file), _T("%s\\flags.dll"), flagsDllFolder); + mir_sntprintf(flag_file, SIZEOF(flag_file), _T("%s\\flags.dll"), flagsDllFolder); HMODULE hFlagsDll = LoadLibraryEx(flag_file, NULL, LOAD_LIBRARY_AS_DATAFILE); sid.flags = SIDF_ALL_TCHAR | SIDF_SORTED; @@ -242,7 +242,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) sid.ptszDescription = languages[i]->full_name; char lang[32]; - mir_snprintf(lang, MAX_REGS(lang), "%S", languages[i]->language); + mir_snprintf(lang, SIZEOF(lang), "%S", languages[i]->language); sid.pszName = lang; @@ -315,7 +315,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) sid.dwId = i; char tmp[128]; - mir_snprintf(tmp, MAX_REGS(tmp), "%s - " TCHAR_STR_PARAM, + mir_snprintf(tmp, SIZEOF(tmp), "%s - " TCHAR_STR_PARAM, Translate("Spell Checker"), languages[i]->full_name); sid.szTooltip = tmp; @@ -359,7 +359,7 @@ int IconsChanged(WPARAM wParam, LPARAM lParam) sid.dwId = i; char tmp[128]; - mir_snprintf(tmp, MAX_REGS(tmp), "%s - " TCHAR_STR_PARAM, + mir_snprintf(tmp, SIZEOF(tmp), "%s - " TCHAR_STR_PARAM, Translate("Spell Checker"), languages[i]->full_name); sid.szTooltip = tmp; @@ -379,10 +379,10 @@ int IconsChanged(WPARAM wParam, LPARAM lParam) int PreShutdown(WPARAM wParam, LPARAM lParam) { int i; - for(i = 0; i < MAX_REGS(hServices); i++) + for(i = 0; i < SIZEOF(hServices); i++) DestroyServiceFunction(hServices[i]); - for(i = 0; i < MAX_REGS(hHooks); i++) + for(i = 0; i < SIZEOF(hHooks); i++) UnhookEvent(hHooks[i]); DeInitOptions(); @@ -672,7 +672,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, { int errors = 0; TCHAR text[1024]; - dlg->re->GetLine(line, text, MAX_REGS(text)); + dlg->re->GetLine(line, text, SIZEOF(text)); int len = lstrlen(text); int first_char = dlg->re->GetFirstCharOfLine(line); @@ -774,7 +774,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, if (dif != 0) { // Read line again - dlg->re->GetLine(line, text, MAX_REGS(text)); + dlg->re->GetLine(line, text, SIZEOF(text)); len = lstrlen(text); int old_first_char = first_char; @@ -859,8 +859,8 @@ void ToLocaleID(TCHAR *szKLName, size_t size) TCHAR ini[32]; TCHAR end[32]; - GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO639LANGNAME, ini, MAX_REGS(ini)); - GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO3166CTRYNAME, end, MAX_REGS(end)); + GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO639LANGNAME, ini, SIZEOF(ini)); + GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO3166CTRYNAME, end, SIZEOF(end)); mir_sntprintf(szKLName, size, _T("%s_%s"), ini, end); } @@ -872,12 +872,12 @@ void LoadDictFromKbdl(Dialog *dlg) // Use default input language HKL hkl = GetKeyboardLayout(0); - mir_sntprintf(szKLName, MAX_REGS(szKLName), _T("%x"), (int) LOWORD(hkl)); - ToLocaleID(szKLName, MAX_REGS(szKLName)); + mir_sntprintf(szKLName, SIZEOF(szKLName), _T("%x"), (int) LOWORD(hkl)); + ToLocaleID(szKLName, SIZEOF(szKLName)); // Old code (use keyboard layout) // GetKeyboardLayoutName(szKLName); -// ToLocaleID(szKLName, MAX_REGS(szKLName)); +// ToLocaleID(szKLName, SIZEOF(szKLName)); int d = GetClosestLanguage(szKLName); if (d >= 0) @@ -934,7 +934,7 @@ LRESULT CALLBACK OwnerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (errors > 0) { TCHAR text[500]; - mir_sntprintf(text,MAX_REGS(text),TranslateT("There are %d spelling errors. Are you sure you want to send this message?"),errors); + mir_sntprintf(text,SIZEOF(text),TranslateT("There are %d spelling errors. Are you sure you want to send this message?"),errors); if (MessageBox(hwnd,text,TranslateT("Spell Checker"), MB_ICONQUESTION | MB_YESNO) == IDNO) { return TRUE; @@ -1068,7 +1068,7 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) TCHAR text[1024]; int first_char; - GetWordCharRange(dlg, sel, text, MAX_REGS(text), first_char); + GetWordCharRange(dlg, sel, text, SIZEOF(text), first_char); SetNoUnderline(dlg->re, sel.cpMin, sel.cpMax); @@ -1152,7 +1152,7 @@ int GetClosestLanguage(TCHAR *lang_name) // Try searching by the prefix only TCHAR lang[128]; - lstrcpyn(lang, lang_name, MAX_REGS(lang)); + lstrcpyn(lang, lang_name, SIZEOF(lang)); TCHAR *p = _tcschr(lang, _T('_')); if (p != NULL) @@ -1225,7 +1225,7 @@ void GetUserProtoLanguageSetting(Dialog *dlg, HANDLE hContact, char *group, char || lstrcmpi(dict->english_name, lang) == 0 || lstrcmpi(dict->language, lang) == 0) { - lstrcpyn(dlg->lang_name, dict->language, MAX_REGS(dlg->lang_name)); + lstrcpyn(dlg->lang_name, dict->language, SIZEOF(dlg->lang_name)); break; } } @@ -1283,7 +1283,7 @@ void GetContactLanguage(Dialog *dlg) { if (!DBGetContactSettingTString(NULL, MODULE_NAME, dlg->name, &dbv)) { - lstrcpyn(dlg->lang_name, dbv.ptszVal, MAX_REGS(dlg->lang_name)); + lstrcpyn(dlg->lang_name, dbv.ptszVal, SIZEOF(dlg->lang_name)); DBFreeVariant(&dbv); } } @@ -1291,13 +1291,13 @@ void GetContactLanguage(Dialog *dlg) { if (!DBGetContactSettingTString(dlg->hContact, MODULE_NAME, "TalkLanguage", &dbv)) { - lstrcpyn(dlg->lang_name, dbv.ptszVal, MAX_REGS(dlg->lang_name)); + lstrcpyn(dlg->lang_name, dbv.ptszVal, SIZEOF(dlg->lang_name)); DBFreeVariant(&dbv); } if (dlg->lang_name[0] == _T('\0') && !DBGetContactSettingTString(dlg->hContact, "eSpeak", "TalkLanguage", &dbv)) { - lstrcpyn(dlg->lang_name, dbv.ptszVal, MAX_REGS(dlg->lang_name)); + lstrcpyn(dlg->lang_name, dbv.ptszVal, SIZEOF(dlg->lang_name)); DBFreeVariant(&dbv); } @@ -1312,13 +1312,13 @@ void GetContactLanguage(Dialog *dlg) { if (!DBGetContactSettingTString(hMetaContact, MODULE_NAME, "TalkLanguage", &dbv)) { - lstrcpyn(dlg->lang_name, dbv.ptszVal, MAX_REGS(dlg->lang_name)); + lstrcpyn(dlg->lang_name, dbv.ptszVal, SIZEOF(dlg->lang_name)); DBFreeVariant(&dbv); } if (dlg->lang_name[0] == _T('\0') && !DBGetContactSettingTString(hMetaContact, "eSpeak", "TalkLanguage", &dbv)) { - lstrcpyn(dlg->lang_name, dbv.ptszVal, MAX_REGS(dlg->lang_name)); + lstrcpyn(dlg->lang_name, dbv.ptszVal, SIZEOF(dlg->lang_name)); DBFreeVariant(&dbv); } } @@ -1337,14 +1337,14 @@ void GetContactLanguage(Dialog *dlg) // Use default lang if (dlg->lang_name[0] == _T('\0')) - lstrcpyn(dlg->lang_name, opts.default_language, MAX_REGS(dlg->lang_name)); + lstrcpyn(dlg->lang_name, opts.default_language, SIZEOF(dlg->lang_name)); } int i = GetClosestLanguage(dlg->lang_name); if (i < 0) { // Lost a dict? - lstrcpyn(dlg->lang_name, opts.default_language, MAX_REGS(dlg->lang_name)); + lstrcpyn(dlg->lang_name, opts.default_language, SIZEOF(dlg->lang_name)); i = GetClosestLanguage(dlg->lang_name); } @@ -1580,7 +1580,7 @@ TCHAR *GetWordUnderPoint(Dialog *dlg, POINT pt, CHARRANGE &sel) TCHAR text[1024]; int first_char; - if (!GetWordCharRange(dlg, sel, text, MAX_REGS(text), first_char)) + if (!GetWordCharRange(dlg, sel, text, SIZEOF(text), first_char)) return NULL; // copy the word @@ -1689,7 +1689,7 @@ void AddMenuForWord(Dialog *dlg, TCHAR *word, CHARRANGE &pos, HMENU hMenu, BOOL InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); TCHAR text[128]; - mir_sntprintf(text, MAX_REGS(text), TranslateT("Wrong word: %s"), word); + mir_sntprintf(text, SIZEOF(text), TranslateT("Wrong word: %s"), word); InsertMenu(hMenu, 0, MF_BYPOSITION, 0, text); } } @@ -2232,7 +2232,7 @@ BOOL lstreq(TCHAR *a, TCHAR *b, size_t len) BOOL CreatePath(const TCHAR *path) { TCHAR folder[1024]; - lstrcpyn(folder, path, MAX_REGS(folder)); + lstrcpyn(folder, path, SIZEOF(folder)); TCHAR *p = folder; if (p[0] && p[1] && p[1] == _T(':') && p[2] == _T('\\')) p += 3; // skip drive letter |