Fixed ReplaceSet().
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1889 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1135,12 +1135,21 @@ BString::ReplaceSet(const char *setOfChars, const char *with)
|
|||||||
if (with == NULL)
|
if (with == NULL)
|
||||||
return *this; //TODO: do something smart
|
return *this; //TODO: do something smart
|
||||||
|
|
||||||
int32 pos;
|
int32 pos, offset = 0;
|
||||||
int32 withLen = strlen(with);
|
int32 withLen = strlen(with);
|
||||||
while ((pos = strcspn(String(), setOfChars)) < Length()) {
|
|
||||||
|
while ((pos = strcspn(String() + offset, setOfChars)) < Length()) {
|
||||||
|
offset += pos;
|
||||||
|
if (offset >= Length())
|
||||||
|
break;
|
||||||
|
_OpenAtBy(offset, withLen - 1);
|
||||||
|
memcpy(_privateData + offset, with, withLen);
|
||||||
|
offset += withLen;
|
||||||
|
}
|
||||||
|
/*while ((pos = strcspn(String() + offset, setOfChars)) < Length()) {
|
||||||
_OpenAtBy(pos, withLen - 1);
|
_OpenAtBy(pos, withLen - 1);
|
||||||
memcpy(_privateData + pos, with, withLen);
|
memcpy(_privateData + pos, with, withLen);
|
||||||
}
|
}*/
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user