History log of /haiku/src/kits/support/String.cpp
Revision Date Author Comments
# bcd6a663 19-Sep-2021 Niels Sascha Reedijk <niels.reedijk@gmail.com>

BString: make move constructor and assignment noexcept

Change-Id: I87f5ecad22f46b59386a091a1bb502536f460315


# 530f89aa 09-Sep-2021 Niels Sascha Reedijk <niels.reedijk@gmail.com>

BString: rewrite cleanup methods

This removes the use of the destructor in the move assignment operator, as it
may rely on undefined behaviour from the compiler. Additionally, some duplicate
logic to dereference and free a shared string has been unified under
_ReleasePrivateData().

Change-Id: Ie9f51d598c734f83cd0fba49b651315c6e9c8aac
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4440
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 0b86520c 06-Sep-2021 Niels Sascha Reedijk <niels.reedijk@gmail.com>

BString: add support for move semantics with C++11 and up.

This implements the "rule of 5" for this type. While the copy operation for
BString was already using shallow copies of the underlying data, this change
further optimizes moving the data from one object to another.

While it is not the intention to implement move semantics to all types in the
legacy Haiku/Be kits, data types like BString are good candidates, because move
operations are often useful when working with data within an application.

In this implementation, the internal data of the string object will be set to
NULL, thus leaving an empty string.

Change-Id: I16bf9424f9b17f622b0b57659b80628e18760288
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4428
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# fbc30e91 31-Dec-2019 Kyle Ambroff-Kao <kyle@ambroffkao.com>

support/String: Revert 6c67c7d63 to fix double-free

6c67c7d63 was attempting to fix a leak caught by a static analysis
tool, but it actually just introduced a double-free bug. Running
`UnitTester BString` will result in a crash.

The original code was correct because, in the event that realloc()
fails in BString::_Resize(), the value of fPrivateData is still
retained. It will be freed by the destructor of BString only if
fPrivateData is not shared by another BString instance, since BStrings
are copy-on-write.

Note that while the change in 6c67c7d63 caused tests to fail, that
doesn't mean those tests are ideal. They only trigger
BString::_Resize() to fail because they depend on implementation
details of hoard2 which limits allocations via malloc() to
1GB. Most malloc() implementations will allow allocations of arbitrary
sizes using anonymous mappings (mmap on Linux, or create_area() in
Haiku). This is a much bigger change, so for now I'm just adding some
comments so that we can revisit these tests if we make a change to the
allocator.

Change-Id: I208c1c7a76b6b4409d237b911c62bb3198e49dab
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2060
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>


# 6c67c7d6 01-Feb-2019 Murai Takashi <tmurai01@gmail.com>

support/String: Fix PVS 626

Fix memory leak when realloc() fails.

Change-Id: I5b44df57bdd251e5164938ed70412c909ce09df1
Reviewed-on: https://review.haiku-os.org/c/1004
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 137ac199 18-Nov-2018 Murai Takashi <tmurai01@gmail.com>

String.cpp: Fix PVS 625

Fix 'newBuffer' is assigned values twice successively.

Change-Id: Id6ec9d40ba279a68e17922931098a6a908eb7156
Reviewed-on: https://review.haiku-os.org/728
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# f436972c 16-Sep-2018 Augustin Cavalier <waddlesplash@gmail.com>

BString: Treat NULL passed as replaceWith as an empty string.

Fixes the tests added in the previous commit, and also #8552.

Change-Id: Idf9459474bc66054f94cf66065ed6fcf9c60cece
Reviewed-on: https://review.haiku-os.org/572
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# a25f7264 22-Mar-2018 Jérôme Duval <jerome.duval@gmail.com>

BString: fix Split() for multiple characters separators...

as suggested by Janus in #14045. Thanks!
* add a unit test for BString::Split().


# cc04d41c 21-Feb-2017 John Scipione <jscipione@gmail.com>

BString: Use safestr() to prevent strlen(NULL)

on StartsWith(), IStartsWith(), EndsWith(), and IEndsWith()


# 388ac82b 05-Jan-2017 John Scipione <jscipione@gmail.com>

BString: Add IStartsWith() and IEndsWith() methods

Case-insensitive version of StartsWith() and EndsWith()


# bdd02e0d 12-Jan-2017 Adrien Destugues <pulkomandy@pulkomandy.tk>

BString: rename SetCharAt to SetByteAt

Makes it clear that it operates on bytes, not unicode codepoints.
Thanks to mmlr for remembering me of this subtlety.


# 0c5219a1 12-Jan-2017 Jérôme Duval <jerome.duval@gmail.com>

Restore missing symbol _ZN7BStringixEi on x86 and x86_64.

* Vision and others were broken after 3eac8208dfcd6bd73a534303414784d3754de855.
* this adds BStringRef in the backward compatibility section.
* fixes #13199.


# 3eac8208 09-Jan-2017 Adrien Destugues <pulkomandy@pulkomandy.tk>

Remove BStringRef and users.

