From befbbe3b75cf8001b40fc5fa06d66f1d5b9614da Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Wed, 1 Aug 2012 18:12:05 +0000 Subject: SpellChecker: code cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@1309 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SpellChecker/src/dictionary.cpp | 80 ++++++++++++++++----------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'plugins/SpellChecker/src/dictionary.cpp') 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 &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 &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 &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 &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 &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 &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 &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]); } -- cgit v1.2.3