diff --git a/src/Config.cpp b/src/Config.cpp index 9726021c..7e7c1906 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -107,9 +107,7 @@ bool CConfig::Parse(CFile& file, CString& sErrorMsg) sTag.Trim(); sValue.Trim(); - if (sTag.Left(1) == "/") { - sTag = sTag.substr(1); - + if (sTag.TrimPrefix("/")) { if (!sValue.empty()) ERROR("Malformated closing tag. Expected \"\"."); if (ConfigStack.empty()) @@ -153,8 +151,7 @@ bool CConfig::Parse(CFile& file, CString& sErrorMsg) // Only remove the first space, people might want // leading spaces (e.g. in the MOTD). - if (sValue.Left(1) == " ") - sValue.LeftChomp(); + sValue.TrimPrefix(" "); // We don't have any names with spaces, trim all // leading/trailing spaces. diff --git a/src/IRCNetwork.cpp b/src/IRCNetwork.cpp index a2f65e73..c5ed38c8 100644 --- a/src/IRCNetwork.cpp +++ b/src/IRCNetwork.cpp @@ -1055,9 +1055,8 @@ bool CIRCNetwork::AddServer(const CString& sName) { CString sHost = sLine.Token(0); CString sPort = sLine.Token(1); - if (sPort.Left(1) == "+") { + if (sPort.TrimPrefix("+")) { bSSL = true; - sPort.LeftChomp(); } unsigned short uPort = sPort.ToUShort(); diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index c97b8feb..faebf354 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -638,9 +638,7 @@ void CIRCSock::ReadLine(const CString& sData) { } } else if (sCmd.Equals("MODE")) { CString sTarget = sRest.Token(0); - CString sModes = sRest.Token(1, true); - if (sModes.Left(1) == ":") - sModes = sModes.substr(1); + CString sModes = sRest.Token(1, true).TrimPrefix_n(":"); CChan* pChan = m_pNetwork->FindChan(sTarget); if (pChan) { diff --git a/src/Template.cpp b/src/Template.cpp index dd77ea36..bc9ce186 100644 --- a/src/Template.cpp +++ b/src/Template.cpp @@ -695,9 +695,8 @@ bool CTemplate::ValidExpr(const CString& sExpression) { CString sName; CString sValue; - if (sExpr.Left(1) == "!") { + if (sExpr.TrimPrefix("!")) { bNegate = true; - sExpr.LeftChomp(); } if (sExpr.find("!=") != CString::npos) { @@ -810,8 +809,7 @@ CString CTemplate::GetValue(const CString& sArgs, bool bFromIf) { return sRet; } } else { - if (sName.Left(1) == "*") { - sName.LeftChomp(1); + if (sName.TrimPrefix("*")) { MCString::iterator it = find(sName); sName = (it != end()) ? it->second : ""; } diff --git a/src/znc.cpp b/src/znc.cpp index 90b7b731..4d3f092d 100644 --- a/src/znc.cpp +++ b/src/znc.cpp @@ -1547,8 +1547,7 @@ bool CZNC::AddListener(const CString& sLine, CString& sError) { sPort = sValue; } - if (sPort.Left(1) == "+") { - sPort.LeftChomp(); + if (sPort.TrimPrefix("+")) { bSSL = true; }