From bff4272dd4799e997ed0b7c5aefa43ac239b1a98 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 9 Nov 2002 11:51:18 +0000 Subject: [PATCH] Fixed ReplaceSet(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1889 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/support/String.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/kits/support/String.cpp b/src/kits/support/String.cpp index 8cb90784d0..0610708bbd 100644 --- a/src/kits/support/String.cpp +++ b/src/kits/support/String.cpp @@ -1135,12 +1135,21 @@ BString::ReplaceSet(const char *setOfChars, const char *with) if (with == NULL) return *this; //TODO: do something smart - int32 pos; + int32 pos, offset = 0; 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); memcpy(_privateData + pos, with, withLen); - } + }*/ return *this; }