As discussed in 2008
(http://www.freelists.org/post/haiku-development/BString-on-GCC4,1),
this class was not efficient because of lack of inlining. Implement the
suggested solution of a SetCharAt method instead. Also add a CompareAt
which covers a specific use case in KeyboardLayout.cpp.

Adjust all places which were using this feature to safer APIs.

Also fixes a copypaste error in FormattingConventions.cpp.


# 3fe7b3f7 02-Nov-2014 Michael Lotz <mmlr@mlotz.ch>

BString: Add ScanWithFormat convenience method.


# 3aeed660 07-Aug-2014 Jérôme Duval <jerome.duval@gmail.com>

include strings.h where appriopriate...

instead or additionally to string.h, in preparation for functions move.
* moves str[n]casecmp() functions and others to strings.h.
* strings.h doesn't include string.h anymore.
* this solves #10949


# 29e8fa59 24-Jun-2014 John Scipione <jscipione@gmail.com>

Style fixes to Support Kit files


# a0b864f0 07-Jun-2014 Jessica Hamilton <jessica.l.hamilton@gmail.com>

BString: fix possible infinite loop in _DoReplace


# 077c84eb 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: atomic_*() functions rework

* No need for the atomically changed variables to be declared as
volatile.
* Drop support for atomically getting and setting unaligned data.
* Introduce atomic_get_and_set[64]() which works the same as
atomic_set[64]() used to. atomic_set[64]() does not return the
previous value anymore.


# 1c521f0b 19-Sep-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BString::Split(): Fix check


# be3833c9 27-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BString: Add SetToFormatVarArgs()


# c82776b2 23-May-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BString: Add Split()


# 379131d9 08-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BString: Add StartsWith() and EndsWith() methods


# 820dca4d 06-Feb-2013 John Scipione <jscipione@gmail.com>

Big docs cleanup.

* Fixed headers including:
- All rights reserved not All Rights Reserved.
- name, email@domain.com not name <email@domain.com>
- tabs and spaces
- Authors: not Documented by:
* Renamed string.dox to String.dox
* Renamed midixxx.dox files to MidiXxx.dox
* Moved images into images subdirectories and updated Doxfile.
* Re-format all files with tabs instead of spaces.
* Fix many spelling mistakes.
* Added all files, classes, structs, and enums to libbe group.


# 11ff194b 27-Apr-2012 Fredrik Holmqvist <fredrik.holmqvist@gmail.com>

Use strnlen instead of own impl, as it probably will have platform specific optimisation.


# ad07ecd8 16-Jul-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

BString::Private class to access BString internals


# 156ea481 16-Jul-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add HashValue() methods to BString


# 04c60f44 23-Aug-2011 Oliver Tappe <zooey@hirschkaefer.de>

* fix stuck loops in Replace...() on single chars in case the old and new character
are the same (Eclipse was complaining about 'assignment to self', which got me
looking at the code ...)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42682 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d0c41784 16-Jul-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

BString::Private class to access BString internals


# 5a54e156 16-Jul-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add HashValue() methods to BString


# 85b41b15 07-Jul-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added bool and double BString::operator<<() versions.
* Removed the clashing operator in JobSetupDlg. Automatic whitespace
cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42387 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a928c3f0 13-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

operation <<(): Use the standard types [unsigned] long [long] instead of
[u]int32 and [u]int64 to avoid clashes with the int/unsigned int versions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42165 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8066fbc7 23-Mar-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

Remove semi unused variable.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41094 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9d214f41 23-Mar-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

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


# b5ddb507 22-Mar-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

Switch to iswspace. Fix space detection at the right. Thanks Jérôme and Ingo. Please review, though.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41084 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 37ffb53f 21-Mar-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

Fix Trim() method for empty strings and strings only containing spaces. Fixes #7392.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41076 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 146d274d 01-Mar-2011 Jonas Sundström <jonas@kirilla.com>

Return of the on-stack buffer.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40767 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a29fb938 01-Mar-2011 Jonas Sundström <jonas@kirilla.com>

Rename and a small simplification. Thanks, Clemens and Ingo.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40756 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3838fb93 27-Feb-2011 Jonas Sundström <jonas@kirilla.com>

Using the buffer of the string instead of one on the stack.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40726 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c9e27ada 27-Feb-2011 Jonas Sundström <jonas@kirilla.com>

Cleanup. Efficiency makerover.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40720 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c91c2de7 26-Feb-2011 Jonas Sundström <jonas@kirilla.com>

Printf-like assignment method for BString.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40695 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9f209e77 16-Feb-2011 Oliver Tappe <zooey@hirschkaefer.de>

Fix minor issue in BString I noticed when researching #7226:
* if _MakeWritable() fails, LockBuffer() must return NULL, not what
happens to be in fPrivateData

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40525 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8510499a 17-Nov-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed the FindLast() char versions. They wouldn't find a character at the
beginning of the string.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39470 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a9038d00 24-Feb-2010 Michael Lotz <mmlr@mlotz.ch>

The withLength variable wasn't initialized properly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35613 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a5b7cbe3 31-Jan-2010 Michael Lotz <mmlr@mlotz.ch>

Adding utf-8 aware version of most functions to BString. They are named after
the corresponding normal functions but have a "Chars" in the name like
"MoveCharsInto" or "AppendChars". Also added CountBytes() and CharAt().
This should make everyday string handling with multibyte strings a bit easier.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35371 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 534bebec 09-Jan-2010 Jérôme Duval <korli@users.berlios.de>

When BString assignment operator is called with a NULL argument we should use an empty string instead. I checked this against Dano.
This fixed #4713


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34983 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e90b90da 31-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Added desperately missing Trim() method.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32035 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1746066c 20-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Made _Allocate() static.
* Moved the private inline methods up in the source file, so they can actually
be inlined.
* UnlockBuffer(): Removed superfluous "if". Maybe the one who wrote it can have
a look and check whether something else was intended originally.
* _MakeWritable() (both versions): Removed the superfluous ref count increment
and the matching decrements.
* _Resize(): Fixed ref count ASSERT. It would always be triggered when called
from UnlockBuffer(), since the ref count is -1 in that case.
* Clarified some comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31662 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e52400cf 06-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed a race condition in the former _Detach*() functions: since atomic_get()
was used, two different threads could decide to share the same mutable string.
* Renamed some functions to make clearer what they do, ie. _Detach() is now
called _MakeWritable().
* Cleaned up some questionable semantics, like the const char* parameter in
_DetachWith() - you can now choose to copy the original string or not with
a boolean. This also makes sure that the string is actually copied when it
has to, which wasn't the case before (but that was no problem with the way
that function was used).
* Made the header compliant with our style guide.
* Further cleanup.
* All BString related unit tests are passed, so I guess I didn't break too
much :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30980 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 96b5480b 06-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Simplification.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30646 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f9745144 21-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

