Switch back to isspace for now. Have to read some utf8 stuff first. Feel free to fix it, though! will not do it in the near future...
Fix header order, ups never changed a libbe file before ;) thx Oliver. Add small optimization as pointed out by Ingo. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41093 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -14,14 +14,14 @@
|
||||
|
||||
/*! String class supporting common string operations. */
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#include <Debug.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <utf8_functions.h>
|
||||
|
||||
@@ -1970,22 +1970,20 @@ BString::Trim()
|
||||
const char* string = String();
|
||||
|
||||
// string is \0 terminated thus we don't need to check if we reached the end
|
||||
uint32 startCount = 0;
|
||||
while (iswspace(string[startCount]))
|
||||
int32 startCount = 0;
|
||||
while (isspace(string[startCount]))
|
||||
startCount++;
|
||||
|
||||
uint32 endCount = 0;
|
||||
while (endCount < originalLength - startCount
|
||||
&& iswspace(string[originalLength - endCount - 1])) {
|
||||
endCount++;
|
||||
}
|
||||
int32 endIndex = Length() - 1;
|
||||
while (endIndex >= startCount && isspace(string[endIndex]))
|
||||
endIndex--;
|
||||
|
||||
if (startCount == 0 && endCount == 0)
|
||||
if (startCount == 0 && endIndex == Length() - 1)
|
||||
return *this;
|
||||
|
||||
// We actually need to trim
|
||||
|
||||
ssize_t length = originalLength - startCount - endCount;
|
||||
ssize_t length = endIndex + 1 - startCount;
|
||||
ASSERT(length >= 0);
|
||||
if (startCount == 0 || length == 0) {
|
||||
_MakeWritable(length, true);
|
||||
|
||||
Reference in New Issue
Block a user