Fixed appending a (substring of a) string to itself
svn-id: r41337
This commit is contained in:
parent
6d59856fe1
commit
a5ff6cc19d
1 changed files with 6 additions and 0 deletions
|
@ -264,6 +264,9 @@ String& String::operator =(char c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
String &String::operator +=(const char *str) {
|
String &String::operator +=(const char *str) {
|
||||||
|
if (_str <= str && str <= _str + _size)
|
||||||
|
return operator+=(Common::String(str));
|
||||||
|
|
||||||
int len = strlen(str);
|
int len = strlen(str);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
ensureCapacity(_size + len, true);
|
ensureCapacity(_size + len, true);
|
||||||
|
@ -275,6 +278,9 @@ String &String::operator +=(const char *str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
String &String::operator +=(const String &str) {
|
String &String::operator +=(const String &str) {
|
||||||
|
if (&str == this)
|
||||||
|
return operator+=(Common::String(str));
|
||||||
|
|
||||||
int len = str._size;
|
int len = str._size;
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
ensureCapacity(_size + len, true);
|
ensureCapacity(_size + len, true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue