summaryrefslogtreecommitdiff
path: root/src/modules/clist/groups.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-09 20:03:46 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-09 20:03:46 +0000
commitbcb27264ba737778e5d3edad36088bacf74f0236 (patch)
treefd1f57744dd380b7babe312a0ab5dc60b48854f2 /src/modules/clist/groups.cpp
parent940231dc5a484b03a278900e1880aa083472b601 (diff)
- short function names allows to write database loops in one string;
- 'continue' operator can be used then; - multiple bugs fixed in clists; - code becomes much more compact; git-svn-id: http://svn.miranda-ng.org/main/trunk@4403 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/clist/groups.cpp')
-rw-r--r--src/modules/clist/groups.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/modules/clist/groups.cpp b/src/modules/clist/groups.cpp
index eb221ae5c7..c2ac366c54 100644
--- a/src/modules/clist/groups.cpp
+++ b/src/modules/clist/groups.cpp
@@ -184,10 +184,7 @@ static INT_PTR DeleteGroup(WPARAM wParam, LPARAM)
CLISTGROUPCHANGE grpChg = { sizeof(CLISTGROUPCHANGE), NULL, NULL };
- for (hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (db_get_ts(hContact, "CList", "Group", &dbv))
continue;
@@ -256,7 +253,6 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move)
char idstr[33];
TCHAR str[256], oldName[256];
DBVARIANT dbv;
- HANDLE hContact;
if (GroupNameExists(szName, groupId)) {
MessageBox(NULL, TranslateT("You already have a group with that name. Please enter a unique name for the group."), TranslateT("Rename Group"), MB_OK);
@@ -274,16 +270,15 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move)
db_set_ts(NULL, "CListGroups", idstr, str);
//must rename setting in all child contacts too
- hContact = db_find_first();
- do {
- ClcCacheEntry* cache = cli.pfnGetCacheEntry(hContact);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ ClcCacheEntry *cache = cli.pfnGetCacheEntry(hContact);
if ( !lstrcmp(cache->tszGroup, oldName)) {
db_set_ts(hContact, "CList", "Group", szName);
mir_free(cache->tszGroup);
cache->tszGroup = 0;
cli.pfnCheckCacheItem(cache);
}
- } while ((hContact = db_find_next(hContact)) != NULL);
+ }
//rename subgroups
{