aboutsummaryrefslogtreecommitdiff
path: root/common/str.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2013-07-04 08:44:49 -0400
committerPaul Gilbert2013-07-04 08:44:49 -0400
commitfa737fd5af3763a152e92c4b74c114876b3a8573 (patch)
tree3e698f9c095ba692c6e305b35785a8f45f5e061b /common/str.cpp
parenta49a7d5ad4f4435ed8cee0934c94155586f2dd99 (diff)
parentbaafae672f3489b0eaf77c22be0c65ba31e6b73d (diff)
downloadscummvm-rg350-fa737fd5af3763a152e92c4b74c114876b3a8573.tar.gz
scummvm-rg350-fa737fd5af3763a152e92c4b74c114876b3a8573.tar.bz2
scummvm-rg350-fa737fd5af3763a152e92c4b74c114876b3a8573.zip
Merge branch 'master' into tsage_r2r
Diffstat (limited to 'common/str.cpp')
-rw-r--r--common/str.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/str.cpp b/common/str.cpp
index 5d647ee4f0..4a10792373 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -361,6 +361,25 @@ void String::deleteChar(uint32 p) {
_size--;
}
+void String::erase(uint32 p, uint32 len) {
+ assert(p < _size);
+
+ makeUnique();
+ // If len == npos or p + len is over the end, remove all the way to the end
+ if (len == npos || p + len >= _size) {
+ // Delete char at p as well. So _size = (p - 1) + 1
+ _size = p;
+ // Null terminate
+ _str[_size] = 0;
+ return;
+ }
+
+ for ( ; p + len <= _size; p++) {
+ _str[p] = _str[p + len];
+ }
+ _size -= len;
+}
+
void String::clear() {
decRefCount(_extern._refCount);