BString::Append(, int32) methods have been broken in r26378. A local
variable "length" shadowed the "length" parameter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26554 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2cbb2916 11-Jul-2008 Stephan Aßmus <superstippi@gmx.de>

* _DoAppend() no longer checks the string and the string length, which resulted
in duplicate work/checks. Instead the length is checked in the calling
functions.
* operator=(const char*) now checks if the passed pointer is the strings
own data pointer. I think it would have freed the memory before, not
sure though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26378 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e3f5e89 07-May-2008 François Revol <revol@free.fr>

Make the BString& version of SetTo() behave like BeOS, that length < 0 is means "until the end". This makes CopyInto() acting alike too. Note the char * version crashes in BeOS, instead we act like the other version for consistency.
There are many other calls that crash in BeOS when called with invalid args, should we attempt to sanitize them or call debugger() instead ?


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25372 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4b832620 10-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* _Realloc() did not initialize the reference count either.
* _Alloc() can now preserve the original reference count, only _Clone()
still initializes it to 1. As Karsten pointed out, this is necessary to
preserve the "shareable" status of the private data.
* I hope that's finally it. What happened to our testing suite, anyway? :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24355 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf4ddb61 10-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* As found by Karsten, the reference count was not initialized in
_ReplaceAtPositions(), and _DoCharacterEscape() (we don't need to preserve
it, though, as it must be 1).
* Factored out an _Alloc() method which is now always called when the private
data is allocated. It also takes care of correct initialization (and thus
fixes the above problem).
* This fix finally allows turning on reference counting again, thanks Karsten!
* Minor cleanup, renamed "oldAdr"/"newAdr" to "oldString", resp. "newString".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24348 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7c58a468 10-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

The result of some more proof-reading caused by Stephan's comments:
* _Realloc(), and _Detach[With]() may fail, but that wasn't accounted for
everywhere.
* The Append(), Prepend(), and Insert() char versions all caused their
backends to access invalid data (must use strncpy() instead of memcpy()
here).
* All Append(), Prepend(), and Insert() BString variants used an invalid
check, and would therefore just do nothing in certain situations like this
one:
BString a = "-";
BString b = a;
a.Append(b);


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24347 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 688c1426 10-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* After my last change, _IsShareable() was called on the wrong string in the
copy constructors, effectively turning of references completely.
* Since that caused troubles (NetPositive now crashes when started), I
temporarily disabled references by letting _IsShareable() always return
false until the issue is resolved.
* _FreePrivateData() now sets the fPrivateData member to NULL, and is also
safe to be called when fPrivateData is NULL.
* Removed my comment about the threading problem in _Detach() and _DetachWith()
as that just couldn't happen.
* _Clone() must not use memcpy() as the string pointed to by "data" might not
be as long as "length".
* LockBuffer() now marks a string as unshareable.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24345 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a1dac092 08-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

Followed suggestion by Stephan.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24314 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 002b33b7 08-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bunch or concurreny bugs and memory leaks of the new reference
string stuff.
* It's still not thread-safe for all usage patterns, though, so we might want
to remove or disable it: if a string is shared between several threads, and
one of those starts to use a reference, all kinds of problems can happen.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24312 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 576e2bf8 24-Feb-2008 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Patch by Julun: implements a refcounted BString. Thank You!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24102 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 43cca04a 06-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19731 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b506de7 01-Jan-2007 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Remove strange character... Apparently I left some junk.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19670 a95241bf-73f2-0310-859d-f6bbb57e9c96


# da738868 01-Jan-2007 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Fixed a bug where BString::FindLast(char,int32) might be fed an offset that was beyond the Length of the string.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19669 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1ea1a6b4 01-Jan-2007 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Remove all the user API comments. There are still some superfluous comments (the name of every function before every function), but the person that coded this class should decide which are superfluous and which aren't.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19668 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d274c6a5 15-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

