diff --git a/IRCSock.cpp b/IRCSock.cpp index fdfc3f0f..fbe2480d 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -258,7 +258,7 @@ void CIRCSock::ReadLine(const CString& sData) { break; } case 324: { // MODE - CUtils::Trim(sRest); + sRest.Trim(); CChan* pChan = m_pUser->FindChan(sRest.Token(0)); if (pChan) { @@ -267,7 +267,7 @@ void CIRCSock::ReadLine(const CString& sData) { } break; case 353: { // NAMES - CUtils::Trim(sRest); + sRest.Trim(); // Todo: allow for non @+= server msgs CChan* pChan = m_pUser->FindChan(sRest.Token(1)); if (pChan) { diff --git a/String.cpp b/String.cpp index ba2aef07..ee9b5544 100644 --- a/String.cpp +++ b/String.cpp @@ -123,7 +123,7 @@ bool CString::Trim(const CString& s) { bool CString::LeftTrim(const CString& s) { bool bRet = false; - while ((Left(1) == " ") || (Left(1) == "\t") || (Left(1) == "\r") || (Left(1) == "\n")) { + while (s.find(Left(1)) != CString::npos) { LeftChomp(); bRet = true; } @@ -134,7 +134,7 @@ bool CString::LeftTrim(const CString& s) { bool CString::RightTrim(const CString& s) { bool bRet = false; - while ((Right(1) == " ") || (Right(1) == "\t") || (Right(1) == "\r") || (Right(1) == "\n")) { + while (s.find(Right(1)) != CString::npos) { RightChomp(); bRet = true; } diff --git a/User.cpp b/User.cpp index 05958bdb..9803ebdc 100644 --- a/User.cpp +++ b/User.cpp @@ -194,7 +194,7 @@ bool CUser::AddServer(const CString& sName) { bool bSSL = false; CString sLine = sName; - CUtils::Trim(sLine); + sLine.Trim(); CString sHost = sLine.Token(0); CString sPort = sLine.Token(1); diff --git a/Utils.cpp b/Utils.cpp index c22cdebb..45781fd3 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -392,18 +392,6 @@ CString CUtils::ToKBytes(double d) { return szRet; } -CString& CUtils::Trim(CString& s) { - while ((s.Right(1) == " ") || (s.Right(1) == "\t") || (s.Right(1) == "\r") || (s.Right(1) == "\n")) { - s.RightChomp(); - } - - while ((s.Left(1) == " ") || (s.Left(1) == "\t") || (s.Left(1) == "\r") || (s.Left(1) == "\n")) { - s.LeftChomp(); - } - - return s; -} - bool CUtils::wildcmp(const CString& sWild, const CString& sString) { // Written by Jack Handy - jakkhandy@hotmail.com const char *wild = sWild.c_str(), *CString = sString.c_str(); diff --git a/Utils.h b/Utils.h index f1e8a4a1..c978d0c6 100644 --- a/Utils.h +++ b/Utils.h @@ -54,7 +54,6 @@ public: static CString ToPercent(double d); static CString ToKBytes(double d); - static CString& Trim(CString& s); static bool wildcmp(const CString& sWild, const CString& sString); static unsigned long long GetMillTime() { diff --git a/main.cpp b/main.cpp index 43ebb029..b93ead5a 100644 --- a/main.cpp +++ b/main.cpp @@ -65,6 +65,7 @@ int main(int argc, char** argv) { if (iOptIndex >= 0) { CString sOption = Lower(g_LongOpts[iOptIndex].name); if (sOption == "version") { + cout << "---[" << CString(" test ").RightTrim() << "]" << endl; cout << CZNC::GetTag() << endl; return 0; } else if (sOption == "makepass") { diff --git a/modules/away.cpp b/modules/away.cpp index 44226289..76c8572d 100644 --- a/modules/away.cpp +++ b/modules/away.cpp @@ -20,6 +20,9 @@ * * * $Log$ + * Revision 1.11 2005/05/08 04:30:13 prozacx + * Moved CUtils::Trim() into CString class + * * Revision 1.10 2005/05/07 09:18:49 prozacx * Moved CUtils::Token() into CString class * @@ -131,7 +134,7 @@ public: u_int iPos = 0; while( ReadLine( sFile, sLine, iPos ) ) { - CUtils::Trim( sLine ); + sLine.Trim(); AddMessage( sLine ); } } else @@ -314,7 +317,7 @@ public: if ( pTime ) { sTime = pTime; - CUtils::Trim( sTime ); + sTime.Trim(); } if ( m_sReason.empty() ) m_sReason = "away :Auto Away at " + sTime; diff --git a/modules/email.cpp b/modules/email.cpp index ed1ae6d0..3a1f1c2e 100644 --- a/modules/email.cpp +++ b/modules/email.cpp @@ -15,6 +15,9 @@ * Author: imaginos * * $Log$ + * Revision 1.6 2005/05/08 04:30:14 prozacx + * Moved CUtils::Trim() into CString class + * * Revision 1.5 2005/05/07 09:43:26 prozacx * Moved CUtils::Ellipsize() into CString class * @@ -207,7 +210,7 @@ public: u_int iPos = 0; while( ::ReadLine( m_sMailBuffer, sLine, iPos ) ) { - CUtils::Trim( sLine ); + sLine.Trim(); if ( sLine.empty() ) break; // out of the headers diff --git a/modules/savebuff.cpp b/modules/savebuff.cpp index 127c5fe1..e3b22127 100644 --- a/modules/savebuff.cpp +++ b/modules/savebuff.cpp @@ -26,6 +26,9 @@ * better solution then plain text. * * $Log$ + * Revision 1.20 2005/05/08 04:30:14 prozacx + * Moved CUtils::Trim() into CString class + * * Revision 1.19 2005/05/05 18:11:04 prozacx * Changed all references to std::string over to CString * @@ -177,7 +180,7 @@ public: u_int iPos = 0; while( ReadLine( sFile, sLine, iPos ) ) { - CUtils::Trim( sLine ); + sLine.Trim(); pChan->AddBuffer( sLine ); } } else @@ -258,7 +261,7 @@ public: u_int iPos = 0; while( ReadLine( sFile, sLine, iPos ) ) { - CUtils::Trim( sLine ); + sLine.Trim(); PutModule( "[" + sLine + "]" ); } } @@ -273,7 +276,7 @@ public: u_int iPos = 0; while( ReadLine( sFile, sLine, iPos ) ) { - CUtils::Trim( sLine ); + sLine.Trim(); PutUser( sLine ); } } diff --git a/modules/schat.cpp b/modules/schat.cpp index 7c12ed70..17348952 100644 --- a/modules/schat.cpp +++ b/modules/schat.cpp @@ -16,6 +16,9 @@ * Author: imaginos * * $Log$ + * Revision 1.11 2005/05/08 04:30:14 prozacx + * Moved CUtils::Trim() into CString class + * * Revision 1.10 2005/05/07 09:18:56 prozacx * Moved CUtils::Token() into CString class * @@ -300,7 +303,7 @@ public: if ( pTime ) { CString sTime = pTime; - CUtils::Trim( sTime ); + sTime.Trim(); Table.SetCell( "Created", sTime ); } @@ -368,7 +371,7 @@ public: if ( pTime ) { CString sTime = pTime; - CUtils::Trim( sTime ); + sTime.Trim(); Table.SetCell( "Created", sTime ); } diff --git a/znc.cpp b/znc.cpp index ddd4a1a9..0bd510fd 100644 --- a/znc.cpp +++ b/znc.cpp @@ -449,7 +449,7 @@ bool CZNC::ParseConfig(const CString& sConfig) { while (File.ReadLine(sLine)) { while ((sLine.Right(1) == "\r") || (sLine.Right(1) == "\n")) { - CUtils::Trim(sLine); + sLine.Trim(); } if ((sLine.empty()) || (sLine[0] == '#') || (sLine.Left(2) == "//")) { @@ -480,8 +480,8 @@ bool CZNC::ParseConfig(const CString& sConfig) { CString sTag = sLine.substr(0, sLine.find_first_of(" \t\r\n")); CString sValue = (sTag.size() < sLine.size()) ? sLine.substr(sTag.size() +1) : ""; - CUtils::Trim(sTag); - CUtils::Trim(sValue); + sTag.Trim(); + sValue.Trim(); if (sLine.Left(1) == "/") { CString sTag = sLine.substr(1); @@ -554,8 +554,8 @@ bool CZNC::ParseConfig(const CString& sConfig) { // If we have a regular line, figure out where it goes CString sName = sLine.Token(0, false, '='); CString sValue = sLine.Token(1, true, '='); - CUtils::Trim(sName); - CUtils::Trim(sValue); + sName.Trim(); + sValue.Trim(); if ((!sName.empty()) && (!sValue.empty())) { if (pUser) {