summaryrefslogtreecommitdiff
path: root/plugins/SpellChecker
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-21 18:40:03 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-21 18:40:14 +0300
commit477a6ea70d0bb1b1dfe9cbd9a15b6dad0284ddeb (patch)
tree247eed13a5231c3983e343f0b7fc2a95012353c2 /plugins/SpellChecker
parent9d0174ebe2bd005418855b18f737c36d5c20ab4a (diff)
all another C++'11 iterators
Diffstat (limited to 'plugins/SpellChecker')
-rw-r--r--plugins/SpellChecker/src/dictionary.cpp12
-rw-r--r--plugins/SpellChecker/src/options.cpp10
-rw-r--r--plugins/SpellChecker/src/spellchecker.cpp6
-rw-r--r--plugins/SpellChecker/src/utils.cpp7
4 files changed, 12 insertions, 23 deletions
diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp
index 03fa58e5fb..98178f0a23 100644
--- a/plugins/SpellChecker/src/dictionary.cpp
+++ b/plugins/SpellChecker/src/dictionary.cpp
@@ -733,8 +733,7 @@ BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString)
wchar_t name[64];
mir_snwprintf(name, L"%s_%s", ini, end);
- for (int i = 0; i < tmp_dicts->getCount(); i++) {
- Dictionary *dict = (*tmp_dicts)[i];
+ for (auto &dict : *tmp_dicts) {
if (mir_wstrcmpi(dict->language, name) == 0) {
GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGLANGUAGE, dict->english_name, _countof(dict->english_name));
@@ -772,9 +771,7 @@ void GetDictsInfo(LIST<Dictionary> &dicts)
EnumSystemLocales(EnumLocalesProc, LCID_SUPPORTED);
// Try to get name from DB
- for (int i = 0; i < dicts.getCount(); i++) {
- Dictionary *dict = dicts[i];
-
+ for (auto &dict : dicts) {
if (dict->full_name[0] == '\0') {
DBVARIANT dbv;
@@ -931,9 +928,8 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, wchar_t *path, wchar_t *use
// Free the list returned by GetAvaibleDictionaries
void FreeDictionaries(LIST<Dictionary> &dicts)
{
- for (int i = 0; i < dicts.getCount(); i++)
- delete dicts[i];
-
+ for (auto &it : dicts)
+ delete it;
dicts.destroy();
}
diff --git a/plugins/SpellChecker/src/options.cpp b/plugins/SpellChecker/src/options.cpp
index 5dd5db0a0d..6f0d0e22e9 100644
--- a/plugins/SpellChecker/src/options.cpp
+++ b/plugins/SpellChecker/src/options.cpp
@@ -98,13 +98,11 @@ void LoadOptions()
db_free(&dbv);
}
- int i;
- for (i = 0; i < languages.getCount(); i++)
- if (mir_wstrcmp(languages[i]->language, opts.default_language) == 0)
- break;
+ for (auto &it : languages)
+ if (mir_wstrcmp(it->language, opts.default_language) == 0)
+ return;
- if (i >= languages.getCount())
- mir_wstrcpy(opts.default_language, languages[0]->language);
+ mir_wstrcpy(opts.default_language, languages[0]->language);
}
static void DrawItem(LPDRAWITEMSTRUCT lpdis, Dictionary *dict)
diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp
index 0640f6f10b..4b495303c1 100644
--- a/plugins/SpellChecker/src/spellchecker.cpp
+++ b/plugins/SpellChecker/src/spellchecker.cpp
@@ -145,7 +145,7 @@ static int ModulesLoaded(WPARAM, LPARAM)
// Get language flags
for (int i = 0; i < languages.getCount(); i++) {
- Dictionary *p = languages[i];
+ auto *p = languages[i];
sid.description.w = p->full_name;
char lang[32];
@@ -179,9 +179,7 @@ static int ModulesLoaded(WPARAM, LPARAM)
FreeLibrary(hFlagsDll);
}
- for (int j = 0; j < languages.getCount(); j++) {
- Dictionary *dict = languages[j];
-
+ for (auto &dict : languages) {
wchar_t filename[MAX_PATH];
mir_snwprintf(filename, L"%s\\%s.ar", customDictionariesFolder, dict->language);
dict->autoReplace = new AutoReplaceMap(filename, dict);
diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp
index 1b88e94621..7dfcd12884 100644
--- a/plugins/SpellChecker/src/utils.cpp
+++ b/plugins/SpellChecker/src/utils.cpp
@@ -728,11 +728,8 @@ void GetUserProtoLanguageSetting(Dialog *dlg, MCONTACT hContact, char *group, ch
if (dbv.type == DBVT_WCHAR && dbv.ptszVal != nullptr) {
wchar_t *lang = dbv.ptszVal;
- for (int i = 0; i < languages.getCount(); i++) {
- Dictionary *dict = languages[i];
- if (mir_wstrcmpi(dict->localized_name, lang) == 0
- || mir_wstrcmpi(dict->english_name, lang) == 0
- || mir_wstrcmpi(dict->language, lang) == 0) {
+ for (auto &dict : languages) {
+ if (mir_wstrcmpi(dict->localized_name, lang) == 0 || mir_wstrcmpi(dict->english_name, lang) == 0 || mir_wstrcmpi(dict->language, lang) == 0) {
mir_wstrncpy(dlg->lang_name, dict->language, _countof(dlg->lang_name));
break;
}