From 12053939f5b0c757a2b099e90fc0b7371e8817e1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 30 Jun 2012 17:02:05 +0000 Subject: code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@700 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/chat/tools.cpp | 2 +- plugins/Variables/contact.cpp | 54 +++--- plugins/Variables/enumprocs.cpp | 4 +- plugins/Variables/help.cpp | 48 ++--- plugins/Variables/options.cpp | 8 +- plugins/Variables/parse_alias.cpp | 16 +- plugins/Variables/parse_external.cpp | 8 +- plugins/Variables/parse_inet.cpp | 4 +- plugins/Variables/parse_logic.cpp | 14 +- plugins/Variables/parse_metacontacts.cpp | 28 +-- plugins/Variables/parse_miranda.cpp | 315 +++++++++++-------------------- plugins/Variables/parse_str.cpp | 46 ++--- plugins/Variables/parse_system.cpp | 30 +-- plugins/Variables/parse_variables.cpp | 8 +- plugins/Variables/tokenregister.cpp | 76 ++++---- plugins/Variables/variables.cpp | 28 +-- plugins/helpers/gen_helpers.cpp | 8 +- 17 files changed, 302 insertions(+), 395 deletions(-) (limited to 'plugins') diff --git a/plugins/TabSRMM/chat/tools.cpp b/plugins/TabSRMM/chat/tools.cpp index ed66bed5da..f9b0bb786c 100644 --- a/plugins/TabSRMM/chat/tools.cpp +++ b/plugins/TabSRMM/chat/tools.cpp @@ -536,7 +536,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO* si, GCEVENT * gce, BOOL bHighligh if (gce == 0 || si == 0 || gce->bIsMe || si->iType == GCW_SERVER) return FALSE; - params = (FLASH_PARAMS*)mir_calloc(1, sizeof(FLASH_PARAMS)); + params = (FLASH_PARAMS*)calloc(1, sizeof(FLASH_PARAMS)); params->hContact = si->hContact; params->bInactive = TRUE; if (si->hWnd && si->dat) { diff --git a/plugins/Variables/contact.cpp b/plugins/Variables/contact.cpp index d2de7c5ace..65c53859fc 100644 --- a/plugins/Variables/contact.cpp +++ b/plugins/Variables/contact.cpp @@ -96,11 +96,11 @@ BYTE getContactInfoType(TCHAR* type) { int i; - if ( type == NULL || _tcslen(type) == 0 ) + if (type == NULL || _tcslen(type) == 0 ) return 0; for ( i=0; i < SIZEOF(builtinCnfs); i++ ) - if ( !_tcscmp( builtinCnfs[i].str, type )) + if (!_tcscmp( builtinCnfs[i].str, type )) return builtinCnfs[i].cnfCode; return 0; @@ -130,18 +130,18 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact) if (szProto == NULL) return NULL; - if ( type & CNF_UNICODE ) + if (type & CNF_UNICODE ) return (TCHAR *)mir_a2t(szProto); return (TCHAR *)mir_strdup(szProto); case CCNF_ACCOUNT: - if ( g_mirandaVersion < PLUGIN_MAKE_VERSION( 0,8,0,0 )) + if (g_mirandaVersion < PLUGIN_MAKE_VERSION( 0,8,0,0 )) return NULL; szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); if (szProto) { PROTOACCOUNT* pa = ProtoGetAccount( szProto ); - if ( pa ) + if (pa ) return mir_tstrdup( pa->tszAccountName ); } return NULL; @@ -154,7 +154,7 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact) if (CallProtoService(szProto, PS_GETNAME, (WPARAM)sizeof(protoname), (LPARAM)protoname)) return NULL; - if ( type & CNF_UNICODE ) + if (type & CNF_UNICODE ) return (TCHAR *)mir_a2t(protoname); return (TCHAR *)mir_strdup(protoname); @@ -196,17 +196,17 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact) struct in_addr in; in.s_addr = htonl(ip); char* dotted = inet_ntoa(in); - if ( dotted == NULL ) + if (dotted == NULL) return NULL; - if ( type & CNF_UNICODE ) + if (type & CNF_UNICODE ) return (TCHAR *)mir_a2t(dotted); return (TCHAR *)mir_strdup(dotted); } case CCNF_GROUP: if (!DBGetContactSetting(hContact, "CList", "Group", &dbv)) { - if ( type & CNF_UNICODE ) + if (type & CNF_UNICODE ) res = (TCHAR *)mir_a2t(dbv.pszVal); else res = (TCHAR *)mir_strdup(dbv.pszVal); @@ -215,7 +215,7 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact) return res; } if (!DBGetContactSettingW(hContact, "CList", "Group", &dbv)) { - if ( type & CNF_UNICODE ) + if (type & CNF_UNICODE ) res = (TCHAR *)mir_wstrdup(dbv.pwszVal); else res = (TCHAR *)mir_u2a(dbv.pwszVal); @@ -228,10 +228,10 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact) case CNF_UNIQUEID: //UID for ChatRoom szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if ( szProto != NULL ) { - if ( DBGetContactSettingByte(hContact, szProto, "ChatRoom", 0) == 1) { + if (szProto != NULL) { + if (DBGetContactSettingByte(hContact, szProto, "ChatRoom", 0) == 1) { DBVARIANT dbv; - if ( !DBGetContactSettingTString(hContact, szProto, "ChatRoomID", &dbv )) { + if (!DBGetContactSettingTString(hContact, szProto, "ChatRoomID", &dbv )) { res = mir_tstrdup( dbv.ptszVal ); DBFreeVariant( &dbv ); return res; @@ -246,12 +246,12 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact) ci.hContact = hContact; ci.dwFlag = type; if (CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci)) { - if ( !( type & CNF_UNICODE )) + if (!( type & CNF_UNICODE )) return NULL; // retrieving the data using UNICODE failed, try without ci.dwFlag &= ~CNF_UNICODE; - if ( CallService( MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci )) + if (CallService( MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci )) return NULL; if (ci.type == CNFT_ASCIIZ) { @@ -275,7 +275,7 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact) return itot(ci.bVal); szVal[0] = (char)ci.bVal; - if ( type & CNF_UNICODE ) + if (type & CNF_UNICODE ) return (TCHAR *)mir_a2t(szVal); return (TCHAR *)mir_strdup(szVal); @@ -338,7 +338,7 @@ int getContactFromString( CONTACTSINFO* ci ) mir_free(tmp); } - if ( (tszContact == NULL) || (_tcslen(tszContact) == 0)) + if ((tszContact == NULL) || (_tcslen(tszContact) == 0)) return -1; ci->hContacts = NULL; @@ -346,7 +346,7 @@ int getContactFromString( CONTACTSINFO* ci ) /* search the cache */ EnterCriticalSection(&csContactCache); for (i=0;iflags == cce[i].flags)) { + if ((!_tcscmp(cce[i].tszContact, tszContact)) && (ci->flags == cce[i].flags)) { /* found in cache */ ci->hContacts = ( HANDLE* )mir_alloc(sizeof(HANDLE)); if (ci->hContacts == NULL) { @@ -400,7 +400,7 @@ int getContactFromString( CONTACTSINFO* ci ) { tszProto = mir_a2t(szProto); - if ( (tszProto != NULL) && (szFind != NULL)) + if ((tszProto != NULL) && (szFind != NULL)) { wsprintf(szFind, _T("<%s:%s>"), tszProto, cInfo); mir_free(cInfo); @@ -414,7 +414,7 @@ int getContactFromString( CONTACTSINFO* ci ) } } // id (exact) - if ( (ci->flags&CI_UNIQUEID) && (!bMatch)) { + if ((ci->flags&CI_UNIQUEID) && (!bMatch)) { szFind = getContactInfoT(CNF_UNIQUEID, hContact, ci->flags&CI_TCHAR); if (szFind != NULL) { if (!_tcscmp(tszContact, szFind)) @@ -424,7 +424,7 @@ int getContactFromString( CONTACTSINFO* ci ) } } // nick (not exact) - if ( (ci->flags&CI_NICK) && (!bMatch)) { + if ((ci->flags&CI_NICK) && (!bMatch)) { szFind = getContactInfoT(CNF_NICK, hContact, ci->flags&CI_TCHAR); if (szFind != NULL) { if (!_tcscmp(tszContact, szFind)) @@ -434,7 +434,7 @@ int getContactFromString( CONTACTSINFO* ci ) } } // list name (not exact) - if ( (ci->flags&CI_LISTNAME) && (!bMatch)) { + if ((ci->flags&CI_LISTNAME) && (!bMatch)) { szFind = getContactInfoT(CNF_DISPLAY, hContact, ci->flags&CI_TCHAR); if (szFind != NULL) { if (!_tcscmp(tszContact, szFind)) @@ -444,7 +444,7 @@ int getContactFromString( CONTACTSINFO* ci ) } } // firstname (exact) - if ( (ci->flags&CI_FIRSTNAME) && (!bMatch)) { + if ((ci->flags&CI_FIRSTNAME) && (!bMatch)) { szFind = getContactInfoT(CNF_FIRSTNAME, hContact, ci->flags&CI_TCHAR); if (szFind != NULL) { if (!_tcscmp(tszContact, szFind)) { @@ -454,7 +454,7 @@ int getContactFromString( CONTACTSINFO* ci ) } } // lastname (exact) - if ( (ci->flags&CI_LASTNAME) && (!bMatch)) { + if ((ci->flags&CI_LASTNAME) && (!bMatch)) { szFind = getContactInfoT(CNF_LASTNAME, hContact, ci->flags&CI_TCHAR); if (szFind != NULL) { if (!_tcscmp(tszContact, szFind)) { @@ -464,7 +464,7 @@ int getContactFromString( CONTACTSINFO* ci ) } } // email (exact) - if ( (ci->flags&CI_EMAIL) && (!bMatch)) { + if ((ci->flags&CI_EMAIL) && (!bMatch)) { szFind = getContactInfoT(CNF_EMAIL, hContact, ci->flags&CI_TCHAR); if (szFind != NULL) { if (!_tcscmp(tszContact, szFind)) { @@ -474,7 +474,7 @@ int getContactFromString( CONTACTSINFO* ci ) } } // CNF_ (exact) - if ( (ci->flags&CI_CNFINFO) && (!bMatch)) { + if ((ci->flags&CI_CNFINFO) && (!bMatch)) { szFind = getContactInfoT((BYTE)(ci->flags&~(CI_CNFINFO|CI_TCHAR)), hContact, ci->flags&CI_TCHAR); if (szFind != NULL) { if (!_tcscmp(tszContact, szFind)) { @@ -593,7 +593,7 @@ TCHAR *encodeContactToString(HANDLE hContact) ZeroMemory(&dbv, sizeof(DBVARIANT)); szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); tszUniqueId = getContactInfoT(CNF_UNIQUEID, hContact, CI_TCHAR); - if ( szProto == NULL || tszUniqueId == NULL ) + if (szProto == NULL || tszUniqueId == NULL) return NULL; tszResult = ( TCHAR* )mir_alloc((_tcslen(tszUniqueId) + strlen(szProto) + 4) * sizeof(TCHAR)); diff --git a/plugins/Variables/enumprocs.cpp b/plugins/Variables/enumprocs.cpp index 5b4bb7922b..74462a8661 100644 --- a/plugins/Variables/enumprocs.cpp +++ b/plugins/Variables/enumprocs.cpp @@ -192,7 +192,7 @@ BOOL WINAPI EnumProcs(PROCENUMPROC lpProc, LPARAM lParam) { break; // Did we just bump into an NTVDM? - if (_stricmp(szFileName, "NTVDM.EXE") == 0) { + if ( _stricmp(szFileName, "NTVDM.EXE") == 0) { // Fill in some info for the 16-bit enum proc. sInfo.dwPID = lpdwPIDs[dwIndex]; @@ -288,7 +288,7 @@ BOOL WINAPI EnumProcs(PROCENUMPROC lpProc, LPARAM lParam) { (char *)procentry.szExeFile, lParam)) { // Did we just bump into an NTVDM? - if (_stricmp((char *)procentry.szExeFile, "NTVDM.EXE") == 0) { + if ( _stricmp((char *)procentry.szExeFile, "NTVDM.EXE") == 0) { // Fill in some info for the 16-bit enum proc. sInfo.dwPID = procentry.th32ProcessID; diff --git a/plugins/Variables/help.cpp b/plugins/Variables/help.cpp index be9e377c28..348384297a 100644 --- a/plugins/Variables/help.cpp +++ b/plugins/Variables/help.cpp @@ -78,7 +78,7 @@ static INT_PTR CALLBACK extratextDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPA return TRUE; case WM_SIZE: - if ( !IsIconic( hwndDlg )) { + if (!IsIconic( hwndDlg )) { UTILRESIZEDIALOG urd = { 0 }; urd.cbSize = sizeof(urd); urd.hInstance = hInst; @@ -163,7 +163,7 @@ static INT_PTR CALLBACK clistDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM mir_free(tszContact); } } - if ( (hContact != INVALID_HANDLE_VALUE) && (hContact != NULL)) + if ((hContact != INVALID_HANDLE_VALUE) && (hContact != NULL)) hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); else hItem = NULL; @@ -184,7 +184,7 @@ static INT_PTR CALLBACK clistDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM return TRUE; case WM_SIZE: - if ( !IsIconic( hwndDlg )) { + if (!IsIconic( hwndDlg )) { UTILRESIZEDIALOG urd = { 0 }; urd.cbSize = sizeof(urd); urd.hInstance = hInst; @@ -373,12 +373,12 @@ static int CALLBACK compareTokenHelp(LPARAM lParam1, LPARAM lParam2, LPARAM lPar res = 0; tr1 = (TOKENREGISTEREX *)lParam1; tr2 = (TOKENREGISTEREX *)lParam2; - if ( tr1 == NULL || tr2 == NULL ) + if (tr1 == NULL || tr2 == NULL) return 0; cat1 = getTokenCategory(tr1); cat2 = getTokenCategory(tr2); - if ( cat1 != NULL && cat2 != NULL ) { + if (cat1 != NULL && cat2 != NULL) { res = _tcscmp(cat1, cat2); mir_free(cat1); mir_free(cat2); @@ -386,7 +386,7 @@ static int CALLBACK compareTokenHelp(LPARAM lParam1, LPARAM lParam2, LPARAM lPar if (res != 0) return res; - if ( tr1->tszTokenString == NULL || tr2->tszTokenString == NULL ) + if (tr1->tszTokenString == NULL || tr2->tszTokenString == NULL) return 0; return _tcscmp(tr1->tszTokenString, tr2->tszTokenString); @@ -429,7 +429,7 @@ static BOOL CALLBACK processTokenListMessage(HWND hwndDlg,UINT msg,WPARAM wParam i += 1; tszHelpDesc = tszTokenDesc = NULL; tr = getTokenRegister(i); - if ( (tr == NULL) || (tr->tszTokenString == NULL)) { + if ((tr == NULL) || (tr->tszTokenString == NULL)) { continue; } else if (hdd != NULL) { @@ -498,7 +498,7 @@ static BOOL CALLBACK processTokenListMessage(HWND hwndDlg,UINT msg,WPARAM wParam else { text = NULL; } - if ( (text != NULL) && ((last == NULL) || (_tcsicmp(last, text)))) { + if ((text != NULL) && ((last == NULL) || (_tcsicmp(last, text)))) { lvItem.mask = LVIF_TEXT; lvItem.pszText = text; ListView_InsertItem(hList, &lvItem); @@ -521,7 +521,7 @@ static BOOL CALLBACK processTokenListMessage(HWND hwndDlg,UINT msg,WPARAM wParam } case WM_NOTIFY: - if ( (((NMHDR*)lParam)->idFrom == IDC_TOKENLIST) && (((NMHDR*)lParam)->code == NM_DBLCLK)) { + if ((((NMHDR*)lParam)->idFrom == IDC_TOKENLIST) && (((NMHDR*)lParam)->code == NM_DBLCLK)) { HWND hList, hwndInputDlg; LVITEM lvItem; int len, item; @@ -575,7 +575,7 @@ static INT_PTR CALLBACK tokenHelpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPA break; case WM_SIZE: - if ( !IsIconic( hwndDlg )) { + if (!IsIconic( hwndDlg )) { UTILRESIZEDIALOG urd = { 0 }; urd.cbSize = sizeof(urd); urd.hInstance = hInst; @@ -723,7 +723,7 @@ static INT_PTR CALLBACK inputDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM dat->splitterPos = rc.bottom - pt.y + 223; GetWindowRect(GetDlgItem(hwndDlg, IDC_TESTSTRING), &rcTeststring); GetWindowRect(GetDlgItem(hwndDlg, IDC_RESULT), &rcResult); - if ( (((rcTeststring.bottom - rcTeststring.top) - (dat->splitterPos - oldSplitterY)) < dat->minInputSize.y) || (((rcResult.bottom - rcResult.top) + (dat->splitterPos - oldSplitterY)) < dat->minResultSize.y)) + if ((((rcTeststring.bottom - rcTeststring.top) - (dat->splitterPos - oldSplitterY)) < dat->minInputSize.y) || (((rcResult.bottom - rcResult.top) + (dat->splitterPos - oldSplitterY)) < dat->minResultSize.y)) dat->splitterPos = oldSplitterY; } } @@ -749,7 +749,7 @@ static INT_PTR CALLBACK inputDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM break; case WM_SIZE: - if ( !IsIconic( hwndDlg )) { + if (!IsIconic( hwndDlg )) { UTILRESIZEDIALOG urd = { 0 }; urd.cbSize = sizeof(urd); urd.hInstance = hInst; @@ -784,7 +784,7 @@ static INT_PTR CALLBACK inputDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM TCHAR *newString = variables_parsedup(string, extraText, (HANDLE)SendMessage(GetParent(hwndDlg), VARM_GETSUBJECT, 0, 0)); if (newString != NULL) { TCHAR *oldString = Hlp_GetDlgItemText(hwndDlg, IDC_RESULT); - if ( oldString == NULL || _tcscmp(oldString, newString)) + if (oldString == NULL || _tcscmp(oldString, newString)) SetWindowText(GetDlgItem(hwndDlg, IDC_RESULT), newString); mir_free(newString); @@ -859,7 +859,7 @@ For example: ?contact(miranda@hotmail.com,email) or ?contact(Miranda,nick). The break; case WM_SIZE: - if ( !IsIconic( hwndDlg )) { + if (!IsIconic( hwndDlg )) { UTILRESIZEDIALOG urd = { 0 }; urd.cbSize = sizeof(urd); urd.hInstance = hInst; @@ -940,7 +940,7 @@ static BOOL CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPar ShowWindow(hPage, SW_HIDE); TabCtrl_InsertItem(hTab, tabCount++, &tci); hShow = hShow==0?hPage:hShow; - if ( (dat->vhs->fi != NULL) && (dat->vhs->fi->szFormat != NULL)) { + if ((dat->vhs->fi != NULL) && (dat->vhs->fi->szFormat != NULL)) { if (dat->vhs->fi->flags & FIF_UNICODE) SendMessage(hwndDlg, VARM_SETINPUTTEXT, 0, (LPARAM)dat->vhs->fi->tszFormat); else { @@ -955,17 +955,17 @@ static BOOL CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPar TCHAR *tszText; tszText = Hlp_GetWindowText(dat->vhs->hwndCtrl); - if ( tszText != NULL ) { + if (tszText != NULL) { SendMessage(hwndDlg, VARM_SETINPUTTEXT, 0, (LPARAM)tszText); mir_free(tszText); } } - if ( dat->vhs->fi != NULL || dat->vhs->hwndCtrl != NULL ) { + if (dat->vhs->fi != NULL || dat->vhs->hwndCtrl != NULL) { SetWindowText(GetDlgItem(hwndDlg, IDC_CANCEL), TranslateT("Cancel")); ShowWindow(GetDlgItem(hwndDlg, IDC_OK), SW_SHOW); } } - if ( (dat->vhs->flags&VHF_SUBJECT) || + if ((dat->vhs->flags&VHF_SUBJECT) || ((dat->vhs->flags&VHF_INPUT) && (((dat->vhs->fi != NULL) && (dat->vhs->fi->hContact != NULL)) || (dat->vhs->flags&VHF_SETLASTSUBJECT)))) { // subject window is created, but not necessarily shown dat->hwndSubjectDlg = hPage = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CLIST_DIALOG), hwndDlg, clistDlgProc, (LPARAM)GetParent(hwndDlg)); @@ -990,7 +990,7 @@ static BOOL CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPar hShow = hShow==0?hPage:hShow; } } - if ( (dat->vhs->flags&VHF_EXTRATEXT) || + if ((dat->vhs->flags&VHF_EXTRATEXT) || ((dat->vhs->flags&VHF_INPUT) && (dat->vhs->fi != NULL) && (dat->vhs->fi->tszExtraText != NULL))) { // extratext window is created, but not necessarily shown dat->hwndExtraTextDlg = hPage = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EXTRATEXT_DIALOG), hwndDlg, extratextDlgProc, (LPARAM)GetParent(hwndDlg)); @@ -999,7 +999,7 @@ static BOOL CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPar MoveWindow(hPage, (rcTabs.left - rcParent.left), (rcTabs.top - rcParent.top), (rcTabs.right - rcTabs.left) - 2*iFrameX, (rcTabs.bottom - rcTabs.top) - 2*iFrameY, TRUE); ShowWindow(hPage, SW_HIDE); - if ( (dat->vhs->fi != NULL) && (dat->vhs->fi->tszExtraText != NULL)) { + if ((dat->vhs->fi != NULL) && (dat->vhs->fi->tszExtraText != NULL)) { if (dat->vhs->fi->flags & FIF_UNICODE) SendMessage(hwndDlg, VARM_SETEXTRATEXT, 0, (LPARAM)dat->vhs->fi->tszExtraText); else { @@ -1042,7 +1042,7 @@ static BOOL CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPar case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_OK: - if ( (dat->vhs->fi != NULL) && (!(dat->vhs->flags&VHF_DONTFILLSTRUCT))) { + if ((dat->vhs->fi != NULL) && (!(dat->vhs->flags&VHF_DONTFILLSTRUCT))) { int len = SendMessage(hwndDlg, VARM_GETINPUTTEXTLENGTH, 0, 0); if (len > 0) { @@ -1081,7 +1081,7 @@ static BOOL CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPar (LPARAM)dat->vhs->hwndCtrl); } - if ( (dat->vhs->flags&VHF_FULLFILLSTRUCT) && (dat->vhs->fi != NULL)) { + if ((dat->vhs->flags&VHF_FULLFILLSTRUCT) && (dat->vhs->fi != NULL)) { int len; len = SendMessage(hwndDlg, VARM_GETEXTRATEXTLENGTH, 0, 0); @@ -1217,7 +1217,7 @@ static BOOL CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPar } case WM_NOTIFY: - if ( (((NMHDR*)lParam)->idFrom == IDC_TABS)) { + if ((((NMHDR*)lParam)->idFrom == IDC_TABS)) { if (((NMHDR*)lParam)->code == TCN_SELCHANGING) { TCITEM tci; @@ -1252,7 +1252,7 @@ static BOOL CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPar int count = TabCtrl_GetItemCount(hTab); for ( int i=0; i < count; i++ ) { TabCtrl_GetItem(hTab, i, &tci); - if ( ((HWND)tci.lParam != dat->hwndSubjectDlg) && ((HWND)tci.lParam != dat->hwndExtraTextDlg)) + if (((HWND)tci.lParam != dat->hwndSubjectDlg) && ((HWND)tci.lParam != dat->hwndExtraTextDlg)) DestroyWindow((HWND)tci.lParam); } } diff --git a/plugins/Variables/options.cpp b/plugins/Variables/options.cpp index 22743d0ab5..3ccbbd987f 100644 --- a/plugins/Variables/options.cpp +++ b/plugins/Variables/options.cpp @@ -29,7 +29,7 @@ static INT_PTR CALLBACK SetOptsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARA TranslateDialogDefault(hwndDlg); { DBVARIANT dbv; - if ( !DBGetContactSettingTString( NULL, MODULENAME, SETTING_STARTUPTEXT, &dbv )) { + if (!DBGetContactSettingTString( NULL, MODULENAME, SETTING_STARTUPTEXT, &dbv )) { SetDlgItemText(hwndDlg, IDC_FORMATTEXT, dbv.ptszVal); DBFreeVariant(&dbv); } @@ -44,7 +44,7 @@ static INT_PTR CALLBACK SetOptsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARA break; case WM_COMMAND: - if ( (HIWORD(wParam) == EN_CHANGE) || (HIWORD(wParam) == BN_CLICKED)) { + if ((HIWORD(wParam) == EN_CHANGE) || (HIWORD(wParam) == BN_CLICKED)) { switch (LOWORD(wParam)) { case IDC_PARSEATSTARTUP: case IDC_STRIPCRLF: @@ -57,7 +57,7 @@ static INT_PTR CALLBACK SetOptsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARA gParseOpts.bStripAll = IsDlgButtonChecked(hwndDlg, IDC_STRIPALL); break; } - if ( LOWORD(wParam) == IDC_FORMATTEXT && IsDlgButtonChecked( hwndDlg, IDC_AUTOPARSE )) + if (LOWORD(wParam) == IDC_FORMATTEXT && IsDlgButtonChecked( hwndDlg, IDC_AUTOPARSE )) SendMessage(hwndDlg, VARM_PARSE, 0, 0); } switch (LOWORD(wParam)) { @@ -67,7 +67,7 @@ static INT_PTR CALLBACK SetOptsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARA case IDC_AUTOPARSE: SendMessage(hwndDlg, VARM_PARSE, 0, 0); - if ( IsDlgButtonChecked( hwndDlg, IDC_AUTOPARSE )) + if (IsDlgButtonChecked( hwndDlg, IDC_AUTOPARSE )) SetTimer(hwndDlg, IDT_PARSE, 1000, NULL); else KillTimer(hwndDlg, IDT_PARSE); diff --git a/plugins/Variables/parse_alias.cpp b/plugins/Variables/parse_alias.cpp index cdcef9ff17..1ab708b42d 100644 --- a/plugins/Variables/parse_alias.cpp +++ b/plugins/Variables/parse_alias.cpp @@ -29,7 +29,7 @@ static ALIASREGISTER *searchAliasRegister(TCHAR *szAlias) { unsigned int i; res = NULL; - if ( (szAlias == NULL) || (_tcslen(szAlias) == 0)) { + if ((szAlias == NULL) || (_tcslen(szAlias) == 0)) { return NULL; } EnterCriticalSection(&csAliasRegister); @@ -50,18 +50,18 @@ static TCHAR *replaceArguments(TCHAR *res, TCHAR *tArg, TCHAR *rArg) { unsigned int cur, ecur; - if (_tcslen(tArg) == 0) + if ( _tcslen(tArg) == 0) return res; cur = ecur = 0; while (*(res+cur) != _T('\0')) { - if ( (*(res+cur) == _T('(')) || (*(res+cur) == _T(','))) { + if ((*(res+cur) == _T('(')) || (*(res+cur) == _T(','))) { ecur = ++cur; while ( (*(res+ecur) != _T(')')) && (*(res+ecur) != _T(','))) { ecur++; } - if ( ((signed int)_tcslen(tArg) == (ecur-cur)) && (!_tcsncmp(tArg, res+cur, _tcslen(tArg)))) { - if (_tcslen(rArg) > _tcslen(tArg)) { + if (((signed int)_tcslen(tArg) == (ecur-cur)) && (!_tcsncmp(tArg, res+cur, _tcslen(tArg)))) { + if ( _tcslen(rArg) > _tcslen(tArg)) { res = ( TCHAR* )mir_realloc(res, (_tcslen(res) + (_tcslen(rArg)-_tcslen(tArg)) + 1)*sizeof(TCHAR)); if (res == NULL) return NULL; @@ -83,7 +83,7 @@ static TCHAR *parseTranslateAlias(ARGUMENTSINFO *ai) { ALIASREGISTER *areg; areg = searchAliasRegister(ai->targv[0]); - if ( (areg == NULL) || (areg->argc != ai->argc-1)) { + if ((areg == NULL) || (areg->argc != ai->argc-1)) { return NULL; } res = mir_tstrdup(areg->szTranslation); @@ -101,7 +101,7 @@ static int addToAliasRegister(TCHAR *szAlias, unsigned int argc, TCHAR** argv, T unsigned int i, j; - if ( szAlias == NULL || szTranslation == NULL || _tcslen(szAlias) == 0 ) + if (szAlias == NULL || szTranslation == NULL || _tcslen(szAlias) == 0 ) return -1; EnterCriticalSection(&csAliasRegister); @@ -188,7 +188,7 @@ static TCHAR *parseAddAlias(ARGUMENTSINFO *ai) { if (i != argc-1) _tcscat(szArgs, _T(",")); } - if ( (szArgs != NULL) && (argc > 0)) { + if ((szArgs != NULL) && (argc > 0)) { szArgsA = mir_t2a(szArgs); diff --git a/plugins/Variables/parse_external.cpp b/plugins/Variables/parse_external.cpp index fa3f25ff87..6a0d0dd846 100644 --- a/plugins/Variables/parse_external.cpp +++ b/plugins/Variables/parse_external.cpp @@ -73,7 +73,7 @@ static TCHAR *parseWinampSong(ARGUMENTSINFO *ai) { } scur = _tcschr(szTitle, _T('.')); cur = _tcsstr(scur, _T(" - Winamp")); - if ( (scur == NULL) || (cur == NULL) || (scur >= cur) || (scur > (szTitle + _tcslen(szTitle) - 2)) || (cur > (szTitle + _tcslen(szTitle)))) { + if ((scur == NULL) || (cur == NULL) || (scur >= cur) || (scur > (szTitle + _tcslen(szTitle) - 2)) || (cur > (szTitle + _tcslen(szTitle)))) { mir_free(szTitle); return NULL; } @@ -101,15 +101,15 @@ static TCHAR *parseWinampState(ARGUMENTSINFO *ai) { } scur = _tcschr(szTitle, _T('.')); cur = _tcsstr(scur, _T(" - Winamp")); - if ( (scur == NULL) || (cur == NULL)) { + if ((scur == NULL) || (cur == NULL)) { mir_free(szTitle); return mir_tstrdup(TranslateT("Stopped")); } - if ( (!_tcsncmp(cur+10, _T("[Stopped]"), 9))) { + if ((!_tcsncmp(cur+10, _T("[Stopped]"), 9))) { mir_free(szTitle); return mir_tstrdup(TranslateT("Stopped")); } - if ( (!_tcsncmp(cur+10, _T("[Paused]"), 8))) { + if ((!_tcsncmp(cur+10, _T("[Paused]"), 8))) { mir_free(szTitle); return mir_tstrdup(TranslateT("Paused")); } diff --git a/plugins/Variables/parse_inet.cpp b/plugins/Variables/parse_inet.cpp index 12db607b99..4eabed3ccc 100644 --- a/plugins/Variables/parse_inet.cpp +++ b/plugins/Variables/parse_inet.cpp @@ -37,7 +37,7 @@ static TCHAR *parseUrlEnc(ARGUMENTSINFO *ai) { } cur = 0; while (cur < strlen(res)) { - if ( ( (*(res+cur) >= '0') && (*(res+cur) <= '9')) || ( (*(res+cur) >= 'a') && (*(res+cur) <= 'z')) || ( (*(res+cur) >= 'A') && (*(res+cur) <= 'Z')) ) { + if (( (*(res+cur) >= '0') && (*(res+cur) <= '9')) || ( (*(res+cur) >= 'a') && (*(res+cur) <= 'z')) || ( (*(res+cur) >= 'A') && (*(res+cur) <= 'Z')) ) { cur++; continue; } @@ -75,7 +75,7 @@ static TCHAR *parseUrlDec(ARGUMENTSINFO *ai) { } cur = 0; while (cur < strlen(res)) { - if ( (*(res+cur) == '%') && (strlen(res+cur) >= 3)) { + if ((*(res+cur) == '%') && (strlen(res+cur) >= 3)) { memset(hex, '\0', sizeof(hex)); strncpy(hex, res+cur+1, 2); *(res+cur) = (char)strtol(hex, NULL, 16); diff --git a/plugins/Variables/parse_logic.cpp b/plugins/Variables/parse_logic.cpp index 178439a338..a9abcaa227 100644 --- a/plugins/Variables/parse_logic.cpp +++ b/plugins/Variables/parse_logic.cpp @@ -141,7 +141,7 @@ static TCHAR *parseIfequal(ARGUMENTSINFO *ai) tszFirst = formatString(&fi); fi.szFormat = ai->argv[2]; tszSecond = formatString(&fi); - if ( (tszFirst == NULL) || (tszSecond == NULL)) { + if ((tszFirst == NULL) || (tszSecond == NULL)) { if (tszFirst != NULL) mir_free(tszFirst); @@ -150,7 +150,7 @@ static TCHAR *parseIfequal(ARGUMENTSINFO *ai) return NULL; } - if ( (ttoi(tszFirst)) == (ttoi(tszSecond))) { + if ((ttoi(tszFirst)) == (ttoi(tszSecond))) { mir_free(tszFirst); mir_free(tszSecond); return mir_tstrdup(ai->targv[3]); @@ -176,7 +176,7 @@ static TCHAR *parseIfgreater(ARGUMENTSINFO *ai) { tszFirst = formatString(&fi); fi.szFormat = ai->argv[2]; tszSecond = formatString(&fi); - if ( (tszFirst == NULL) || (tszSecond == NULL)) { + if ((tszFirst == NULL) || (tszSecond == NULL)) { if (tszFirst != NULL) { mir_free(tszFirst); } @@ -185,7 +185,7 @@ static TCHAR *parseIfgreater(ARGUMENTSINFO *ai) { } return NULL; } - if ( (ttoi(tszFirst)) > (ttoi(tszSecond))) { + if ((ttoi(tszFirst)) > (ttoi(tszSecond))) { mir_free(tszFirst); mir_free(tszSecond); return mir_tstrdup(ai->targv[3]); @@ -210,7 +210,7 @@ static TCHAR *parseIflonger(ARGUMENTSINFO *ai) { tszFirst = formatString(&fi); fi.szFormat = ai->argv[2]; tszSecond = formatString(&fi); - if ( (tszFirst == NULL) || (tszSecond == NULL)) { + if ((tszFirst == NULL) || (tszSecond == NULL)) { if (tszFirst != NULL) { mir_free(tszFirst); } @@ -280,7 +280,7 @@ static TCHAR *parseEqual(ARGUMENTSINFO *ai) if (ai->argc != 3) return NULL; - if ( ttoi(ai->targv[1]) != ttoi( ai->targv[2] )) + if (ttoi(ai->targv[1]) != ttoi( ai->targv[2] )) ai->flags |= AIF_FALSE; return mir_tstrdup(_T("")); @@ -291,7 +291,7 @@ static TCHAR *parseGreater(ARGUMENTSINFO *ai) if (ai->argc != 3) return NULL; - if ( ttoi(ai->targv[1]) <= ttoi(ai->targv[2] )) + if (ttoi(ai->targv[1]) <= ttoi(ai->targv[2] )) ai->flags |= AIF_FALSE; return mir_tstrdup(_T("")); diff --git a/plugins/Variables/parse_metacontacts.cpp b/plugins/Variables/parse_metacontacts.cpp index 6ffa229e9f..dd41eba2e3 100644 --- a/plugins/Variables/parse_metacontacts.cpp +++ b/plugins/Variables/parse_metacontacts.cpp @@ -35,7 +35,7 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai) ci.tszContact = ai->targv[1]; ci.flags = 0xFFFFFFFF ^ (CI_TCHAR == 0 ? CI_UNICODE : 0); int count = getContactFromString( &ci ); - if ( count == 1 && ci.hContacts != NULL ) { + if (count == 1 && ci.hContacts != NULL) { hContact = ci.hContacts[0]; mir_free(ci.hContacts); } @@ -52,16 +52,16 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai) TCHAR* res = NULL; TCHAR* szUniqueID = NULL; char* szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if ( szProto != NULL ) + if (szProto != NULL) szUniqueID = getContactInfoT(CNF_UNIQUEID, hContact, 1); - if ( szUniqueID == NULL ) + if (szUniqueID == NULL) { szProto = PROTOID_HANDLE; //szUniqueID = itot((INT_PTR)hContact); szUniqueID = (TCHAR*)mir_alloc(32); _stprintf(szUniqueID, _T("%p"), hContact); - if ( szProto == NULL || szUniqueID == NULL ) + if (szProto == NULL || szUniqueID == NULL) return NULL; } @@ -76,7 +76,7 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai) tszProto = mir_a2t(szProto); - if ( tszProto != NULL && szUniqueID != NULL ) { + if (tszProto != NULL && szUniqueID != NULL) { wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID); mir_free(szUniqueID); mir_free(tszProto); @@ -97,7 +97,7 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai) ci.tszContact = ai->targv[1]; ci.flags = 0xFFFFFFFF ^ (CI_TCHAR == 0 ? CI_UNICODE : 0); int count = getContactFromString( &ci ); - if ( count == 1 && ci.hContacts != NULL ) { + if (count == 1 && ci.hContacts != NULL) { hContact = ci.hContacts[0]; mir_free(ci.hContacts); } @@ -108,7 +108,7 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai) } hContact = (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT, (WPARAM)hContact, 0); - if ( hContact == NULL ) + if (hContact == NULL) return NULL; TCHAR* res = NULL; @@ -122,7 +122,7 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai) //szUniqueID = itot((INT_PTR)hContact); szUniqueID = (TCHAR*)mir_alloc(32); _stprintf(szUniqueID, _T("%p"), hContact); - if ( szProto == NULL || szUniqueID == NULL ) + if (szProto == NULL || szUniqueID == NULL) return NULL; } @@ -137,7 +137,7 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai) tszProto = mir_a2t(szProto); - if ( tszProto != NULL && szUniqueID != NULL ) { + if (tszProto != NULL && szUniqueID != NULL) { wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID); mir_free(szUniqueID); mir_free(tszProto); @@ -158,12 +158,12 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai) ci.tszContact = ai->targv[1]; ci.flags = 0xFFFFFFFF ^ (CI_TCHAR == 0 ? CI_UNICODE : 0); int count = getContactFromString( &ci ); - if ( count == 1 && ci.hContacts != NULL ) { + if (count == 1 && ci.hContacts != NULL) { hContact = ci.hContacts[0]; mir_free( ci.hContacts ); } else { - if ( ci.hContacts != NULL ) + if (ci.hContacts != NULL) mir_free( ci.hContacts ); return NULL; } @@ -183,7 +183,7 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai) //szUniqueID = itot((INT_PTR)hContact); szUniqueID = (TCHAR*)mir_alloc(32); _stprintf(szUniqueID, _T("%p"), hContact); - if ( szProto == NULL || szUniqueID == NULL ) + if (szProto == NULL || szUniqueID == NULL) return NULL; } @@ -198,7 +198,7 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai) tszProto = mir_a2t(szProto); - if ( tszProto != NULL && szUniqueID != NULL ) { + if (tszProto != NULL && szUniqueID != NULL) { wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID); mir_free(szUniqueID); mir_free(tszProto); @@ -209,7 +209,7 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai) int registerMetaContactsTokens() { - if ( ServiceExists( MS_MC_GETPROTOCOLNAME )) { + if (ServiceExists( MS_MC_GETPROTOCOLNAME )) { registerIntToken( _T(MC_GETPARENT), parseGetParent, TRF_FUNCTION, "MetaContacts\t(x)\tget parent metacontact of contact x"); registerIntToken( _T(MC_GETDEFAULT), parseGetDefault, TRF_FUNCTION, "MetaContacts\t(x)\tget default subcontact x"); registerIntToken( _T(MC_GETMOSTONLINE), parseGetMostOnline, TRF_FUNCTION, "MetaContacts\t(x)\tget the 'most online' subcontact x"); diff --git a/plugins/Variables/parse_miranda.cpp b/plugins/Variables/parse_miranda.cpp index 506cae65ea..ad1a79f514 100644 --- a/plugins/Variables/parse_miranda.cpp +++ b/plugins/Variables/parse_miranda.cpp @@ -79,35 +79,29 @@ static int getContactInfoFlags(TCHAR *tszDesc) static TCHAR *parseContact(ARGUMENTSINFO *ai) { - CONTACTSINFO ci; - int count, n; - HANDLE hContact; - - if ( ai->argc < 3 || ai->argc > 4 ) + if (ai->argc < 3 || ai->argc > 4 ) return NULL; - n = 0; - if ( ai->argc == 4 && *ai->targv[3] != _T('r')) + int n = 0; + if (ai->argc == 4 && *ai->targv[3] != _T('r')) n = ttoi(ai->targv[3]) - 1; - ZeroMemory(&ci, sizeof(ci)); + CONTACTSINFO ci = { 0 }; ci.cbSize = sizeof(ci); ci.tszContact = ai->targv[1]; ci.flags = getContactInfoFlags(ai->targv[2]); - count = getContactFromString( &ci ); - if ( count == 0 || ci.hContacts == NULL ) + int count = getContactFromString( &ci ); + if (count == 0 || ci.hContacts == NULL) return NULL; - if ( ai->argc == 4 && *ai->targv[3] == _T('r')) + if (ai->argc == 4 && *ai->targv[3] == _T('r')) n = rand() % count; - if ( count != 1 && ai->argc != 4 ) { - if ( ci.hContacts != NULL ) - mir_free(ci.hContacts); - + if (count != 1 && ai->argc != 4 ) { + mir_free(ci.hContacts); return NULL; } - hContact = ci.hContacts[n]; + HANDLE hContact = ci.hContacts[n]; log_debugA("contact: %x", hContact); mir_free(ci.hContacts); @@ -124,7 +118,7 @@ static TCHAR *parseContactCount(ARGUMENTSINFO *ai) ci.tszContact = ai->targv[1]; ci.flags = getContactInfoFlags(ai->targv[2]); int count = getContactFromString( &ci ); - if ( count != 0 && ci.hContacts != NULL ) + if (count != 0 && ci.hContacts != NULL) mir_free(ci.hContacts); return itot(count); @@ -132,30 +126,24 @@ static TCHAR *parseContactCount(ARGUMENTSINFO *ai) static TCHAR *parseContactInfo(ARGUMENTSINFO *ai) { - HANDLE hContact; - CONTACTSINFO ci; - int count; - BYTE type; - if (ai->argc != 3) return NULL; - hContact = NULL; - ZeroMemory(&ci, sizeof(ci)); + HANDLE hContact = NULL; + CONTACTSINFO ci = { 0 }; ci.cbSize = sizeof(ci); ci.tszContact = ai->targv[1]; ci.flags = 0xFFFFFFFF ^ (CI_TCHAR == 0 ? CI_UNICODE : 0); - count = getContactFromString( &ci ); - if ( count == 1 && ci.hContacts != NULL ) { + int count = getContactFromString( &ci ); + if (count == 1 && ci.hContacts != NULL) { hContact = ci.hContacts[0]; mir_free(ci.hContacts); } else { - if (ci.hContacts != NULL) - mir_free(ci.hContacts); + mir_free(ci.hContacts); return NULL; } - type = getContactInfoType(ai->targv[2]); + BYTE type = getContactInfoType(ai->targv[2]); if (type == 0) return NULL; @@ -164,32 +152,30 @@ static TCHAR *parseContactInfo(ARGUMENTSINFO *ai) static TCHAR *parseDBProfileName(ARGUMENTSINFO *ai) { - char name[MAX_PATH]; - if (ai->argc != 1) return NULL; - if (CallService(MS_DB_GETPROFILENAME, SIZEOF(name), (LPARAM)name)) + TCHAR name[MAX_PATH]; + if (CallService(MS_DB_GETPROFILENAMET, SIZEOF(name), (LPARAM)name)) return NULL; - return mir_a2t(name); + return mir_tstrdup(name); } -static TCHAR *parseDBProfilePath(ARGUMENTSINFO *ai) { - - char path[MAX_PATH]; - +static TCHAR *parseDBProfilePath(ARGUMENTSINFO *ai) +{ if (ai->argc != 1) return NULL; - if (CallService(MS_DB_GETPROFILEPATH, SIZEOF(path), (LPARAM)path)) + TCHAR path[MAX_PATH]; + if (CallService(MS_DB_GETPROFILEPATHT, SIZEOF(path), (LPARAM)path)) return NULL; - return mir_a2t(path); + return mir_tstrdup(path); } -static TCHAR* getDBSetting(HANDLE hContact, char* module, char* setting, TCHAR* defaultValue) { - +static TCHAR* getDBSetting(HANDLE hContact, char* module, char* setting, TCHAR* defaultValue) +{ DBVARIANT dbv; if (DBGetContactSettingW(hContact, module, setting, &dbv)) return defaultValue; @@ -209,7 +195,7 @@ static TCHAR* getDBSetting(HANDLE hContact, char* module, char* setting, TCHAR* var = mir_a2t(dbv.pszVal); break; case DBVT_WCHAR: - var = _wcsdup(dbv.pwszVal); + var = mir_wstrdup(dbv.pwszVal); break; case DBVT_UTF8: Utf8Decode(dbv.pszVal, &var); @@ -222,42 +208,35 @@ static TCHAR* getDBSetting(HANDLE hContact, char* module, char* setting, TCHAR* static TCHAR *parseDBSetting(ARGUMENTSINFO *ai) { - CONTACTSINFO ci; - HANDLE hContact; - int count; - char *szModule, *szSetting; - TCHAR *res, *szDefaultValue; - if (ai->argc < 4) return NULL; - res = NULL; - hContact = NULL; - szDefaultValue = NULL; - if (_tcslen(ai->targv[1]) > 0) { - ZeroMemory(&ci, sizeof(ci)); + TCHAR *res = NULL, *szDefaultValue = NULL; + HANDLE hContact = NULL; + + if ( _tcslen(ai->targv[1]) > 0) { + CONTACTSINFO ci = { 0 }; ci.cbSize = sizeof(ci); ci.tszContact = ai->targv[1]; ci.flags = 0xFFFFFFFF^(CI_TCHAR==0?CI_UNICODE:0); - count = getContactFromString( &ci ); - if ( count == 1 && ci.hContacts != NULL ) { + int count = getContactFromString( &ci ); + if (count == 1 && ci.hContacts != NULL) { hContact = ci.hContacts[0]; mir_free(ci.hContacts); } else { - if (ci.hContacts != NULL) - mir_free(ci.hContacts); + mir_free(ci.hContacts); return NULL; } } - szModule = mir_t2a(ai->targv[2]); - szSetting = mir_t2a(ai->targv[3]); + char *szModule = mir_t2a(ai->targv[2]); + char *szSetting = mir_t2a(ai->targv[3]); - if ( ai->argc > 4 && _tcslen(ai->targv[4]) > 0 ) + if (ai->argc > 4 && _tcslen(ai->targv[4]) > 0) szDefaultValue = mir_tstrdup(ai->targv[4]); - if ( szModule != NULL && szSetting != NULL ) { + if (szModule != NULL && szSetting != NULL) { res = getDBSetting(hContact, szModule, szSetting, szDefaultValue); mir_free(szModule); mir_free(szSetting); @@ -267,23 +246,16 @@ static TCHAR *parseDBSetting(ARGUMENTSINFO *ai) static TCHAR *parseLastSeenDate(ARGUMENTSINFO *ai) { - HANDLE hContact; - CONTACTSINFO ci; - int count, len; - SYSTEMTIME lsTime; - TCHAR *szFormat, *res; - char *szModule; - if (ai->argc <= 1) return NULL; - hContact = NULL; - ZeroMemory(&ci, sizeof(ci)); + HANDLE hContact = NULL; + CONTACTSINFO ci = { 0 }; ci.cbSize = sizeof(ci); ci.tszContact = ai->targv[1]; ci.flags = 0xFFFFFFFF^(CI_TCHAR==0?CI_UNICODE:0); - count = getContactFromString( &ci ); - if ( count == 1 && ci.hContacts != NULL ) { + int count = getContactFromString( &ci ); + if (count == 1 && ci.hContacts != NULL) { hContact = ci.hContacts[0]; mir_free(ci.hContacts); } @@ -292,13 +264,15 @@ static TCHAR *parseLastSeenDate(ARGUMENTSINFO *ai) mir_free(ci.hContacts); return NULL; } - if ( ai->argc == 2 || (ai->argc > 2 && _tcslen(ai->targv[2]) == 0)) + + TCHAR *szFormat; + if (ai->argc == 2 || (ai->argc > 2 && _tcslen(ai->targv[2]) == 0)) szFormat = NULL; else szFormat = ai->targv[2]; - ZeroMemory(&lsTime, sizeof(lsTime)); - szModule = CEX_MODULE; + SYSTEMTIME lsTime = { 0 }; + char *szModule = CEX_MODULE; lsTime.wYear = DBGetContactSettingWord(hContact, szModule, "Year", 0); if (lsTime.wYear == 0) szModule = SEEN_MODULE; @@ -315,8 +289,8 @@ static TCHAR *parseLastSeenDate(ARGUMENTSINFO *ai) lsTime.wDayOfWeek = DBGetContactSettingWord(hContact, szModule, "WeekDay", 0); lsTime.wMonth = DBGetContactSettingWord(hContact, szModule, "Month", 0); - len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &lsTime, szFormat, NULL, 0); - res = ( TCHAR* )mir_alloc((len+1)*sizeof(TCHAR)); + int len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &lsTime, szFormat, NULL, 0); + TCHAR *res = ( TCHAR* )mir_alloc((len+1)*sizeof(TCHAR)); if (res == NULL) return NULL; @@ -330,38 +304,33 @@ static TCHAR *parseLastSeenDate(ARGUMENTSINFO *ai) static TCHAR *parseLastSeenTime(ARGUMENTSINFO *ai) { - HANDLE hContact; - CONTACTSINFO ci; - int count, len; - SYSTEMTIME lsTime; - TCHAR *szFormat, *res; - char *szModule; - if (ai->argc <= 1) return NULL; - hContact = NULL; - ZeroMemory(&ci, sizeof(ci)); + HANDLE hContact = NULL; + + CONTACTSINFO ci = { 0 }; ci.cbSize = sizeof(ci); ci.tszContact = ai->targv[1]; ci.flags = 0xFFFFFFFF^(CI_TCHAR==0?CI_UNICODE:0); - count = getContactFromString( &ci ); - if ( count == 1 && ci.hContacts != NULL ) { + int count = getContactFromString( &ci ); + if (count == 1 && ci.hContacts != NULL) { hContact = ci.hContacts[0]; mir_free(ci.hContacts); } else { - if (ci.hContacts != NULL) - mir_free(ci.hContacts); + mir_free(ci.hContacts); return NULL; } - if ( ai->argc == 2 || (ai->argc > 2 && _tcslen(ai->targv[2]) == 0)) + + TCHAR *szFormat; + if (ai->argc == 2 || (ai->argc > 2 && _tcslen(ai->targv[2]) == 0)) szFormat = NULL; else szFormat = ai->targv[2]; - ZeroMemory(&lsTime, sizeof(lsTime)); - szModule = CEX_MODULE; + SYSTEMTIME lsTime = { 0 }; + char *szModule = CEX_MODULE; lsTime.wYear = DBGetContactSettingWord(hContact, szModule, "Year", 0); if (lsTime.wYear == 0) szModule = SEEN_MODULE; @@ -379,8 +348,8 @@ static TCHAR *parseLastSeenTime(ARGUMENTSINFO *ai) lsTime.wMonth = DBGetContactSettingWord(hContact, szModule, "Month", 0); lsTime.wYear = DBGetContactSettingWord(hContact, szModule, "Year", 0); - len = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &lsTime, szFormat, NULL, 0); - res = ( TCHAR* )mir_alloc((len+1)*sizeof(TCHAR)); + int len = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &lsTime, szFormat, NULL, 0); + TCHAR *res = ( TCHAR* )mir_alloc((len+1)*sizeof(TCHAR)); if (res == NULL) return NULL; @@ -392,34 +361,27 @@ static TCHAR *parseLastSeenTime(ARGUMENTSINFO *ai) return res; } -static TCHAR *parseLastSeenStatus(ARGUMENTSINFO *ai) { - - HANDLE hContact; - CONTACTSINFO ci; - int count, status; - char *szModule; - TCHAR *szStatus; - +static TCHAR *parseLastSeenStatus(ARGUMENTSINFO *ai) +{ if (ai->argc != 2) return NULL; - hContact = NULL; - ZeroMemory(&ci, sizeof(ci)); + HANDLE hContact = NULL; + CONTACTSINFO ci = { 0 }; ci.cbSize = sizeof(ci); ci.tszContact = ai->targv[1]; ci.flags = 0xFFFFFFFF^(CI_TCHAR==0?CI_UNICODE:0); - count = getContactFromString( &ci ); - if ( (count == 1) && (ci.hContacts != NULL)) { + int count = getContactFromString( &ci ); + if ((count == 1) && (ci.hContacts != NULL)) { hContact = ci.hContacts[0]; mir_free(ci.hContacts); } else { - if (ci.hContacts != NULL) - mir_free(ci.hContacts); + mir_free(ci.hContacts); return NULL; } - szModule = CEX_MODULE; - status = DBGetContactSettingWord(hContact, szModule, "Status", 0); + char *szModule = CEX_MODULE; + int status = DBGetContactSettingWord(hContact, szModule, "Status", 0); if (status == 0) szModule = SEEN_MODULE; @@ -427,46 +389,38 @@ static TCHAR *parseLastSeenStatus(ARGUMENTSINFO *ai) { if (status == 0) return NULL; - szStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)status, GSMDF_UNICODE); + TCHAR *szStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)status, GSMDF_TCHAR); if (szStatus != NULL) return mir_tstrdup(szStatus); return NULL; } -static TCHAR *parseMirandaPath(ARGUMENTSINFO *ai) { - - TCHAR path[MAX_PATH]; - +static TCHAR *parseMirandaPath(ARGUMENTSINFO *ai) +{ if (ai->argc != 1) return NULL; ai->flags |= AIF_DONTPARSE; + TCHAR path[MAX_PATH]; if (GetModuleFileName(NULL, path, SIZEOF(path)) == 0) return NULL; return mir_tstrdup(path); } -static TCHAR *parseMyStatus(ARGUMENTSINFO *ai) { - - int status; - char *szProto; - TCHAR *szStatus; - +static TCHAR *parseMyStatus(ARGUMENTSINFO *ai) +{ if (ai->argc > 2) return NULL; - if ( ai->argc == 1 || _tcslen(ai->targv[1]) == 0 ) + int status; + if (ai->argc == 1 || _tcslen(ai->targv[1]) == 0 ) status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0); - else { - - szProto = mir_t2a(ai->targv[1]); + else + status = CallProtoService( _T2A(ai->targv[1]), PS_GETSTATUS, 0, 0); - status = CallProtoService(szProto, PS_GETSTATUS, 0, 0); - mir_free(szProto); - } - szStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)status, GSMDF_UNICODE); + TCHAR *szStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)status, GSMDF_UNICODE); if (szStatus != NULL) return mir_tstrdup(szStatus); @@ -475,49 +429,40 @@ static TCHAR *parseMyStatus(ARGUMENTSINFO *ai) { static TCHAR *parseProtoInfo(ARGUMENTSINFO *ai) { - TCHAR *tszRes; - char *szProto, *szRes; - if (ai->argc != 3) return NULL; - szRes = NULL; - tszRes = NULL; - - szProto = mir_t2a(ai->targv[1]); + char *szRes = NULL; + TCHAR *tszRes = NULL; + char *szProto = mir_t2a(ai->targv[1]); if (!_tcscmp(ai->targv[2], _T(STR_PINAME))) tszRes = Hlp_GetProtocolName(szProto); else if (!_tcscmp(ai->targv[2], _T(STR_PIUIDTEXT))) { - char *szText; - if (!ProtoServiceExists(szProto, PS_GETCAPS)) return NULL; - szText = (char *)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDTEXT, 0); + char *szText = (char *)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDTEXT, 0); if (szText != NULL) szRes = _strdup(szText); } else if (!_tcscmp(ai->targv[2], _T(STR_PIUIDSETTING))) { - char *szText; if (!ProtoServiceExists(szProto, PS_GETCAPS)) return NULL; - szText = (char *)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); + char *szText = (char *)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); if (szText != NULL) szRes = _strdup(szText); } mir_free(szProto); - if ( szRes == NULL && tszRes == NULL ) + if (szRes == NULL && tszRes == NULL) return NULL; - if ( szRes != NULL && tszRes == NULL ) { - - tszRes = mir_a2t(szRes); - mir_free(szRes); - + if (szRes != NULL && tszRes == NULL) { + tszRes = mir_a2t(szRes); + mir_free(szRes); } - else if ( szRes != NULL && tszRes != NULL ) + else if (szRes != NULL && tszRes != NULL) mir_free(szRes); return tszRes; @@ -525,16 +470,13 @@ static TCHAR *parseProtoInfo(ARGUMENTSINFO *ai) static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai) { - char *szProto; - TCHAR *szUniqueID, *res, *tszProto; - - if ( ai->argc != 1 || ai->fi->hContact == NULL ) + if (ai->argc != 1 || ai->fi->hContact == NULL) return NULL; ai->flags |= AIF_DONTPARSE; - res = NULL; - szUniqueID = NULL; - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ai->fi->hContact, 0); + TCHAR *res = NULL; + TCHAR *szUniqueID = NULL; + char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ai->fi->hContact, 0); if (szProto != NULL) szUniqueID = getContactInfoT(CNF_UNIQUEID, ai->fi->hContact, 1); @@ -543,7 +485,7 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai) //szUniqueID = itot((INT_PTR)ai->fi->hContact); szUniqueID = (TCHAR*)mir_alloc(32); _stprintf(szUniqueID, _T("%p"), ai->fi->hContact); - if ( szProto == NULL || szUniqueID == NULL ) + if (szProto == NULL || szUniqueID == NULL) return NULL; } @@ -553,11 +495,8 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai) return NULL; } - - tszProto = mir_a2t(szProto); - - - if ( tszProto != NULL && szUniqueID != NULL ) { + TCHAR *tszProto = mir_a2t(szProto); + if (tszProto != NULL && szUniqueID != NULL) { wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID); mir_free(szUniqueID); mir_free(tszProto); @@ -595,9 +534,9 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags) dbe.cbBlob = 0; dbe.pBlob = NULL; if (hContact != NULL) { - if ( (flags & DBE_FIRST) && (flags & DBE_UNREAD)) { + if ((flags & DBE_FIRST) && (flags & DBE_UNREAD)) { hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0); - if ( hDbEvent == NULL && (flags & DBE_READ)) + if (hDbEvent == NULL && (flags & DBE_READ)) hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0); } else if (flags & DBE_FIRST) @@ -672,7 +611,7 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags) hSearchEvent = findDbEvent(hSearchContact, hDbEvent, flags); dbe.cbBlob = 0; if (!CallService(MS_DB_EVENT_GET, (WPARAM)hSearchEvent, (LPARAM)&dbe)) { - if ( ((dbe.timestamp > matchTimestamp) || (matchTimestamp == 0)) && (dbe.timestamp < priorTimestamp)) { + if (((dbe.timestamp > matchTimestamp) || (matchTimestamp == 0)) && (dbe.timestamp < priorTimestamp)) { hMatchEvent = hSearchEvent; matchTimestamp = dbe.timestamp; } @@ -698,44 +637,11 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags) flags &= ~DBE_LAST; } } - } while ( (!bEventOk) && (hDbEvent != NULL)); - - return hDbEvent; -} - -// modified from history.c -static TCHAR *GetMessageDescription(DBEVENTINFO *dbei) -{ - TCHAR *tszRes; - - if ( ServiceExists( MS_DB_EVENT_GETTEXT )) { - // Miranda 0.7 - TCHAR *buf = DbGetEventTextT(dbei, CP_ACP); - tszRes = mir_tstrdup(buf); - mir_free(buf); - } - else { - char *pszSrc = ( char* )dbei->pBlob; - size_t len = strlen(( char* )dbei->pBlob )+1; - - if ( dbei->cbBlob > len ) { - int len2 = dbei->cbBlob - len; - - tszRes = ( TCHAR* )mir_calloc(len2); - memcpy(tszRes, &dbei->pBlob[ len ], len2); - } - else { - char *szRes = ( char* )mir_calloc(len); - strncpy(szRes, ( const char* )pszSrc, len); - tszRes = mir_a2t(szRes); - mir_free(szRes); - } - } + while ( (!bEventOk) && (hDbEvent != NULL)); - return tszRes; + return hDbEvent; } -// end: from history.c // ?message(%subject%,last|first,sent|recv,read|unread) static TCHAR *parseDbEvent(ARGUMENTSINFO *ai) @@ -782,7 +688,7 @@ static TCHAR *parseDbEvent(ARGUMENTSINFO *ai) ci.tszContact = ai->targv[1]; ci.flags = 0xFFFFFFFF^(CI_TCHAR==0?CI_UNICODE:0); int count = getContactFromString( &ci ); - if ( (count == 1) && (ci.hContacts != NULL)) { + if ((count == 1) && (ci.hContacts != NULL)) { hContact = ci.hContacts[0]; mir_free(ci.hContacts); } @@ -801,7 +707,8 @@ static TCHAR *parseDbEvent(ARGUMENTSINFO *ai) mir_free(dbe.pBlob); return NULL; } - TCHAR *res = GetMessageDescription(&dbe); + + TCHAR *res = DbGetEventTextT(&dbe, CP_ACP); mir_free(dbe.pBlob); return res; } @@ -873,10 +780,10 @@ static TCHAR *parseMirandaCoreVar(ARGUMENTSINFO *ai) static TCHAR *parseMirSrvExists(ARGUMENTSINFO *ai) { - if ( ai->argc != 2 ) + if (ai->argc != 2 ) return NULL; - if ( !ServiceExists( _T2A( ai->targv[1] ))) + if (!ServiceExists( _T2A( ai->targv[1] ))) ai->flags |= AIF_FALSE; return mir_tstrdup(_T("")); diff --git a/plugins/Variables/parse_str.cpp b/plugins/Variables/parse_str.cpp index 3f9781dcfc..81144aea08 100644 --- a/plugins/Variables/parse_str.cpp +++ b/plugins/Variables/parse_str.cpp @@ -32,7 +32,7 @@ static TCHAR *parseCaps(ARGUMENTSINFO *ai) { *cur = (TCHAR)CharUpper((LPTSTR)*cur); cur++; while (*cur != _T('\0')) { - if ( (*cur == _T(' ')) && (*(cur+1) != _T('\0'))) { + if ((*cur == _T(' ')) && (*(cur+1) != _T('\0'))) { cur++; if (IsCharLower(*cur)) *cur = (TCHAR)CharUpper((LPTSTR)*cur); @@ -58,7 +58,7 @@ static TCHAR *parseCaps2(ARGUMENTSINFO *ai) { *cur = (TCHAR)CharUpper((LPTSTR)*cur); cur++; while (*cur != _T('\0')) { - if ( (*cur == _T(' ')) && (*(cur+1) != _T('\0'))) { + if ((*cur == _T(' ')) && (*(cur+1) != _T('\0'))) { cur++; if (IsCharLower(*cur)) *cur = (TCHAR)CharUpper((LPTSTR)*cur); @@ -87,7 +87,7 @@ static TCHAR *parseEolToCrlf(ARGUMENTSINFO *ai) { cur = res; do { cur = _tcschr(cur, _T('\n')); - if ( (cur == NULL) || ((cur > res) && (*(cur-1) == '\r'))) { + if ((cur == NULL) || ((cur > res) && (*(cur-1) == '\r'))) { continue; } log_debug(cur); @@ -156,7 +156,7 @@ static TCHAR *parseFixeol2(ARGUMENTSINFO *ai) { szEol = _T("\n"); } if (szEol != NULL) { - if (_tcslen(szReplacement) > _tcslen(szEol)) { + if ( _tcslen(szReplacement) > _tcslen(szEol)) { res = ( TCHAR* )realloc(res, (_tcslen(res) + _tcslen(szReplacement) - _tcslen(szEol) + 1)*sizeof(TCHAR)); cur = res+pos; } @@ -278,7 +278,7 @@ static TCHAR *parseLongest(ARGUMENTSINFO *ai) { } iLong = 1; for (i=2;iargc;i++) { - if (_tcslen(ai->targv[i]) > _tcslen(ai->targv[iLong])) { + if ( _tcslen(ai->targv[i]) > _tcslen(ai->targv[iLong])) { iLong = i; } } @@ -410,7 +410,7 @@ static TCHAR *parsePadcutright(ARGUMENTSINFO *ai) { for (i=0; i < addcount; i++ ) *cur++ = padchar; - if ( padding > addcount ) + if (padding > addcount ) _tcsncpy(res, ai->targv[1], padding-addcount); return res; @@ -445,19 +445,19 @@ static TCHAR *parseReplace(ARGUMENTSINFO *ai) { TCHAR *res, *cur; unsigned int i, pos; - if ( (ai->argc < 4) || (ai->argc%2 != 0)) { + if ((ai->argc < 4) || (ai->argc%2 != 0)) { return NULL; } pos = 0; res = mir_tstrdup(ai->targv[1]); for (i=2;iargc;i+=2) { - if (_tcslen(ai->targv[i]) == 0) { + if ( _tcslen(ai->targv[i]) == 0) { continue; } for (pos=0;pos<_tcslen(res);pos++) { cur = res+pos; if (!_tcsncmp(cur, ai->targv[i], _tcslen(ai->targv[i]))) { - if (_tcslen(ai->targv[i+1]) > _tcslen(ai->targv[i])) { + if ( _tcslen(ai->targv[i+1]) > _tcslen(ai->targv[i])) { res = ( TCHAR* )realloc(res, (_tcslen(res) + _tcslen(ai->targv[i+1]) - _tcslen(ai->targv[i]) + 1)*sizeof(TCHAR)); cur = res+pos; } @@ -506,7 +506,7 @@ static TCHAR *parseScroll(ARGUMENTSINFO *ai) { if (ai->argc != 4) { return NULL; } - if (_tcslen(ai->targv[1]) == 0) { + if ( _tcslen(ai->targv[1]) == 0) { return mir_tstrdup(ai->targv[1]); } @@ -538,7 +538,7 @@ static TCHAR *parseShortest(ARGUMENTSINFO *ai) { } iShort = 1; for (i=2;iargc;i++) { - if (_tcslen(ai->targv[i]) < _tcslen(ai->targv[iShort])) { + if ( _tcslen(ai->targv[i]) < _tcslen(ai->targv[iShort])) { iShort = i; } } @@ -556,7 +556,7 @@ static TCHAR *parseStrchr(ARGUMENTSINFO *ai) { } ZeroMemory(szVal, sizeof(szVal)); c = _tcschr(ai->targv[1], *ai->targv[2]); - if ( (c == NULL) || (*c == _T('\0'))) { + if ((c == NULL) || (*c == _T('\0'))) { return mir_tstrdup(_T("0")); } @@ -568,7 +568,7 @@ static TCHAR *parseStrcmp(ARGUMENTSINFO *ai) { if (ai->argc != 3) { return NULL; } - if (_tcscmp(ai->targv[1], ai->targv[2])) { + if ( _tcscmp(ai->targv[1], ai->targv[2])) { ai->flags |= AIF_FALSE; } @@ -604,7 +604,7 @@ static TCHAR *parseStrncmp(ARGUMENTSINFO *ai) { if (n <= 0) { return NULL; } - if (_tcsncmp(ai->targv[1], ai->targv[2], n)) { + if ( _tcsncmp(ai->targv[1], ai->targv[2], n)) { ai->flags |= AIF_FALSE; } @@ -617,7 +617,7 @@ static TCHAR *parseStricmp(ARGUMENTSINFO *ai) { return NULL; } - if (_tcsicmp(ai->targv[1], ai->targv[2])) { + if ( _tcsicmp(ai->targv[1], ai->targv[2])) { ai->flags |= AIF_FALSE; } @@ -635,7 +635,7 @@ static TCHAR *parseStrnicmp(ARGUMENTSINFO *ai) { if (n <= 0) { return NULL; } - if (_tcsnicmp(ai->targv[1], ai->targv[2], n)) { + if ( _tcsnicmp(ai->targv[1], ai->targv[2], n)) { ai->flags |= AIF_FALSE; } @@ -650,7 +650,7 @@ static TCHAR *parseStrrchr(ARGUMENTSINFO *ai) { return NULL; } c = _tcsrchr(ai->targv[1], *ai->targv[2]); - if ( (c == NULL) || (*c == _T('\0'))) { + if ((c == NULL) || (*c == _T('\0'))) { return mir_tstrdup(_T("0")); } @@ -665,7 +665,7 @@ static TCHAR *parseStrstr(ARGUMENTSINFO *ai) { return NULL; } c = _tcsstr(ai->targv[1], ai->targv[2]); - if ( (c == NULL) || (*c == _T('\0'))) { + if ((c == NULL) || (*c == _T('\0'))) { return mir_tstrdup(_T("0")); } @@ -705,7 +705,7 @@ static TCHAR *parseSelect(ARGUMENTSINFO *ai) { return NULL; } n = ttoi(ai->targv[1]); - if ( (n > (signed int)ai->argc-2) || (n <= 0)) { + if ((n > (signed int)ai->argc-2) || (n <= 0)) { return NULL; } @@ -761,7 +761,7 @@ static TCHAR *parseTab(ARGUMENTSINFO *ai) { TCHAR *res, *cur; count = 1; - if ( (ai->argc == 2) && (_tcslen(ai->targv[1]) > 0)) { + if ((ai->argc == 2) && (_tcslen(ai->targv[1]) > 0)) { count = ttoi(ai->targv[1]); } if (count < 0) { @@ -842,20 +842,20 @@ static TCHAR *parseWord(ARGUMENTSINFO *ai) { int i, from, to; TCHAR *res, *szWord; - if ( ai->argc < 3 || ai->argc > 4 ) + if (ai->argc < 3 || ai->argc > 4 ) return NULL; res = NULL; from = ttoi(ai->targv[2]); if (ai->argc == 4) { - if (_tcslen(ai->targv[3]) > 0) + if ( _tcslen(ai->targv[3]) > 0) to = ttoi(ai->targv[3]); else to = 100000; // rework } else to = from; - if ( (from == 0) || (to == 0) || (from > to)) + if ((from == 0) || (to == 0) || (from > to)) return NULL; for (i=from;i<=to;i++) { diff --git a/plugins/Variables/parse_system.cpp b/plugins/Variables/parse_system.cpp index 8acfd174b0..761211edeb 100644 --- a/plugins/Variables/parse_system.cpp +++ b/plugins/Variables/parse_system.cpp @@ -69,7 +69,7 @@ static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai) { if (ai->argc != 2) return NULL; - if (_tcslen(ai->targv[1]) == 0) + if ( _tcslen(ai->targv[1]) == 0) szCounter = mir_tstrdup(_T("\\Processor(_Total)\\% Processor Time")); else { szCounter = ( TCHAR* )mir_alloc((_tcslen(ai->targv[1]) + 32)*sizeof(TCHAR)); @@ -136,7 +136,7 @@ static TCHAR *parseCurrentDate(ARGUMENTSINFO *ai) { int len; TCHAR *szFormat, *res; - if ( ai->argc == 1 || (ai->argc > 1 && _tcslen(ai->targv[1]) == 0 )) + if (ai->argc == 1 || (ai->argc > 1 && _tcslen(ai->targv[1]) == 0 )) szFormat = NULL; else szFormat = ai->targv[1]; @@ -159,7 +159,7 @@ static TCHAR *parseCurrentTime(ARGUMENTSINFO *ai) { int len; TCHAR *szFormat, *res; - if ( ai->argc == 1 || (ai->argc > 1) && (_tcslen(ai->targv[1]) == 0)) + if (ai->argc == 1 || (ai->argc > 1) && (_tcslen(ai->targv[1]) == 0)) szFormat = NULL; else szFormat = ai->targv[1]; @@ -182,7 +182,7 @@ static TCHAR *parseDirectory(ARGUMENTSINFO *ai) { int depth; TCHAR *res, *ecur, *scur; - if ( ai->argc < 2 || ai->argc > 3 ) + if (ai->argc < 2 || ai->argc > 3 ) return NULL; depth = 1; @@ -227,7 +227,7 @@ static TCHAR *parseDirectory2(ARGUMENTSINFO *ai) { int depth; TCHAR *res, *ecur; - if ( ai->argc < 2 || ai->argc > 3 ) + if (ai->argc < 2 || ai->argc > 3 ) return NULL; depth = 1; @@ -456,12 +456,12 @@ static TCHAR *parseListDir(ARGUMENTSINFO *ai) { if (hFind == INVALID_HANDLE_VALUE) { return NULL; } - if ( ((ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && (bDirs)) || ((!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) && (bFiles))) { + if (((ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && (bDirs)) || ((!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) && (bFiles))) { tszRes = ( TCHAR* )mir_alloc((_tcslen(ffd.cFileName) + _tcslen(tszSeperator) + 1)*sizeof(TCHAR)); _tcscpy(tszRes, ffd.cFileName); } while (FindNextFile(hFind, &ffd) != 0) { - if ( ((ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && (bDirs)) || ((!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) && (bFiles))) { + if (((ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && (bDirs)) || ((!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) && (bFiles))) { if (tszRes != NULL) { _tcscat(tszRes, tszSeperator); tszRes = ( TCHAR* )mir_realloc(tszRes, (_tcslen(tszRes) + _tcslen(ffd.cFileName) + _tcslen(tszSeperator) + 1)*sizeof(TCHAR)); @@ -484,7 +484,7 @@ static BOOL CALLBACK MyProcessEnumerator(DWORD dwPID, WORD wTask, char *szProces char **szProc; szProc = (char **)lParam; - if ( (*szProc != NULL) && (!_stricmp(*szProc, szProcess))) { + if ((*szProc != NULL) && (!_stricmp(*szProc, szProcess))) { *szProc = NULL; } @@ -558,7 +558,7 @@ static TCHAR *parseRegistryValue(ARGUMENTSINFO *ai) { } ZeroMemory(res, len); err = RegQueryValueEx(hKey, ai->targv[2], NULL, &type, (BYTE*)res, &len); - if ( (err != ERROR_SUCCESS) || (type != REG_SZ)) { + if ((err != ERROR_SUCCESS) || (type != REG_SZ)) { RegCloseKey(hKey); mir_free(res); return NULL; @@ -602,7 +602,7 @@ static TCHAR *parseTimestamp2Date(ARGUMENTSINFO *ai) { if (timestamp == 0) { return NULL; } - if ( (ai->argc == 2) || ((ai->argc > 2) && (_tcslen(ai->targv[2]) == 0))) { + if ((ai->argc == 2) || ((ai->argc > 2) && (_tcslen(ai->targv[2]) == 0))) { szFormat = NULL; } else { @@ -638,7 +638,7 @@ static TCHAR *parseTimestamp2Time(ARGUMENTSINFO *ai) { if (timestamp == 0) { return NULL; } - if ( (ai->argc == 2) || ((ai->argc > 2) && (_tcslen(ai->targv[2]) == 0))) { + if ((ai->argc == 2) || ((ai->argc > 2) && (_tcslen(ai->targv[2]) == 0))) { szFormat = NULL; } else { @@ -796,7 +796,7 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) { } } } - if ( ((tUC) && (*(TCHAR *)pCur == _T('\r'))) || ((!tUC) && (*(char *)pCur == '\r'))) { + if (((tUC) && (*(TCHAR *)pCur == _T('\r'))) || ((!tUC) && (*(char *)pCur == '\r'))) { // in case the \r was at the end of the buffer, \n could be next SetFilePointer(hFile, -1*csz, NULL, FILE_CURRENT); totalReadSz -= csz; @@ -843,7 +843,7 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) { return res; } } - if ( ((DWORD)(linePos+(pCur-pBuf)) == fileSz)) { // eof + if (((DWORD)(linePos+(pCur-pBuf)) == fileSz)) { // eof CloseHandle(hFile); if (tUC) { @@ -859,7 +859,7 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) { if (readSz == bufSz-csz) { // buffer must be increased bufSz += TXTFILEBUFSZ*csz; - if ( ((tUC) && (*(TCHAR *)pCur == _T('\r'))) || ((!tUC) && (*(char *)pCur == '\r'))) { + if (((tUC) && (*(TCHAR *)pCur == _T('\r'))) || ((!tUC) && (*(char *)pCur == '\r'))) { pCur -= csz; } icur = pCur - pBuf; @@ -996,7 +996,7 @@ int registerSystemTokens() { #if _WIN32_WINNT>=0x0500 registerIntToken(_T(UPTIME), parseUpTime, TRF_FIELD, "System Functions\tuptime in seconds"); #endif - if ( !ServiceExists( MS_UTILS_REPLACEVARS )) + if (!ServiceExists( MS_UTILS_REPLACEVARS )) registerIntToken(_T(ENVIRONMENTVARIABLE), parseEnvironmentVariable, TRF_FUNCTION , "Miranda Core OS\t(%xxxxxxx%)\tany environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"); else { registerIntToken(_T(ENVIRONMENTVARIABLE), parseEnvironmentVariable, TRF_FUNCTION , "System Functions\t(x)\texpand environment variable x"); diff --git a/plugins/Variables/parse_variables.cpp b/plugins/Variables/parse_variables.cpp index 8b9bc57093..1be98fdf5e 100644 --- a/plugins/Variables/parse_variables.cpp +++ b/plugins/Variables/parse_variables.cpp @@ -28,12 +28,12 @@ static int addToVariablesRegister(TCHAR *szName, TCHAR *szText) { int i; - if ( (szName == NULL) || (szText == NULL) || (_tcslen(szName) <= 0)) { + if ((szName == NULL) || (szText == NULL) || (_tcslen(szName) <= 0)) { return -1; } EnterCriticalSection(&csVarRegister); for (i=0;itr.flags & TRF_PARSEFUNC ) && tre->tr.szService != NULL ) + if (!( tre->tr.flags & TRF_PARSEFUNC ) && tre->tr.szService != NULL) mir_free( tre->tr.szService ); - if ( tre->tr.tszTokenString != NULL ) + if (tre->tr.tszTokenString != NULL) mir_free( tre->tr.tszTokenString ); - if ( tre->tr.szHelpText != NULL ) + if (tre->tr.szHelpText != NULL) mir_free( tre->tr.szHelpText ); - if ( (tre->tr.flags & TRF_CLEANUP ) && !( tre->tr.flags & TRF_CLEANUPFUNC ) && tre->tr.szCleanupService != NULL ) + if ((tre->tr.flags & TRF_CLEANUP ) && !( tre->tr.flags & TRF_CLEANUPFUNC ) && tre->tr.szCleanupService != NULL) mir_free( tre->tr.szCleanupService ); mir_free( tre ); @@ -106,10 +106,10 @@ INT_PTR registerToken(WPARAM wParam, LPARAM lParam) TokenRegisterEntry *tre; TOKENREGISTEREX *newVr = ( TOKENREGISTEREX* )lParam; - if ( newVr == NULL || newVr->szTokenString == NULL || newVr->cbSize <= 0 ) + if (newVr == NULL || newVr->szTokenString == NULL || newVr->cbSize <= 0 ) return -1; - if ( newVr->flags & TRF_TCHAR ) { + if (newVr->flags & TRF_TCHAR ) { deRegisterToken( newVr->tszTokenString ); hash = NameHashFunction( newVr->tszTokenString ); } @@ -125,28 +125,28 @@ INT_PTR registerToken(WPARAM wParam, LPARAM lParam) } tre = ( TokenRegisterEntry* )mir_alloc( sizeof( TokenRegisterEntry )); - if ( tre == NULL ) + if (tre == NULL) return -1; memcpy( &tre->tr, newVr, newVr->cbSize ); tre->nameHash = hash; - if ( !_tcscmp( newVr->tszTokenString, _T("alias"))) + if (!_tcscmp( newVr->tszTokenString, _T("alias"))) log_debugA("alias"); - if ( !( newVr->flags & TRF_PARSEFUNC ) && newVr->szService != NULL ) + if (!( newVr->flags & TRF_PARSEFUNC ) && newVr->szService != NULL) tre->tr.szService = mir_strdup( newVr->szService ); - if ( newVr->flags & TRF_TCHAR ) + if (newVr->flags & TRF_TCHAR ) tre->tr.tszTokenString = mir_tstrdup( newVr->tszTokenString ); else tre->tr.tszTokenString = mir_a2t( newVr->szTokenString ); - if ( newVr->szHelpText != NULL ) + if (newVr->szHelpText != NULL) tre->tr.szHelpText = mir_strdup( newVr->szHelpText ); - if (( newVr->flags & TRF_CLEANUP ) && !( newVr->flags & TRF_CLEANUPFUNC ) && newVr->szCleanupService != NULL ) + if (( newVr->flags & TRF_CLEANUP ) && !( newVr->flags & TRF_CLEANUPFUNC ) && newVr->szCleanupService != NULL) tre->tr.szCleanupService = mir_strdup( newVr->szCleanupService ); EnterCriticalSection(&csRegister); @@ -162,12 +162,12 @@ TOKENREGISTEREX *searchRegister(TCHAR *tvar, int type) TokenRegisterEntry *tre; TOKENREGISTEREX *retVr; - if ( tvar == NULL ) + if (tvar == NULL) return 0; EnterCriticalSection( &csRegister ); tre = FindTokenRegisterByName( tvar ); - if ( tre == NULL || ( type != 0 && (tre->tr.flags & ( TRF_FIELD | TRF_FUNCTION )) != 0 && !( tre->tr.flags & type ))) + if (tre == NULL || ( type != 0 && (tre->tr.flags & ( TRF_FIELD | TRF_FUNCTION )) != 0 && !( tre->tr.flags & type ))) retVr = NULL; else retVr = &tre->tr; @@ -178,7 +178,7 @@ TOKENREGISTEREX *searchRegister(TCHAR *tvar, int type) TCHAR *parseFromRegister(ARGUMENTSINFO *ai) { - if ( ai == NULL || ai->argc == 0 || ai->targv[0] == NULL) + if (ai == NULL || ai->argc == 0 || ai->targv[0] == NULL) return NULL; INT_PTR callRes = 0; @@ -188,7 +188,7 @@ TCHAR *parseFromRegister(ARGUMENTSINFO *ai) /* note the following limitation: you cannot add/remove tokens during a call from a different thread */ TOKENREGISTEREX *thisVr = searchRegister( ai->targv[0], 0 ); - if ( thisVr == NULL ) { + if (thisVr == NULL) { LeaveCriticalSection(&csRegister); return NULL; } @@ -196,7 +196,7 @@ TCHAR *parseFromRegister(ARGUMENTSINFO *ai) TOKENREGISTEREX trCopy = *thisVr; // ai contains WCHARs, convert to chars because the tr doesn't support WCHARs - if ( !( thisVr->flags & TRF_TCHAR )) { + if (!( thisVr->flags & TRF_TCHAR )) { // unicode variables calls a non-unicode plugin unsigned int j; ARGUMENTSINFO cAi; @@ -206,41 +206,41 @@ TCHAR *parseFromRegister(ARGUMENTSINFO *ai) for ( j=0; j < ai->argc; j++ ) cAi.argv[j] = mir_t2a( ai->targv[j] ); - if ( thisVr->flags & TRF_PARSEFUNC ) + if (thisVr->flags & TRF_PARSEFUNC ) callRes = (INT_PTR)thisVr->parseFunction( &cAi ); - else if ( thisVr->szService != NULL) + else if (thisVr->szService != NULL) callRes = CallService( thisVr->szService, (WPARAM)0, (LPARAM)&cAi ); for ( j=0; j < cAi.argc; j++ ) - if ( cAi.argv[j] != NULL ) + if (cAi.argv[j] != NULL) mir_free( cAi.argv[j] ); - if ((char *)callRes != NULL ) + if ((char *)callRes != NULL) res = mir_a2t(( char* )callRes ); } else { // unicode variables calls unicode plugin - if ( thisVr->flags & TRF_PARSEFUNC ) + if (thisVr->flags & TRF_PARSEFUNC ) callRes = (INT_PTR)thisVr->parseFunctionT( ai ); - else if ( thisVr->szService != NULL ) + else if (thisVr->szService != NULL) callRes = CallService( thisVr->szService, (WPARAM)0, (LPARAM)ai ); - if (( TCHAR* )callRes != NULL ) + if (( TCHAR* )callRes != NULL) res = mir_tstrdup(( TCHAR* )callRes ); } - if (( void* )callRes != NULL ) { - if ( trCopy.flags & TRF_CLEANUP ) { - if ( trCopy.flags & TRF_CLEANUPFUNC ) + if (( void* )callRes != NULL) { + if (trCopy.flags & TRF_CLEANUP ) { + if (trCopy.flags & TRF_CLEANUPFUNC ) trCopy.cleanupFunctionT(( TCHAR* )callRes ); - else if ( trCopy.szCleanupService != NULL ) + else if (trCopy.szCleanupService != NULL) CallService( trCopy.szCleanupService, 0, (LPARAM)callRes ); } - if ( trCopy.flags & TRF_FREEMEM ) { - if ( trCopy.memType == TR_MEM_MIRANDA ) + if (trCopy.flags & TRF_FREEMEM ) { + if (trCopy.memType == TR_MEM_MIRANDA ) mir_free(( void* )callRes ); -// else if ( trCopy.memType == TR_MEM_VARIABLES ) +// else if (trCopy.memType == TR_MEM_VARIABLES ) // mir_free((void *)callRes); } } @@ -274,7 +274,7 @@ int getTokenRegisterCount() static int CompareTokens( const TokenRegisterEntry* p1, const TokenRegisterEntry* p2 ) { - if ( p1->nameHash == p2->nameHash ) + if (p1->nameHash == p2->nameHash ) return 0; return ( p1->nameHash < p2->nameHash ) ? -1 : 1; @@ -296,16 +296,16 @@ int deinitTokenRegister() for ( i=0; i < tokens.count; i++ ) { TokenRegisterEntry *tre = tokens.items[ i ]; - if ( !( tre->tr.flags & TRF_PARSEFUNC ) && tre->tr.szService != NULL ) + if (!( tre->tr.flags & TRF_PARSEFUNC ) && tre->tr.szService != NULL) mir_free( tre->tr.szService ); - if ( tre->tr.tszTokenString != NULL ) + if (tre->tr.tszTokenString != NULL) mir_free( tre->tr.tszTokenString ); - if ( tre->tr.szHelpText != NULL ) + if (tre->tr.szHelpText != NULL) mir_free( tre->tr.szHelpText ); - if (( tre->tr.flags & TRF_CLEANUP ) && !( tre->tr.flags & TRF_CLEANUPFUNC ) && tre->tr.szCleanupService != NULL ) + if (( tre->tr.flags & TRF_CLEANUP ) && !( tre->tr.flags & TRF_CLEANUPFUNC ) && tre->tr.szCleanupService != NULL) mir_free( tre->tr.szCleanupService ); mir_free( tre ); diff --git a/plugins/Variables/variables.cpp b/plugins/Variables/variables.cpp index 83e6bd34e0..7f8c97371b 100644 --- a/plugins/Variables/variables.cpp +++ b/plugins/Variables/variables.cpp @@ -73,7 +73,7 @@ TCHAR *getArguments(TCHAR *string, TCHAR ***aargv, int *aargc) { break; case _T(','): - if ( (!bDontParse) && (brackets == 0)) { + if ((!bDontParse) && (brackets == 0)) { bNewArg = TRUE; } break; @@ -85,10 +85,10 @@ TCHAR *getArguments(TCHAR *string, TCHAR ***aargv, int *aargc) { break; case _T(')'): - if ( (brackets == 0) && (!bDontParse)) { + if ((brackets == 0) && (!bDontParse)) { bDone = bNewArg = TRUE; } - else if ( (brackets > 0) && (!bDontParse)) { + else if ((brackets > 0) && (!bDontParse)) { brackets -= 1; } break; @@ -207,12 +207,12 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi) continue; } // remove end of lines - else if ( (!_tcsncmp(cur, _T("\r\n"), 2)) && (gParseOpts.bStripEOL)) { + else if ((!_tcsncmp(cur, _T("\r\n"), 2)) && (gParseOpts.bStripEOL)) { MoveMemory(cur, cur+2, (_tcslen(cur+2)+1)*sizeof(TCHAR)); pos = cur-string-1; continue; } - else if ( ((*cur == _T('\n')) && (gParseOpts.bStripEOL)) || ((*cur == _T(' ')) && (gParseOpts.bStripWS))) { + else if (((*cur == _T('\n')) && (gParseOpts.bStripEOL)) || ((*cur == _T(' ')) && (gParseOpts.bStripWS))) { MoveMemory(cur, cur+1, (_tcslen(cur+1)+1)*sizeof(TCHAR)); pos = cur - string - 1; continue; @@ -232,7 +232,7 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi) pos = scur-string-1; continue; } - else if ( (*cur != _T(FIELD_CHAR)) && (*cur != _T(FUNC_CHAR)) && (*cur != _T(FUNC_ONCE_CHAR))) { + else if ((*cur != _T(FIELD_CHAR)) && (*cur != _T(FUNC_CHAR)) && (*cur != _T(FUNC_ONCE_CHAR))) { if (gParseOpts.bStripAll) { MoveMemory(cur, cur+1, (_tcslen(cur+1)+1)*sizeof(TCHAR)); pos = cur - string - 1; @@ -283,12 +283,12 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi) } cur += len+1; } - else if ( (*cur == _T(FUNC_CHAR)) || (*cur == _T(FUNC_ONCE_CHAR))) { + else if ((*cur == _T(FUNC_CHAR)) || (*cur == _T(FUNC_ONCE_CHAR))) { TCHAR *argcur; cur += _tcslen(tr->tszTokenString)+1; argcur = getArguments(cur, &argv, &argc); - if ( (argcur == cur) || (argcur == NULL)) { + if ((argcur == cur) || (argcur == NULL)) { fi->eCount += 1; // error getting arguments continue; @@ -326,7 +326,7 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi) ai.argc = argc+1; ai.targv = pargv; ai.fi = fi; - if ( (*scur == _T(FUNC_ONCE_CHAR)) || (*scur == _T(FIELD_CHAR))) + if ((*scur == _T(FUNC_ONCE_CHAR)) || (*scur == _T(FIELD_CHAR))) ai.flags |= AIF_DONTPARSE; parsedToken = parseFromRegister(&ai); @@ -340,7 +340,7 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi) } //replaced a var - if ( ai.flags & AIF_FALSE ) + if (ai.flags & AIF_FALSE ) fi->eCount++; else fi->pCount++; @@ -387,17 +387,17 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi) pos--; // parse the same pos again, it changed - if ( tr == NULL ) + if (tr == NULL) parsedToken = NULL; // To avoid mir_free } if (parsedToken != NULL) mir_free(parsedToken); for ( i=0; i < argc; i++ ) - if ( argv[i] != NULL ) + if (argv[i] != NULL) mir_free( argv[i] ); - if ( argv != NULL ) + if (argv != NULL) mir_free(argv); return ( TCHAR* )mir_realloc(string, (_tcslen(string)+1)*sizeof(TCHAR)); @@ -556,7 +556,7 @@ int LoadVarModule() { HMODULE hUxTheme; - if ( (initTokenRegister() != 0) || (initContactModule() != 0)) { + if ((initTokenRegister() != 0) || (initContactModule() != 0)) { return -1; } diff --git a/plugins/helpers/gen_helpers.cpp b/plugins/helpers/gen_helpers.cpp index 2ac1b4212c..8a1ce0a922 100644 --- a/plugins/helpers/gen_helpers.cpp +++ b/plugins/helpers/gen_helpers.cpp @@ -30,7 +30,7 @@ int ProtoServiceExists(const char *szModule, const char *szService) { char *Hlp_GetProtocolNameA(const char *proto) { char protoname[256]; - if ( (!ProtoServiceExists(proto, PS_GETNAME)) || (CallProtoService(proto, PS_GETNAME, (WPARAM)sizeof(protoname), (LPARAM)protoname))) + if ((!ProtoServiceExists(proto, PS_GETNAME)) || (CallProtoService(proto, PS_GETNAME, (WPARAM)sizeof(protoname), (LPARAM)protoname))) return NULL; return mir_strdup(protoname); @@ -39,7 +39,7 @@ char *Hlp_GetProtocolNameA(const char *proto) { TCHAR *Hlp_GetProtocolName(const char *proto) { char protoname[256]; - if ( (!ProtoServiceExists(proto, PS_GETNAME)) || (CallProtoService(proto, PS_GETNAME, (WPARAM)sizeof(protoname), (LPARAM)protoname))) + if ((!ProtoServiceExists(proto, PS_GETNAME)) || (CallProtoService(proto, PS_GETNAME, (WPARAM)sizeof(protoname), (LPARAM)protoname))) return NULL; return mir_a2t(protoname); @@ -210,7 +210,7 @@ int AddErrorLogMessage(const TCHAR* fmt, ...) { // int ttoi(TCHAR *string) { - return ( string == NULL ) ? 0 : _ttoi( string ); + return ( string == NULL) ? 0 : _ttoi( string ); } TCHAR *itot(int num) { @@ -237,7 +237,7 @@ int Hlp_UnicodeCheck(char *szPluginName, BOOL bForce, const char *szModule) { if (!CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)sizeof(szVersionText), (LPARAM)szVersionText)) { ptr = strstr(szVersionText, "Unicode"); - if ( (ptr == NULL) && (!DBGetContactSettingByte(NULL, szModule, SETTING_NOENCODINGCHECK, 0))) { + if ((ptr == NULL) && (!DBGetContactSettingByte(NULL, szModule, SETTING_NOENCODINGCHECK, 0))) { if (bForce) { MessageBoxA(NULL, "You are running the ANSI version Miranda. Please use the ANSI build of this plugin.", szPluginName, MB_OK); -- cgit v1.2.3