Added non-const form of BString::operator<<(BString&) for backwards compatibility
(see bug #418).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17851 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e6a6424e 13-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Added a work-around to _Alloc() to allow R5 NetPositive to work on Haiku;
dunno if we want to keep this, though.
* Improved some methods by no longer calling strlen() more than once.
* We're now using snprintf() instead of sprintf() in the << operators to
make them more secure (even though the string lengths should be long
enough).
* Improved << operators by taking the return (the resulting string length) of
snprintf() into account.
* Replaced calls to _GrowBy() with a negative argument with calls to
_Alloc() which actually safes some computation.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16783 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 94a055c1 05-Mar-2006 Oliver Tappe <zooey@hirschkaefer.de>

* fixed broken FindLast() taking a char and an offset
* added two more tests that exhibit the (now fixed) problem in FindLast()



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16586 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c728a74e 06-Jul-2005 Michael Lotz <mmlr@mlotz.ch>

Cleanup. We don't need string_helper anymore as it's only function (strcasestr) is in libroot. It was a temporary solution more than two years ago.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13514 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ba8e3cf1 04-Jul-2004 Axel Dörfler <axeld@pinc-software.de>

Now exports B_EMPTY_STRING - maybe there is a better place for it, like
SupportDefs.cpp. Feel free to move it to a better place.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8302 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cd58ac99 16-Feb-2004 Axel Dörfler <axeld@pinc-software.de>

Minitiure optimizations for BString: eliminated a superfluous variable,
and removed the "newData" calculation, since "dataLen" already contained
the same value.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6613 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5480b459 13-Nov-2003 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Another patch from Oliver Tappe: BString behaves better when the user supplies out-of bounds values in Insert(), Remove(), etc.
Code is refactored, and it fully complies with our guidelines.
Tests have been updated too (hint: try the replace tests with R5 and our implementation...)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5348 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1783edd5 11-Feb-2003 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added a big patch from Oliver Tappe. BString now is much faster when it has to deal with very long strings. Thanks Oliver. Fixed the (in)famous LockBuffer(0)->UnlockBuffer(-1) R5 bug.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2686 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a8dee23e 10-Jan-2003 Stefano Ceccherini <stefano.ceccherini@gmail.com>

A fix for a Replace function, some checks which makes the code
more robust, some style changes, some more comments.
Started to document the class with Doxygen comments.
(I made too many changes to keep the file local :)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2399 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d546b00e 17-Nov-2002 ejakowatz <ejakowatz@nowhere.fake>

Undid the oh-so-1337 utf_char_len "optimization" (which is not only slower,
but doesn't handle invalid UTF-8 strings correctly) in CountChars().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2002 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 202ed890 14-Nov-2002 ejakowatz <ejakowatz@nowhere.fake>

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


# 5f6935dc 14-Nov-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed the build again. It seems that BGA Utf8_char_lenght() function really works :)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1939 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8f1a4e7f 14-Nov-2002 ejakowatz <ejakowatz@nowhere.fake>

Implemented BGA's UTF-8 char len suggestion in UTF8.h and used it in
BString::CountChars().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1932 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e0db3523 11-Nov-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some style changes, some bugfixes


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1903 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bff4272d 09-Nov-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed ReplaceSet().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1889 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d106184 07-Nov-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some cleanups (more to come)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1871 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 82e052e5 05-Nov-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed BString so it passes all the committed tests


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1854 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f68e12e5 29-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Tests are a developer's best friends :)) Fixed an incorrect implementation of the private function _FindAfter.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1762 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ba3487e3 28-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed a typing bug to make it compile again


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1751 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e0060f3f 28-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Implemented the last function (ReplaceSet()). Now it's just a matter
of doing tests for the remaining functions.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1734 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8109fda8 23-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some optimizations in FindFirst functions


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1633 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eae06be4 21-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Er... it seems I found some time to work on this :)))
Added the last two missing FindLast() functions


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1584 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 21b4758c 15-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some fixes, added the missing compare operators


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1532 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 73d1e1fe 12-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixes for bugs exposed by the tests


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1488 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a125bf5 11-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some fixes, added the missing operator[], switched to BeOS debug macros,
Implemented the missing Replace functions. Just ReplaceSet is missing
(tests coming)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1483 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 979b68a7 06-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed a stupid bug in BString::CharacterEscape() and committed the correct version of DataIO.cpp (the former was an incorrect version)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1429 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a971d340 06-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added Escaping/Deescaping. Fixed a bug in Inserting methods


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1405 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 16444b39 03-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added CapitalizeEachWord() (ugly implementation, maybe, but it works). This version passes all checked-in tests


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1357 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d9e38b87 01-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

More functions, more bug fixes.
Just Escaping/Deescaping and some Replacing functions missing


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1336 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53fd1e70 30-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

More BString functions. Constructors, CountChars() and operators "=" and "+=" are tested with cppunit and work fine.
Added string_helper.cpp and .h to compile String.cpp correctly. Those will be removed as soon as we have our working libc.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1313 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 39be953e 26-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed a stupid typing bug, implemented a pair of other functions


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1194 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7c64b6d7 26-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Implemented format-appending operators, more optimizations and bugfixes


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1191 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0155e3bd 23-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some small optimizations


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1126 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2ffca36a 17-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed a nasty bug in Append functions. A quick test with BeMamER shows that my BString implementation begin to work :)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1081 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 070e0673 11-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some new methods (Removing), some bug fixes, some optimisations.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1018 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8f86fcdc 10-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some bug fixes


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1008 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7c830dc4 09-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

