diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-09 20:03:46 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-09 20:03:46 +0000 |
commit | bcb27264ba737778e5d3edad36088bacf74f0236 (patch) | |
tree | fd1f57744dd380b7babe312a0ab5dc60b48854f2 /plugins/TabSRMM/src/container.cpp | |
parent | 940231dc5a484b03a278900e1880aa083472b601 (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 'plugins/TabSRMM/src/container.cpp')
-rw-r--r-- | plugins/TabSRMM/src/container.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index e5e98c9a44..c37642d345 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -2389,25 +2389,21 @@ void TSAPI DeleteContainer(int iIndex) char *szKey = "TAB_ContainersW";
char *szSettingP = "CNTW_";
char *szSubKey = "containerW";
- HANDLE hhContact;
_snprintf(szIndex, 8, "%d", iIndex);
-
if (!M->GetTString(NULL, szKey, szIndex, &dbv)) {
if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR) {
TCHAR *wszContainerName = dbv.ptszVal;
M->WriteTString(NULL, szKey, szIndex, _T("**free**"));
- hhContact = db_find_first();
- while (hhContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DBVARIANT dbv_c;
- if (!M->GetTString(hhContact, SRMSGMOD_T, szSubKey, &dbv_c)) {
+ if (!M->GetTString(hContact, SRMSGMOD_T, szSubKey, &dbv_c)) {
TCHAR *wszString = dbv_c.ptszVal;
if (_tcscmp(wszString, wszContainerName) && lstrlen(wszString) == lstrlen(wszContainerName))
- db_unset(hhContact, SRMSGMOD_T, "containerW");
+ db_unset(hContact, SRMSGMOD_T, "containerW");
db_free(&dbv_c);
}
- hhContact = db_find_next(hhContact);
}
_snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%d_Flags", szSettingP, iIndex);
db_unset(NULL, SRMSGMOD_T, szSetting);
@@ -2433,27 +2429,24 @@ void TSAPI RenameContainer(int iIndex, const TCHAR *szNew) char *szSettingP = "CNTW_";
char *szSubKey = "containerW";
char szIndex[10];
- HANDLE hhContact;
_snprintf(szIndex, 8, "%d", iIndex);
if (!M->GetTString(NULL, szKey, szIndex, &dbv)) {
- if (szNew != NULL) {
+ if (szNew != NULL)
if (lstrlen(szNew) != 0)
M->WriteTString(NULL, szKey, szIndex, szNew);
- }
- hhContact = db_find_first();
- while (hhContact) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DBVARIANT dbv_c;
- if (!M->GetTString(hhContact, SRMSGMOD_T, szSubKey, &dbv_c)) {
+ if (!M->GetTString(hContact, SRMSGMOD_T, szSubKey, &dbv_c)) {
if (!_tcscmp(dbv.ptszVal, dbv_c.ptszVal) && lstrlen(dbv_c.ptszVal) == lstrlen(dbv.ptszVal)) {
if (szNew != NULL) {
if (lstrlen(szNew) != 0)
- M->WriteTString(hhContact, SRMSGMOD_T, szSubKey, szNew);
+ M->WriteTString(hContact, SRMSGMOD_T, szSubKey, szNew);
}
}
db_free(&dbv_c);
}
- hhContact = db_find_next(hhContact);
}
db_free(&dbv);
}
|