From bcb27264ba737778e5d3edad36088bacf74f0236 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 9 Apr 2013 20:03:46 +0000 Subject: - 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 --- protocols/IRCG/src/clist.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'protocols/IRCG/src/clist.cpp') diff --git a/protocols/IRCG/src/clist.cpp b/protocols/IRCG/src/clist.cpp index d3f4aed5de..a60353a8e5 100644 --- a/protocols/IRCG/src/clist.cpp +++ b/protocols/IRCG/src/clist.cpp @@ -144,9 +144,8 @@ bool CIrcProto::CList_SetAllOffline(BYTE ChatsToo) DisconnectAllDCCSessions(false); - HANDLE hContact = db_find_first(); - while ( hContact ) { - char* szProto = GetContactProto(hContact); + for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + char *szProto = GetContactProto(hContact); if (szProto != NULL && !lstrcmpiA( szProto, m_szModuleName)) { if ( getByte( hContact, "ChatRoom", 0 ) == 0 ) { if ( getByte(hContact, "DCC", 0 ) != 0 ) { @@ -161,9 +160,8 @@ bool CIrcProto::CList_SetAllOffline(BYTE ChatsToo) db_unset( hContact, m_szModuleName, "IP" ); setString( hContact, "User", "" ); setString( hContact, "Host", "" ); - } } - - hContact = db_find_next(hContact); + } + } } return true; } @@ -176,15 +174,14 @@ HANDLE CIrcProto::CList_FindContact (CONTACT* user) TCHAR* lowercasename = mir_tstrdup( user->name ); CharLower(lowercasename); - char *szProto; DBVARIANT dbv1; DBVARIANT dbv2; DBVARIANT dbv3; DBVARIANT dbv4; DBVARIANT dbv5; - HANDLE hContact = db_find_first(); - while (hContact) { - szProto = GetContactProto(hContact); + + for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + char *szProto = GetContactProto(hContact); if ( szProto != NULL && !lstrcmpiA( szProto, m_szModuleName )) { if ( getByte( hContact, "ChatRoom", 0) == 0) { HANDLE hContact_temp = NULL; @@ -238,9 +235,9 @@ HANDLE CIrcProto::CList_FindContact (CONTACT* user) if ( hContact_temp != (HANDLE)-1 ) return hContact_temp; return 0; - } } } - - hContact = db_find_next(hContact); + } + } + } } mir_free(lowercasename); return 0; -- cgit v1.2.3