From 0bc6905beb27cee9e288e6680e4ce6a85bcfd8e8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 15 Nov 2017 13:41:50 +0300 Subject: IRC: more code cleaning --- protocols/IRCG/src/commandmonitor.cpp | 40 +++++++++++++++++------------------ protocols/IRCG/src/input.cpp | 18 ++++++++-------- protocols/IRCG/src/irclib.cpp | 20 +++++++++--------- protocols/IRCG/src/options.cpp | 14 ++++++------ protocols/IRCG/src/output.cpp | 8 +++---- protocols/IRCG/src/services.cpp | 2 +- protocols/IRCG/src/tools.cpp | 22 +++++++++---------- protocols/IRCG/src/windows.cpp | 16 +++++++------- 8 files changed, 70 insertions(+), 70 deletions(-) (limited to 'protocols/IRCG') diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index 5601a07dfc..6694c24698 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -431,7 +431,7 @@ bool CIrcProto::OnIrc_MODEQUERY(const CIrcMessage* pmsg) int iParametercount = 3; LPCTSTR p1 = pmsg->parameters[2]; - while (*p1 != '\0') { + while (*p1 != 0) { if (*p1 == '+') bAdd = true; if (*p1 == '-') @@ -469,7 +469,7 @@ bool CIrcProto::OnIrc_MODE(const CIrcMessage* pmsg) int iParametercount = 2; LPCTSTR p1 = pmsg->parameters[1]; - while (*p1 != '\0') { + while (*p1 != 0) { if (*p1 == '+') { bAdd = true; sModes += L"+"; @@ -902,13 +902,13 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg) // if all characters are number it indicates we have found the adress, port and size parameters int ind = 0; - while (sTemp[ind] != '\0') { + while (sTemp[ind] != 0) { if (!iswdigit(sTemp[ind])) break; ind++; } - if (sTemp[ind] == '\0' && GetWord(mess, index + ((bIsChat) ? 1 : 2)).IsEmpty()) + if (sTemp[ind] == 0 && GetWord(mess, index + ((bIsChat) ? 1 : 2)).IsEmpty()) bFlag = true; index++; } @@ -921,7 +921,7 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg) if (p2 > p1) { p2--; while (p2 != p1 && *p2 == ' ') { - *p2 = '\0'; + *p2 = 0; p2--; } sFile = p1; @@ -970,13 +970,13 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg) // if all characters are number it indicates we have found the adress, port and size parameters int ind = 0; - while (sTemp[ind] != '\0') { + while (sTemp[ind] != 0) { if (!iswdigit(sTemp[ind])) break; ind++; } - if (sTemp[ind] == '\0' && GetWord(mess, index + 2).IsEmpty()) + if (sTemp[ind] == 0 && GetWord(mess, index + 2).IsEmpty()) bFlag = true; index++; } @@ -987,7 +987,7 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg) if (p2 > p1) { p2--; while (p2 != p1 && *p2 == ' ') { - *p2 = '\0'; + *p2 = 0; p2--; } sFile = p1; @@ -1006,7 +1006,7 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg) // 2. Check for malformed dcc commands or other errors if (bIsChat || type == L"send") { wchar_t szTemp[256]; - szTemp[0] = '\0'; + szTemp[0] = 0; unsigned long ulAdr = 0; if (m_manualHost) @@ -1040,7 +1040,7 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg) } else if (type == L"accept" || type == L"resume") { wchar_t szTemp[256]; - szTemp[0] = '\0'; + szTemp[0] = 0; if (type == L"resume" && !m_DCCFileEnabled) mir_snwprintf(szTemp, TranslateT("DCC: File transfer resume request from %s denied"), pmsg->prefix.sNick.c_str()); @@ -1183,7 +1183,7 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg) // handle incoming ctcp in notices. This technique is used for replying to CTCP queries else if (pmsg->sCommand == L"NOTICE") { wchar_t szTemp[300]; - szTemp[0] = '\0'; + szTemp[0] = 0; //if we got incoming CTCP Version for contact in CList - then write its as MirVer for that contact! if (pmsg->m_bIncoming && command == L"version") { @@ -1494,7 +1494,7 @@ bool CIrcProto::OnIrc_LIST(const CIrcMessage* pmsg) temp = wcsstr(temp, L"]"); if (mir_wstrlen(temp) > 1) { temp++; - temp[0] = '\0'; + temp[0] = 0; lvItem.iSubItem = 2; lvItem.pszText = save; ListView_SetItem(hListView, &lvItem); @@ -2044,15 +2044,15 @@ bool CIrcProto::OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg) // Pull out host, user and nick wchar_t *p2 = wcschr(p1, '@'); if (p2) { - *p2 = '\0'; + *p2 = 0; p2++; host = p2; } p2 = wcschr(p1, '='); if (p2) { if (*(p2 - 1) == '*') - *(p2 - 1) = '\0'; // remove special char for IRCOps - *p2 = '\0'; + *(p2 - 1) = 0; // remove special char for IRCOps + *p2 = 0; p2++; awaystatus = *p2; p2++; @@ -2188,7 +2188,7 @@ bool CIrcProto::OnIrc_SUPPORT(const CIrcMessage* pmsg) sUserModes = (char*)_T2A(p1); sUserModes = sUserModes.Mid(0, p2 - p1); p2++; - if (*p2 != '\0') + if (*p2 != 0) sUserModePrefixes = p2; } else { @@ -2208,8 +2208,8 @@ bool CIrcProto::OnIrc_SUPPORT(const CIrcMessage* pmsg) sUserModes.SetAt(n, 'a'); else if (sUserModePrefixes[n] == '*') sUserModes.SetAt(n, 'q'); - else if (sUserModePrefixes[n] == '\0') - sUserModes.SetAt(n, '\0'); + else if (sUserModePrefixes[n] == 0) + sUserModes.SetAt(n, 0); else sUserModes.SetAt(n, '_'); } @@ -2237,7 +2237,7 @@ void CIrcProto::OnIrcDisconnected() bTempForceCheck = false; m_iTempCheckTime = 0; - m_myHost[0] = '\0'; + m_myHost[0] = 0; int Temp = m_iStatus; KillIdent(); @@ -2408,7 +2408,7 @@ bool CIrcProto::AddIgnore(const wchar_t* mask, const wchar_t* flags, const wchar bool CIrcProto::RemoveIgnore(const wchar_t* mask) { int idx; - while ((idx = IsIgnored(mask, '\0')) != 0) + while ((idx = IsIgnored(mask, 0)) != 0) m_ignoreItems.remove(idx - 1); RewriteIgnoreSettings(); diff --git a/protocols/IRCG/src/input.cpp b/protocols/IRCG/src/input.cpp index 6d0e79c5bf..8b7bec22e7 100644 --- a/protocols/IRCG/src/input.cpp +++ b/protocols/IRCG/src/input.cpp @@ -80,7 +80,7 @@ CMStringW CIrcProto::DoAlias(const wchar_t *text, wchar_t *window) bool LinebreakFlag = false, hasAlias = false; p2 = wcsstr(p1, L"\r\n"); if (!p2) - p2 = wcschr(p1, '\0'); + p2 = wcschr(p1, 0); if (p1 == p2) return (CMStringW)text; @@ -112,7 +112,7 @@ CMStringW CIrcProto::DoAlias(const wchar_t *text, wchar_t *window) hasAlias = true; const wchar_t* p4 = wcsstr(p3, L"\r\n"); if (!p4) - p4 = wcschr(p3, '\0'); + p4 = wcschr(p3, 0); *(wchar_t*)p4 = 0; CMStringW str = p3; @@ -149,11 +149,11 @@ CMStringW CIrcProto::DoAlias(const wchar_t *text, wchar_t *window) p1 += 2; p2 = wcsstr(p1, L"\r\n"); if (!p2) - p2 = wcschr(p1, '\0'); + p2 = wcschr(p1, 0); delete[] line; LinebreakFlag = true; } - while (*p1 != '\0'); + while (*p1 != 0); return hasAlias ? DoIdentifiers(Messageout, window) : Messageout; } @@ -178,7 +178,7 @@ CMStringW CIrcProto::DoIdentifiers(CMStringW text, const wchar_t*) text.Replace(L"%mirver", _A2T(mirver)); text.Replace(L"%version", _A2T(__VERSION_STRING_DOTS)); - str[0] = 3; str[1] = '\0'; + str[0] = 3; str[1] = 0; text.Replace(L"%color", str); str[0] = 2; @@ -732,21 +732,21 @@ static void __stdcall DoInputRequestAliasApcStub(void* _par) infotext = &p[11]; p = wcschr(infotext, '\"'); if (p) { - *p = '\0'; + *p = 0; p++; if (*p == ',' && p[1] == '\"') { p++; p++; title = p; p = wcschr(title, '\"'); if (p) { - *p = '\0'; + *p = 0; p++; if (*p == ',' && p[1] == '\"') { p++; p++; defaulttext = p; p = wcschr(defaulttext, '\"'); if (p) - *p = '\0'; + *p = 0; } } } @@ -815,7 +815,7 @@ bool CIrcProto::PostIrcMessageWnd(wchar_t *window, MCONTACT hContact, const wcha if (mir_wstrcmpi(window, SERVERWINDOW) != 0) { wchar_t* p1 = wcschr(windowname, ' '); if (p1) - *p1 = '\0'; + *p1 = 0; } // remove unecessary linebreaks, and do the aliases diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp index c0be7a3e87..94f736affa 100644 --- a/protocols/IRCG/src/irclib.cpp +++ b/protocols/IRCG/src/irclib.cpp @@ -377,7 +377,7 @@ void CIrcProto::DoReceive() break; cbInBuf += cbRead; - chBuf[cbInBuf] = '\0'; + chBuf[cbInBuf] = 0; char* pStart = chBuf; while (*pStart) { @@ -386,14 +386,14 @@ void CIrcProto::DoReceive() // seek end-of-line for (pEnd = pStart; *pEnd && *pEnd != '\r' && *pEnd != '\n'; ++pEnd) ; - if (*pEnd == '\0') + if (*pEnd == 0) break; // uncomplete message. stop parsing. ++nLinesProcessed; // replace end-of-line with NULLs and skip while (*pEnd == '\r' || *pEnd == '\n') - *pEnd++ = '\0'; + *pEnd++ = 0; // process single message by monitor objects if (*pStart) { @@ -403,9 +403,9 @@ void CIrcProto::DoReceive() if (pszTemp) { char* p1 = pszTemp; // replace end-of-line with NULLs - while (*p1 != '\0') { + while (*p1 != 0) { if (*p1 == '\r' || *p1 == '\n') - *p1 = '\0'; + *p1 = 0; p1++; } @@ -1307,7 +1307,7 @@ void CDccSession::DoChatReceive() break; cbInBuf += cbRead; - chBuf[cbInBuf] = '\0'; + chBuf[cbInBuf] = 0; char* pStart = chBuf; while (*pStart) { @@ -1316,14 +1316,14 @@ void CDccSession::DoChatReceive() // seek end-of-line for (pEnd = pStart; *pEnd && *pEnd != '\r' && *pEnd != '\n'; ++pEnd) ; - if (*pEnd == '\0') + if (*pEnd == 0) break; // uncomplete message. stop parsing. ++nLinesProcessed; // replace end-of-line with NULLs and skip while (*pEnd == '\r' || *pEnd == '\n') - *pEnd++ = '\0'; + *pEnd++ = 0; if (*pStart) { // send it off to some messaging module @@ -1396,14 +1396,14 @@ void DoIdent(HNETLIBCONN hConnection, DWORD, void* extra) break; cbTotal += cbRead; - szBuf[cbTotal] = '\0'; + szBuf[cbTotal] = 0; LBL_Parse: char* EOLPos = strstr(szBuf, "\r\n"); if (EOLPos == nullptr) continue; - EOLPos[0] = EOLPos[1] = '\0'; + EOLPos[0] = EOLPos[1] = 0; rtrim(szBuf); ppro->debugLogA("Got Ident request: %s", szBuf); diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index 49e3049c9e..1d93bf88bb 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -152,7 +152,7 @@ static int sttServerEnum( const char* szSetting, LPARAM ) } p1 = strchr(p2, ':') + 1; - p2 = strchr(p1, '\0'); + p2 = strchr(p1, 0); pData->m_group = (char*)mir_alloc(p2 - p1 + 1); mir_strncpy(pData->m_group, p1, p2 - p1 + 1); @@ -949,7 +949,7 @@ static LRESULT CALLBACK EditSubclassProc(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_CHAR: if (wParam == 21 || wParam == 11 || wParam == 2) { char w[2]; - w[1] = '\0'; + w[1] = 0; if (wParam == 11) w[0] = 3; if (wParam == 2) @@ -1318,18 +1318,18 @@ void CIrcProto::InitIgnore(void) char* pszIgnoreData = IrcLoadFile(szLoadFileName); if (pszIgnoreData != nullptr) { char *p1 = pszIgnoreData; - while (*p1 != '\0') { + while (*p1 != 0) { while (*p1 == '\r' || *p1 == '\n') p1++; - if (*p1 == '\0') + if (*p1 == 0) break; char* p2 = strstr(p1, "\r\n"); if (!p2) - p2 = strchr(p1, '\0'); + p2 = strchr(p1, 0); char* pTemp = p2; - while (pTemp > p1 && (*pTemp == '\r' || *pTemp == '\n' || *pTemp == '\0' || *pTemp == ' ')) + while (pTemp > p1 && (*pTemp == '\r' || *pTemp == '\n' || *pTemp == 0 || *pTemp == ' ')) pTemp--; *++pTemp = 0; @@ -1701,7 +1701,7 @@ void CIrcProto::InitPrefs(void) m_alias = mir_wstrdup(L"/op /mode ## +ooo $1 $2 $3\r\n/dop /mode ## -ooo $1 $2 $3\r\n/voice /mode ## +vvv $1 $2 $3\r\n/dvoice /mode ## -vvv $1 $2 $3\r\n/j /join #$1 $2-\r\n/p /part ## $1-\r\n/w /whois $1\r\n/k /kick ## $1 $2-\r\n/q /query $1\r\n/logon /log on ##\r\n/logoff /log off ##\r\n/save /log buffer $1\r\n/slap /me slaps $1 around a bit with a large trout"); m_quickComboSelection = getDword("QuickComboSelection", m_serverComboSelection + 1); - m_myHost[0] = '\0'; + m_myHost[0] = 0; colors[0] = RGB(255, 255, 255); colors[1] = RGB(0, 0, 0); diff --git a/protocols/IRCG/src/output.cpp b/protocols/IRCG/src/output.cpp index a1a95b346c..49958b1fd9 100644 --- a/protocols/IRCG/src/output.cpp +++ b/protocols/IRCG/src/output.cpp @@ -27,7 +27,7 @@ static CMStringW FormatOutput(const CIrcMessage* pmsg) if (pmsg->m_bIncoming) { // Is it an incoming message? if (pmsg->sCommand == L"WALLOPS" && pmsg->parameters.getCount() > 0) { - wchar_t temp[200]; *temp = '\0'; + wchar_t temp[200]; *temp = 0; mir_snwprintf(temp, TranslateT("WallOps from %s: "), pmsg->prefix.sNick.c_str()); sMessage = temp; for (int i = 0; i < (int)pmsg->parameters.getCount(); i++) { @@ -39,7 +39,7 @@ static CMStringW FormatOutput(const CIrcMessage* pmsg) } if (pmsg->sCommand == L"INVITE" && pmsg->parameters.getCount() > 1) { - wchar_t temp[256]; *temp = '\0'; + wchar_t temp[256]; *temp = 0; mir_snwprintf(temp, TranslateT("%s invites you to %s"), pmsg->prefix.sNick.c_str(), pmsg->parameters[1].c_str()); sMessage = temp; for (int i = 2; i < (int)pmsg->parameters.getCount(); i++) { @@ -52,7 +52,7 @@ static CMStringW FormatOutput(const CIrcMessage* pmsg) int index = _wtoi(pmsg->sCommand.c_str()); if (index == 301 && pmsg->parameters.getCount() > 0) { - wchar_t temp[500]; *temp = '\0'; + wchar_t temp[500]; *temp = 0; mir_snwprintf(temp, TranslateT("%s is away"), pmsg->parameters[1].c_str()); sMessage = temp; for (int i = 2; i < (int)pmsg->parameters.getCount(); i++) { @@ -80,7 +80,7 @@ static CMStringW FormatOutput(const CIrcMessage* pmsg) return pmsg->parameters[2] + L": " + pmsg->parameters[1]; } else if (pmsg->sCommand == L"NOTICE" && pmsg->parameters.getCount() > 1) { - wchar_t temp[500]; *temp = '\0'; + wchar_t temp[500]; *temp = 0; int l = pmsg->parameters[1].GetLength(); if (l > 3 && pmsg->parameters[1][0] == 1 && pmsg->parameters[1][l - 1] == 1) { diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp index 00bb276d8a..c6ed1fb46c 100644 --- a/protocols/IRCG/src/services.cpp +++ b/protocols/IRCG/src/services.cpp @@ -481,7 +481,7 @@ int __cdecl CIrcProto::GCEventHook(WPARAM, LPARAM lParam) wchar_t *p1 = mir_wstrdup(gch->ptszID); wchar_t *p2 = wcsstr(p1, L" - "); if (p2) - *p2 = '\0'; + *p2 = 0; switch (gch->iType) { case GC_SESSION_TERMINATE: diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp index a174921927..96434c7150 100644 --- a/protocols/IRCG/src/tools.cpp +++ b/protocols/IRCG/src/tools.cpp @@ -58,11 +58,11 @@ CMStringW __stdcall GetWord(const wchar_t* text, int index) while (*p1 == ' ') p1++; - if (*p1 != '\0') { + if (*p1 != 0) { for (int i = 0; i < index; i++) { p2 = wcschr(p1, ' '); if (!p2) - p2 = wcschr(p1, '\0'); + p2 = wcschr(p1, 0); else while (*p2 == ' ') p2++; @@ -72,7 +72,7 @@ CMStringW __stdcall GetWord(const wchar_t* text, int index) p2 = wcschr(p1, ' '); if (!p2) - p2 = wcschr(p1, '\0'); + p2 = wcschr(p1, 0); if (p1 != p2) return CMStringW(p1, p2 - p1); @@ -98,7 +98,7 @@ const wchar_t* __stdcall GetWordAddress(const wchar_t* text, int index) for (int i = 0; i < index; i++) { temp = wcschr(temp, ' '); if (!temp) - temp = (wchar_t*)wcschr(text, '\0'); + temp = (wchar_t*)wcschr(text, 0); else while (*temp == ' ') temp++; @@ -131,7 +131,7 @@ char* __stdcall IrcLoadFile(wchar_t* szPath) fseek(hFile, 0, SEEK_SET); // seek back to original pos szContainer = new char[dwSiz + 1]; fread(szContainer, 1, dwSiz, hFile); - szContainer[dwSiz] = '\0'; + szContainer[dwSiz] = 0; fclose(hFile); return szContainer; } @@ -191,11 +191,11 @@ CMStringA __stdcall GetWord(const char* text, int index) while (*p1 == ' ') p1++; - if (*p1 != '\0') { + if (*p1 != 0) { for (int i = 0; i < index; i++) { p2 = strchr(p1, ' '); if (!p2) - p2 = strchr(p1, '\0'); + p2 = strchr(p1, 0); else while (*p2 == ' ') p2++; @@ -205,7 +205,7 @@ CMStringA __stdcall GetWord(const char* text, int index) p2 = strchr(p1, ' '); if (!p2) - p2 = strchr(p1, '\0'); + p2 = strchr(p1, 0); if (p1 != p2) return CMStringA(p1, p2 - p1 + 1); @@ -254,7 +254,7 @@ static const wchar_t* DoEnterNumber(const wchar_t *text, int &res) wchar_t* __stdcall DoColorCodes(const wchar_t *text, bool bStrip, bool bReplacePercent) { - static wchar_t szTemp[4000]; szTemp[0] = '\0'; + static wchar_t szTemp[4000]; szTemp[0] = 0; wchar_t* p = szTemp; bool bBold = false; bool bUnderline = false; @@ -264,7 +264,7 @@ wchar_t* __stdcall DoColorCodes(const wchar_t *text, bool bStrip, bool bReplaceP if (!text) return szTemp; - while (*text != '\0') { + while (*text != 0) { switch (*text) { case '%': // escape *p++ = '%'; @@ -354,7 +354,7 @@ wchar_t* __stdcall DoColorCodes(const wchar_t *text, bool bStrip, bool bReplaceP } } - *p = '\0'; + *p = 0; return szTemp; } diff --git a/protocols/IRCG/src/windows.cpp b/protocols/IRCG/src/windows.cpp index 9b91719ad3..4dc846af9b 100644 --- a/protocols/IRCG/src/windows.cpp +++ b/protocols/IRCG/src/windows.cpp @@ -746,14 +746,14 @@ void CQuestionDlg::OnOk(CCtrlButton*) if (p2) { p2++; if (k == 2 || (*p2 != ',' || (*p2 == ',' && p2[1] != '\"'))) - *p2 = '\0'; + *p2 = 0; else p2 += 2; p1 = p2; } } } - else *p1 = '\0'; + else *p1 = 0; } CMStringW S('\0', j + 2); @@ -843,15 +843,15 @@ LRESULT CALLBACK MgrEditSubclassProc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARA char w[2]; if (wParam == 11) { w[0] = 3; - w[1] = '\0'; + w[1] = 0; } if (wParam == 2) { w[0] = 2; - w[1] = '\0'; + w[1] = 0; } if (wParam == 21) { w[0] = 31; - w[1] = '\0'; + w[1] = 0; } SendMessage(m_hwnd, EM_REPLACESEL, false, (LPARAM)w); SendMessage(m_hwnd, EM_SCROLLCARET, 0, 0); @@ -1081,8 +1081,8 @@ void CManagerDlg::OnApplyModes(CCtrlButton*) GetDlgItemText(m_hwnd, IDC_CAPTION, window, _countof(window)); CHANNELINFO *wi = (CHANNELINFO*)Chat_GetUserInfo(m_proto->m_szModuleName, window); if (wi) { - wchar_t toadd[10]; *toadd = '\0'; - wchar_t toremove[10]; *toremove = '\0'; + wchar_t toadd[10]; *toadd = 0; + wchar_t toremove[10]; *toremove = 0; CMStringW appendixadd = L""; CMStringW appendixremove = L""; if (wi->pszMode && wcschr(wi->pszMode, 't')) { @@ -1308,7 +1308,7 @@ void CManagerDlg::InitManager(int mode, const wchar_t* window) bool add = false; wchar_t* p1 = wi->pszMode; if (p1) { - while (*p1 != '\0' && *p1 != ' ') { + while (*p1 != 0 && *p1 != ' ') { if (*p1 == '+') add = true; if (*p1 == '-') -- cgit v1.2.3