More functions and bug fixes, and lot of code from Marc Flerackers


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1001 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a82280a 06-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Merged MallocIO.cpp with DataIO.cpp, some code refactoring,
and let a first, basic BString implementetation enter the game


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@988 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52a38012 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3fe7b3f72c545aae15ca08f85f5f5dad4c55817b 02-Nov-2014 Michael Lotz <mmlr@mlotz.ch>

BString: Add ScanWithFormat convenience method.


# 3aeed6607cd07762c0e709633c012b3a632dbad9 07-Aug-2014 Jérôme Duval <jerome.duval@gmail.com>

include strings.h where appriopriate...

instead or additionally to string.h, in preparation for functions move.
* moves str[n]casecmp() functions and others to strings.h.
* strings.h doesn't include string.h anymore.
* this solves #10949


# 29e8fa5922c9f9a5eb09a2fcc92e7fb321d4cc59 24-Jun-2014 John Scipione <jscipione@gmail.com>

Style fixes to Support Kit files


# a0b864f0e4c5e256375b7afdc8f0706c2c1158ee 07-Jun-2014 Jessica Hamilton <jessica.l.hamilton@gmail.com>

BString: fix possible infinite loop in _DoReplace


# 077c84eb27b25430428d356f3d13afabc0cc0d13 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: atomic_*() functions rework

* No need for the atomically changed variables to be declared as
volatile.
* Drop support for atomically getting and setting unaligned data.
* Introduce atomic_get_and_set[64]() which works the same as
atomic_set[64]() used to. atomic_set[64]() does not return the
previous value anymore.


# 1c521f0b311686a352b2f57aa12bd53dc5dbdced 19-Sep-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BString::Split(): Fix check


# be3833c9a41fbd09c1a4fa8c458f5cae5ff792ee 27-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BString: Add SetToFormatVarArgs()


# c82776b2fabe0e546e213495e53cef22a8afb6a6 23-May-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BString: Add Split()


# 379131d97d1bda4b50a0a384c36abd239783cc83 08-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BString: Add StartsWith() and EndsWith() methods


# 820dca4df6c7bf955c46e8f6521b9408f50b2900 06-Feb-2013 John Scipione <jscipione@gmail.com>

Big docs cleanup.

* Fixed headers including:
- All rights reserved not All Rights Reserved.
- name, email@domain.com not name <email@domain.com>
- tabs and spaces
- Authors: not Documented by:
* Renamed string.dox to String.dox
* Renamed midixxx.dox files to MidiXxx.dox
* Moved images into images subdirectories and updated Doxfile.
* Re-format all files with tabs instead of spaces.
* Fix many spelling mistakes.
* Added all files, classes, structs, and enums to libbe group.


# 11ff194b97c0772c72d9e4c5c08c8b1390d6e8e6 27-Apr-2012 Fredrik Holmqvist <fredrik.holmqvist@gmail.com>

Use strnlen instead of own impl, as it probably will have platform specific optimisation.


# ad07ecd82172564bbf3ecad2b9cdf6e7dd3747a6 16-Jul-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

BString::Private class to access BString internals


# 156ea481b3270fa156bf26c88b5cf571e97e7374 16-Jul-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add HashValue() methods to BString


# 04c60f4472a61b1a0e7b5e2add1de79d42b51c30 23-Aug-2011 Oliver Tappe <zooey@hirschkaefer.de>

* fix stuck loops in Replace...() on single chars in case the old and new character
are the same (Eclipse was complaining about 'assignment to self', which got me
looking at the code ...)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42682 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d0c417848b2a5b665578911e6acb3593bed8d0e8 16-Jul-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

BString::Private class to access BString internals


# 5a54e156e5b96ef240ce432a09f18dea364dcd47 16-Jul-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add HashValue() methods to BString


# 85b41b15d95ef86c0880faa6dcb0b35547328024 07-Jul-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added bool and double BString::operator<<() versions.
* Removed the clashing operator in JobSetupDlg. Automatic whitespace
cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42387 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a928c3f001e0919aa0f206ee35b60c6042861a20 13-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

operation <<(): Use the standard types [unsigned] long [long] instead of
[u]int32 and [u]int64 to avoid clashes with the int/unsigned int versions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42165 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8066fbc76694a099197153a83022c9e784decdcd 23-Mar-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

Remove semi unused variable.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41094 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9d214f419dfaa30b10296c12989b0e5d887f5d8f 23-Mar-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

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


# b5ddb5072e9a9f545adfc493e5395f6b8f2b1f1c 22-Mar-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

Switch to iswspace. Fix space detection at the right. Thanks Jérôme and Ingo. Please review, though.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41084 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 37ffb53fb4aac12c5e091b87bd5746b85d5a0b79 21-Mar-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

Fix Trim() method for empty strings and strings only containing spaces. Fixes #7392.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41076 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 146d274d81f795ef7189e0ade897e8f237bf403f 01-Mar-2011 Jonas Sundström <jonas@kirilla.com>

Return of the on-stack buffer.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40767 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a29fb9388d8f0fe48c526b6c582bcd02892f7ba9 01-Mar-2011 Jonas Sundström <jonas@kirilla.com>

