Some bug fixing on BString and it's unit tests. Should now pass all

current tests!  Now included in the build.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1946 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
ejakowatz
2002-11-15 03:36:17 +00:00
parent 8f3cf68703
commit 202ed890a9
4 changed files with 79 additions and 55 deletions
+15 -6
View File
@@ -86,17 +86,24 @@ int32
BString::CountChars() const
{
int32 count = 0;
char *ptr = _privateData;
if (ptr == NULL)
return 0;
const char *ptr = String();
while (*ptr)
{
// Jump to next UTF8 character
// ejaesler: BGA's nifty function
ptr += utf8_char_len(*ptr);
count++;
}
#if 0
while (*ptr++)
{
count++;
// Jump to next UTF8 character
for (; (*ptr & 0xc0) == 0x80; ptr++);
}
#endif
return count;
}
@@ -1503,7 +1510,9 @@ BString::_GrowBy(int32 size)
ASSERT(curLen + size >= 0);
if (_privateData != NULL)
{
_privateData -= sizeof(int32);
}
_privateData = (char*)realloc(_privateData,
curLen + size + sizeof(int32) + 1);
@@ -1517,7 +1526,7 @@ BString::_GrowBy(int32 size)
}
char*
char *
BString::_OpenAtBy(int32 offset, int32 length)
{
ASSERT(offset >= 0);