mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Added Replace_n() and fixed internal loop bug in Replace() (thanks psycho for finding it)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@595 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -366,13 +366,19 @@ unsigned int CString::Replace(const CString& sReplace, const CString& sWith) {
|
||||
return CString::Replace(*this, sReplace, sWith);
|
||||
}
|
||||
|
||||
CString CString::Replace_n(const CString& sReplace, const CString& sWith) const {
|
||||
CString sRet(*this);
|
||||
sRet.Replace(sReplace, sWith);
|
||||
return sRet;
|
||||
}
|
||||
|
||||
unsigned int CString::Replace(CString& sStr, const CString& sReplace, const CString& sWith) {
|
||||
unsigned int uRet = 0;
|
||||
size_type uPos = sStr.find(sReplace);
|
||||
|
||||
while (uPos != npos) {
|
||||
sStr.replace(uPos, sReplace.length(), sWith);
|
||||
uPos = sStr.find(sReplace);
|
||||
uPos = sStr.find(sReplace, uPos + sReplace.length() +1);
|
||||
uRet++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user