Rename and a small simplification. Thanks, Clemens and Ingo.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40756 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3838fb9359a8b9895ba8b554ecdfb92f5ff02278 27-Feb-2011 Jonas Sundström <jonas@kirilla.com>

Using the buffer of the string instead of one on the stack.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40726 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c9e27adabfc36772dd8b8c2b32a4b9233f58e07a 27-Feb-2011 Jonas Sundström <jonas@kirilla.com>

Cleanup. Efficiency makerover.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40720 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c91c2de735e57aa5d3d775b234fa8f00447df56e 26-Feb-2011 Jonas Sundström <jonas@kirilla.com>

Printf-like assignment method for BString.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40695 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9f209e77b87c431e19a86c199bee726c85d682ae 16-Feb-2011 Oliver Tappe <zooey@hirschkaefer.de>

Fix minor issue in BString I noticed when researching #7226:
* if _MakeWritable() fails, LockBuffer() must return NULL, not what
happens to be in fPrivateData

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40525 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8510499a79cf1411034f1d104fe0875787cf565a 17-Nov-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed the FindLast() char versions. They wouldn't find a character at the
beginning of the string.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39470 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a9038d00b42d886bc9fec2582e57a433be58cb40 24-Feb-2010 Michael Lotz <mmlr@mlotz.ch>

The withLength variable wasn't initialized properly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35613 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a5b7cbe3318e316b14b06334c26800f46ac26f3d 31-Jan-2010 Michael Lotz <mmlr@mlotz.ch>

Adding utf-8 aware version of most functions to BString. They are named after
the corresponding normal functions but have a "Chars" in the name like
"MoveCharsInto" or "AppendChars". Also added CountBytes() and CharAt().
This should make everyday string handling with multibyte strings a bit easier.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35371 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 534bebec39c34e7c1ea20477b5abeaa9575a6269 09-Jan-2010 Jérôme Duval <korli@users.berlios.de>

When BString assignment operator is called with a NULL argument we should use an empty string instead. I checked this against Dano.
This fixed #4713


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34983 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e90b90daf6315ab2650ea947cfaa55f86e859591 31-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Added desperately missing Trim() method.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32035 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1746066cde0af657e63ce6ca99e2331c7c6216c5 20-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Made _Allocate() static.
* Moved the private inline methods up in the source file, so they can actually
be inlined.
* UnlockBuffer(): Removed superfluous "if". Maybe the one who wrote it can have
a look and check whether something else was intended originally.
* _MakeWritable() (both versions): Removed the superfluous ref count increment
and the matching decrements.
* _Resize(): Fixed ref count ASSERT. It would always be triggered when called
from UnlockBuffer(), since the ref count is -1 in that case.
* Clarified some comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31662 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e52400cf24d1a3c668a8f127e78b9e3226964cd0 06-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed a race condition in the former _Detach*() functions: since atomic_get()
was used, two different threads could decide to share the same mutable string.
* Renamed some functions to make clearer what they do, ie. _Detach() is now
called _MakeWritable().
* Cleaned up some questionable semantics, like the const char* parameter in
_DetachWith() - you can now choose to copy the original string or not with
a boolean. This also makes sure that the string is actually copied when it
has to, which wasn't the case before (but that was no problem with the way
that function was used).
* Made the header compliant with our style guide.
* Further cleanup.
* All BString related unit tests are passed, so I guess I didn't break too
much :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30980 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 96b5480b3fad98e69b922999285bf0d8ba1ec786 06-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Simplification.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30646 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f9745144763fc14e88b7f671ddd265fd81b7cb00 21-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

BString::Append(, int32) methods have been broken in r26378. A local
variable "length" shadowed the "length" parameter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26554 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2cbb2916a7812306317a79cb4dd9d0cfa083d15d 11-Jul-2008 Stephan Aßmus <superstippi@gmx.de>

* _DoAppend() no longer checks the string and the string length, which resulted
in duplicate work/checks. Instead the length is checked in the calling
functions.
* operator=(const char*) now checks if the passed pointer is the strings
own data pointer. I think it would have freed the memory before, not
sure though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26378 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e3f5e895985f70c5922879c0ee24f5bde64a698 07-May-2008 François Revol <revol@free.fr>

Make the BString& version of SetTo() behave like BeOS, that length < 0 is means "until the end". This makes CopyInto() acting alike too. Note the char * version crashes in BeOS, instead we act like the other version for consistency.
There are many other calls that crash in BeOS when called with invalid args, should we attempt to sanitize them or call debugger() instead ?


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25372 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4b83262008f3f368f2b4dd19b65a2552efa6f136 10-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* _Realloc() did not initialize the reference count either.
* _Alloc() can now preserve the original reference count, only _Clone()
still initializes it to 1. As Karsten pointed out, this is necessary to
preserve the "shareable" status of the private data.
* I hope that's finally it. What happened to our testing suite, anyway? :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24355 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf4ddb61e1d7e76bb4ac2c1c809ab007c7588d14 10-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* As found by Karsten, the reference count was not initialized in
_ReplaceAtPositions(), and _DoCharacterEscape() (we don't need to preserve
it, though, as it must be 1).
* Factored out an _Alloc() method which is now always called when the private
data is allocated. It also takes care of correct initialization (and thus
fixes the above problem).
* This fix finally allows turning on reference counting again, thanks Karsten!
* Minor cleanup, renamed "oldAdr"/"newAdr" to "oldString", resp. "newString".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24348 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7c58a46830ee7161885e83edbee3b1537a269389 10-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

