summaryrefslogtreecommitdiff
path: root/plugins/SpellChecker/src/dictionary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SpellChecker/src/dictionary.cpp')
-rw-r--r--plugins/SpellChecker/src/dictionary.cpp80
1 files changed, 40 insertions, 40 deletions
diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp
index 18689e9756..9a7ae1775c 100644
--- a/plugins/SpellChecker/src/dictionary.cpp
+++ b/plugins/SpellChecker/src/dictionary.cpp
@@ -365,7 +365,7 @@ protected:
void loadCustomDict()
{
TCHAR filename[1024];
- mir_sntprintf(filename, SIZEOF(filename), _T("%s\\%s.cdic"), userPath, language);
+ mir_sntprintf(filename, _countof(filename), _T("%s\\%s.cdic"), userPath, language);
FILE *file = _tfopen(filename, _T("rb"));
if (file != NULL) {
@@ -373,7 +373,7 @@ protected:
char c;
int pos = 0;
while ((c = fgetc(file)) != EOF) {
- if (c == '\n' || c == '\r' || pos >= SIZEOF(tmp) - 1) {
+ if (c == '\n' || c == '\r' || pos >= _countof(tmp) - 1) {
if (pos > 0) {
tmp[pos] = '\0';
hunspell->add(tmp);
@@ -395,12 +395,12 @@ protected:
CreateDirectoryTreeT(userPath);
TCHAR filename[1024];
- mir_sntprintf(filename, SIZEOF(filename), _T("%s\\%s.cdic"), userPath, language);
+ mir_sntprintf(filename, _countof(filename), _T("%s\\%s.cdic"), userPath, language);
FILE *file = _tfopen(filename, _T("ab"));
if (file != NULL) {
char tmp[1024];
- toHunspell(tmp, word, SIZEOF(tmp));
+ toHunspell(tmp, word, _countof(tmp));
fprintf(file, "%s\n", tmp);
fclose(file);
}
@@ -412,7 +412,7 @@ protected:
return;
char hunspell_word[1024];
- toHunspell(hunspell_word, word, SIZEOF(hunspell_word));
+ toHunspell(hunspell_word, word, _countof(hunspell_word));
hunspell->add(hunspell_word);
}
@@ -443,13 +443,13 @@ protected:
public:
HunspellDictionary(TCHAR *aLanguage, TCHAR *aFileWithoutExtension, TCHAR *anUserPath, TCHAR *aSource)
{
- mir_tstrncpy(language, aLanguage, SIZEOF(language));
- mir_tstrncpy(fileWithoutExtension, aFileWithoutExtension, SIZEOF(fileWithoutExtension));
- mir_tstrncpy(userPath, anUserPath, SIZEOF(userPath));
+ mir_tstrncpy(language, aLanguage, _countof(language));
+ mir_tstrncpy(fileWithoutExtension, aFileWithoutExtension, _countof(fileWithoutExtension));
+ mir_tstrncpy(userPath, anUserPath, _countof(userPath));
if (aSource == NULL)
source[0] = _T('\0');
else
- mir_tstrncpy(source, aSource, SIZEOF(source));
+ mir_tstrncpy(source, aSource, _countof(source));
loaded = LANGUAGE_NOT_LOADED;
localized_name[0] = _T('\0');
@@ -523,8 +523,8 @@ public:
char aff[1024];
- mir_snprintf(dic, SIZEOF(dic), "%S.dic", fileWithoutExtension);
- mir_snprintf(aff, SIZEOF(aff), "%S.aff", fileWithoutExtension);
+ mir_snprintf(dic, _countof(dic), "%S.dic", fileWithoutExtension);
+ mir_snprintf(aff, _countof(aff), "%S.aff", fileWithoutExtension);
hunspell = new Hunspell(aff, dic);
@@ -542,7 +542,7 @@ public:
}
else {
- for (int i = 0; i < SIZEOF(codepages); i++) {
+ for (int i = 0; i < _countof(codepages); i++) {
if (_strcmpi(codepages[i].name, dic_enc) == 0) {
if (IsValidCodePage(codepages[i].codepage))
codePage = codepages[i].codepage;
@@ -581,7 +581,7 @@ public:
// TODO Check if it was generated by auto-replacement
char hunspell_word[1024];
- toHunspell(hunspell_word, word, SIZEOF(hunspell_word));
+ toHunspell(hunspell_word, word, _countof(hunspell_word));
return hunspell->spell(hunspell_word);
}
@@ -596,7 +596,7 @@ public:
return ret;
char hunspell_word[1024];
- toHunspell(hunspell_word, word, SIZEOF(hunspell_word));
+ toHunspell(hunspell_word, word, _countof(hunspell_word));
char ** words = NULL;
ret.count = hunspell->suggest(&words, hunspell_word);
@@ -625,7 +625,7 @@ public:
return ret;
char hunspell_word[1024];
- toHunspell(hunspell_word, word, SIZEOF(hunspell_word));
+ toHunspell(hunspell_word, word, _countof(hunspell_word));
char ** words;
int count = hunspell->suggest_auto(&words, hunspell_word);
@@ -654,7 +654,7 @@ public:
return NULL;
char hunspell_word[1024];
- toHunspell(hunspell_word, word, SIZEOF(hunspell_word));
+ toHunspell(hunspell_word, word, _countof(hunspell_word));
char ** words;
int count = hunspell->suggest_auto(&words, hunspell_word);
@@ -733,37 +733,37 @@ BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString)
TCHAR ini[32];
TCHAR end[32];
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO639LANGNAME, ini, SIZEOF(ini));
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO3166CTRYNAME, end, SIZEOF(end));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO639LANGNAME, ini, _countof(ini));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO3166CTRYNAME, end, _countof(end));
TCHAR name[64];
- mir_sntprintf(name, SIZEOF(name), _T("%s_%s"), ini, end);
+ mir_sntprintf(name, _countof(name), _T("%s_%s"), ini, end);
for (int i = 0; i < tmp_dicts->getCount(); i++) {
Dictionary *dict = (*tmp_dicts)[i];
if (mir_tstrcmpi(dict->language, name) == 0) {
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGLANGUAGE, dict->english_name, SIZEOF(dict->english_name));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGLANGUAGE, dict->english_name, _countof(dict->english_name));
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLANGUAGE, dict->localized_name, SIZEOF(dict->localized_name));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLANGUAGE, dict->localized_name, _countof(dict->localized_name));
if (dict->localized_name[0] == 0)
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLOCALIZEDLANGUAGENAME, dict->localized_name, SIZEOF(dict->localized_name));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLOCALIZEDLANGUAGENAME, dict->localized_name, _countof(dict->localized_name));
if (dict->localized_name[0] == 0)
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SNATIVEDISPLAYNAME, dict->localized_name, SIZEOF(dict->localized_name));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SNATIVEDISPLAYNAME, dict->localized_name, _countof(dict->localized_name));
if (dict->localized_name[0] == 0 && dict->english_name[0] != 0) {
TCHAR country[1024];
- GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGCOUNTRY, country, SIZEOF(country));
+ GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGCOUNTRY, country, _countof(country));
TCHAR name[1024];
if (country[0] != 0)
- mir_sntprintf(name, SIZEOF(name), _T("%s (%s)"), dict->english_name, country);
+ mir_sntprintf(name, _countof(name), _T("%s (%s)"), dict->english_name, country);
else
- mir_tstrncpy(name, dict->english_name, SIZEOF(name));
+ mir_tstrncpy(name, dict->english_name, _countof(name));
- mir_tstrncpy(dict->localized_name, TranslateTS(name), SIZEOF(dict->localized_name));
+ mir_tstrncpy(dict->localized_name, TranslateTS(name), _countof(dict->localized_name));
}
if (dict->localized_name[0] != 0) {
- mir_sntprintf(dict->full_name, SIZEOF(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language);
+ mir_sntprintf(dict->full_name, _countof(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language);
}
break;
}
@@ -787,24 +787,24 @@ void GetDictsInfo(LIST<Dictionary> &dicts)
char lang[128];
WideCharToMultiByte(CP_ACP, 0, dict->language, -1, lang, sizeof(lang), NULL, NULL);
if (!db_get_ts(NULL, MODULE_NAME, lang, &dbv)) {
- mir_tstrncpy(dict->localized_name, dbv.ptszVal, SIZEOF(dict->localized_name));
+ mir_tstrncpy(dict->localized_name, dbv.ptszVal, _countof(dict->localized_name));
db_free(&dbv);
}
if (dict->localized_name[0] == _T('\0')) {
- for (size_t j = 0; j < SIZEOF(aditionalLanguages); j++) {
+ for (size_t j = 0; j < _countof(aditionalLanguages); j++) {
if (!mir_tstrcmp(aditionalLanguages[j].language, dict->language)) {
- mir_tstrncpy(dict->localized_name, TranslateTS(aditionalLanguages[j].localized_name), SIZEOF(dict->localized_name));
+ mir_tstrncpy(dict->localized_name, TranslateTS(aditionalLanguages[j].localized_name), _countof(dict->localized_name));
break;
}
}
}
if (dict->localized_name[0] != _T('\0')) {
- mir_sntprintf(dict->full_name, SIZEOF(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language);
+ mir_sntprintf(dict->full_name, _countof(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language);
}
else {
- mir_tstrncpy(dict->full_name, dict->language, SIZEOF(dict->full_name));
+ mir_tstrncpy(dict->full_name, dict->language, _countof(dict->full_name));
}
}
}
@@ -815,7 +815,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, SIZEOF(file), _T("%s\\*.dic"), path);
+ mir_sntprintf(file, _countof(file), _T("%s\\*.dic"), path);
BOOL found = FALSE;
@@ -823,7 +823,7 @@ void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, TCHAR *path, TCH
HANDLE hFFD = FindFirstFile(file, &ffd);
if (hFFD != INVALID_HANDLE_VALUE) {
do {
- mir_sntprintf(file, SIZEOF(file), _T("%s\\%s"), path, ffd.cFileName);
+ mir_sntprintf(file, _countof(file), _T("%s\\%s"), path, ffd.cFileName);
// Check .dic
DWORD attrib = GetFileAttributes(file);
@@ -871,14 +871,14 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_pa
if (opts.use_other_apps_dicts) {
// Get other apps dicts
- for (int i = 0; i < SIZEOF(otherHunspellApps); i++) {
+ for (int i = 0; i < _countof(otherHunspellApps); i++) {
TCHAR key[1024];
- mir_sntprintf(key, SIZEOF(key), APPPATH, otherHunspellApps[i].key);
+ mir_sntprintf(key, _countof(key), APPPATH, otherHunspellApps[i].key);
HKEY hKey = 0;
LONG lResult = 0;
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE, &hKey)) {
- DWORD size = SIZEOF(key);
+ DWORD size = _countof(key);
lResult = RegQueryValueEx(hKey, _T("Path"), NULL, NULL, (LPBYTE)key, &size);
RegCloseKey(hKey);
}
@@ -892,7 +892,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 = SIZEOF(key);
+ DWORD cchValue = _countof(key);
if (ERROR_SUCCESS != RegEnumValue(hKey, local, key, &cchValue, NULL, NULL, NULL, NULL))
break;
key[cchValue] = 0;
@@ -911,7 +911,7 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_pa
if (ERROR_SUCCESS == lResult) {
TCHAR folder[1024];
- mir_sntprintf(folder, SIZEOF(folder), _T("%s\\Dictionaries"), key);
+ mir_sntprintf(folder, _countof(folder), _T("%s\\Dictionaries"), key);
GetHunspellDictionariesFromFolder(languages, folder, user_path, otherHunspellApps[i].name);
}