Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork130
Fixed string::replace doesn't replace multiple occurrences of longer string with shorter one#200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -234,10 +234,10 @@ void String::move(String &rhs) | ||
String & String::operator = (const String &rhs) | ||
{ | ||
if (this == &rhs) return *this; | ||
if (rhs.buffer) copy(rhs.buffer, rhs.len); | ||
else invalidate(); | ||
return *this; | ||
} | ||
@@ -253,7 +253,7 @@ String & String::operator = (const char *cstr) | ||
{ | ||
if (cstr) copy(cstr, strlen(cstr)); | ||
else invalidate(); | ||
return *this; | ||
} | ||
@@ -484,7 +484,7 @@ bool String::equalsIgnoreCase( const String &s2 ) const | ||
const char *p2 = s2.buffer; | ||
while (*p1) { | ||
if (tolower(*p1++) != tolower(*p2++)) return false; | ||
} | ||
return true; | ||
} | ||
@@ -515,7 +515,7 @@ char String::charAt(unsigned int loc) const | ||
return operator[](loc); | ||
} | ||
void String::setCharAt(unsigned int loc, char c) | ||
{ | ||
if (loc < len) buffer[loc] = c; | ||
} | ||
@@ -652,9 +652,9 @@ void String::replace(const String& find, const String& replace) | ||
} | ||
} else if (diff < 0) { | ||
unsigned int size = len; // compute size needed for result | ||
diff = 0 - diff; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Ah, this line hurts 😉 . (Could it not be | ||
while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { | ||
readFrom = foundAt + find.len; | ||
size -= diff; | ||
} | ||
if (size == len) return; | ||