The result of some more proof-reading caused by Stephan's comments:
* _Realloc(), and _Detach[With]() may fail, but that wasn't accounted for
everywhere.
* The Append(), Prepend(), and Insert() char versions all caused their
backends to access invalid data (must use strncpy() instead of memcpy()
here).
* All Append(), Prepend(), and Insert() BString variants used an invalid
check, and would therefore just do nothing in certain situations like this
one:
BString a = "-";
BString b = a;
a.Append(b);


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24347 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 688c14266c074ca6507884d55ca07260bc54a2b3 10-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* After my last change, _IsShareable() was called on the wrong string in the
copy constructors, effectively turning of references completely.
* Since that caused troubles (NetPositive now crashes when started), I
temporarily disabled references by letting _IsShareable() always return
false until the issue is resolved.
* _FreePrivateData() now sets the fPrivateData member to NULL, and is also
safe to be called when fPrivateData is NULL.
* Removed my comment about the threading problem in _Detach() and _DetachWith()
as that just couldn't happen.
* _Clone() must not use memcpy() as the string pointed to by "data" might not
be as long as "length".
* LockBuffer() now marks a string as unshareable.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24345 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a1dac092faebcf14e5bed82346f978e32b369672 08-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

Followed suggestion by Stephan.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24314 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 002b33b7200207e2d72b35499e34675ee69de713 08-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bunch or concurreny bugs and memory leaks of the new reference
string stuff.
* It's still not thread-safe for all usage patterns, though, so we might want
to remove or disable it: if a string is shared between several threads, and
one of those starts to use a reference, all kinds of problems can happen.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24312 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 576e2bf833a58f8948eca3fc65fdf7c10f2cfbc6 24-Feb-2008 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Patch by Julun: implements a refcounted BString. Thank You!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24102 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 43cca04a9a7d68c5510667a0bc7eab0322a66cb2 06-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19731 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b506de747485790c4406dd2d8da3a36448aa9c1 01-Jan-2007 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Remove strange character... Apparently I left some junk.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19670 a95241bf-73f2-0310-859d-f6bbb57e9c96


# da738868ba5d2ba4b41faf271ad162747da73116 01-Jan-2007 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Fixed a bug where BString::FindLast(char,int32) might be fed an offset that was beyond the Length of the string.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19669 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1ea1a6b46e89e3651ee0cd2a38b3fff850a16dea 01-Jan-2007 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Remove all the user API comments. There are still some superfluous comments (the name of every function before every function), but the person that coded this class should decide which are superfluous and which aren't.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19668 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d274c6a5978c206fb01f1798172b8dd3d7a10fbb 15-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

Added non-const form of BString::operator<<(BString&) for backwards compatibility
(see bug #418).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17851 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e6a6424e1c440345e5765388634ecfe9f2ca6dd1 13-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Added a work-around to _Alloc() to allow R5 NetPositive to work on Haiku;
dunno if we want to keep this, though.
* Improved some methods by no longer calling strlen() more than once.
* We're now using snprintf() instead of sprintf() in the << operators to
make them more secure (even though the string lengths should be long
enough).
* Improved << operators by taking the return (the resulting string length) of
snprintf() into account.
* Replaced calls to _GrowBy() with a negative argument with calls to
_Alloc() which actually safes some computation.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16783 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 94a055c10d7d2ebe5a45b68914a963da39dfb39b 05-Mar-2006 Oliver Tappe <zooey@hirschkaefer.de>

* fixed broken FindLast() taking a char and an offset
* added two more tests that exhibit the (now fixed) problem in FindLast()



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16586 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c728a74e429cde07ec49368f6a7d3b198dc611fc 06-Jul-2005 Michael Lotz <mmlr@mlotz.ch>

Cleanup. We don't need string_helper anymore as it's only function (strcasestr) is in libroot. It was a temporary solution more than two years ago.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13514 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ba8e3cf1e406a17fd3124004a87165b24c137903 04-Jul-2004 Axel Dörfler <axeld@pinc-software.de>

Now exports B_EMPTY_STRING - maybe there is a better place for it, like
SupportDefs.cpp. Feel free to move it to a better place.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8302 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cd58ac99684738eec50365a04a0d88f8145ef46a 16-Feb-2004 Axel Dörfler <axeld@pinc-software.de>

Minitiure optimizations for BString: eliminated a superfluous variable,
and removed the "newData" calculation, since "dataLen" already contained
the same value.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6613 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5480b4590e267957b90b79736b3990ddd39459a3 13-Nov-2003 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Another patch from Oliver Tappe: BString behaves better when the user supplies out-of bounds values in Insert(), Remove(), etc.
Code is refactored, and it fully complies with our guidelines.
Tests have been updated too (hint: try the replace tests with R5 and our implementation...)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5348 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1783edd55c5853b04b278c699cdfe569289dbffb 11-Feb-2003 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added a big patch from Oliver Tappe. BString now is much faster when it has to deal with very long strings. Thanks Oliver. Fixed the (in)famous LockBuffer(0)->UnlockBuffer(-1) R5 bug.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2686 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a8dee23ea037bca91d23eee891ac5757cf143e73 10-Jan-2003 Stefano Ceccherini <stefano.ceccherini@gmail.com>

A fix for a Replace function, some checks which makes the code
more robust, some style changes, some more comments.
Started to document the class with Doxygen comments.
(I made too many changes to keep the file local :)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2399 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d546b00e22c046cb4e52654322989840139a3c63 17-Nov-2002 ejakowatz <ejakowatz@nowhere.fake>

Undid the oh-so-1337 utf_char_len "optimization" (which is not only slower,
but doesn't handle invalid UTF-8 strings correctly) in CountChars().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2002 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 202ed890a9bd848fb660ea9c4adead33e76aa53e 14-Nov-2002 ejakowatz <ejakowatz@nowhere.fake>

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


# 5f6935dc8cb697f455728e42fa31567703fef7f3 14-Nov-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed the build again. It seems that BGA Utf8_char_lenght() function really works :)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1939 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8f1a4e7f895edfed9bca8b83b288cb0f362caea5 14-Nov-2002 ejakowatz <ejakowatz@nowhere.fake>

Implemented BGA's UTF-8 char len suggestion in UTF8.h and used it in
BString::CountChars().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1932 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e0db3523fcb88f5bffbdef5455a999aa73f5df03 11-Nov-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some style changes, some bugfixes


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1903 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bff4272dd4799e997ed0b7c5aefa43ac239b1a98 09-Nov-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed ReplaceSet().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1889 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d106184616040a18babe3aa5587f498ab0e34ed 07-Nov-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some cleanups (more to come)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1871 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 82e052e5a3b56c09ebc3e74e20a8e4a7c6ac9bb5 05-Nov-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed BString so it passes all the committed tests


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1854 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f68e12e5ede925cdc1e3ecdeed02cd7c37ecff80 29-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Tests are a developer's best friends :)) Fixed an incorrect implementation of the private function _FindAfter.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1762 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ba3487e33ab1ce410f7683440ec04f74b0f38b81 28-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed a typing bug to make it compile again


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1751 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e0060f3ff2b431fb53b1138acc1f1d5bd916aef4 28-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Implemented the last function (ReplaceSet()). Now it's just a matter
of doing tests for the remaining functions.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1734 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8109fda8d29087b08b5fc83c69fc1837c3402305 23-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some optimizations in FindFirst functions


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1633 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eae06be4659eaf52615eac776963f8a208083e90 21-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Er... it seems I found some time to work on this :)))
Added the last two missing FindLast() functions


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1584 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 21b4758ca88cd54615c16afeaaf62eb2d3c37a05 15-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some fixes, added the missing compare operators


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1532 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 73d1e1fe5e585b5f18ead7475b1ee6a05619fe26 12-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixes for bugs exposed by the tests


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1488 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a125bf5e03e3d34ea29d2fa9fb2da8e4f98de6c 11-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some fixes, added the missing operator[], switched to BeOS debug macros,
Implemented the missing Replace functions. Just ReplaceSet is missing
(tests coming)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1483 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 979b68a75bfb10d2df2167191df7e8e6dc692ba7 06-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed a stupid bug in BString::CharacterEscape() and committed the correct version of DataIO.cpp (the former was an incorrect version)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1429 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a971d340bba661464aee0c60a7a580d721c7bb1d 06-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added Escaping/Deescaping. Fixed a bug in Inserting methods


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1405 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 16444b397135cebda39e4395b32e04ecdae4a485 03-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added CapitalizeEachWord() (ugly implementation, maybe, but it works). This version passes all checked-in tests


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1357 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d9e38b8715f9327042a616506338d31138b3b514 01-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

More functions, more bug fixes.
Just Escaping/Deescaping and some Replacing functions missing


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1336 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53fd1e70a4692a2c61864e4b241ab057c265f60c 30-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

More BString functions. Constructors, CountChars() and operators "=" and "+=" are tested with cppunit and work fine.
Added string_helper.cpp and .h to compile String.cpp correctly. Those will be removed as soon as we have our working libc.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1313 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 39be953e7a0297bcc89e97502c99261b1de640f8 26-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed a stupid typing bug, implemented a pair of other functions


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1194 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7c64b6d7d54bde006eaaeb5b41024b980571b38c 26-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Implemented format-appending operators, more optimizations and bugfixes


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1191 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0155e3bd85e2304de85a9ac58a8e3d42451df237 23-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some small optimizations


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1126 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2ffca36a92656e8e3ef2ec67b6c7fdd461ca6c96 17-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed a nasty bug in Append functions. A quick test with BeMamER shows that my BString implementation begin to work :)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1081 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 070e0673326f608827a0ee791d3523b099715e98 11-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some new methods (Removing), some bug fixes, some optimisations.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1018 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8f86fcdc82f91b0e313eed4ebecf49f77f5a9f01 10-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Some bug fixes


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1008 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7c830dc497920adc8c5f833f7f9eee8eb6590d0a 09-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

More functions and bug fixes, and lot of code from Marc Flerackers


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1001 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a82280a11ed5cf42df9c25b5db122eb66fecde4 06-Sep-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Merged MallocIO.cpp with DataIO.cpp, some code refactoring,
and let a first, basic BString implementetation enter the game


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@988 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52a380120846174213ccce9c4aab0dda17c72083 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96