diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2010-11-29 21:50:29 +0100 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2010-11-29 21:50:29 +0100 |
commit | 977c77aa085b10e48505c861f5d47b3e881170e2 (patch) | |
tree | 985647f8f00798d7e2e499305b66d222242e6b40 /lib/String.cc | |
parent | 0fd6cb126b6238d2cbc01bed12ff043f45039c76 (diff) | |
parent | c99762a8980e691bab478f67b56b3fde56694e86 (diff) |
Merge branch 'master' of /pub/repo.git/Baltisot
Diffstat (limited to 'lib/String.cc')
-rw-r--r-- | lib/String.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/String.cc b/lib/String.cc index 14195f6..47315b6 100644 --- a/lib/String.cc +++ b/lib/String.cc @@ -276,8 +276,10 @@ String String::extract(size_t from, ssize_t to) const { char * String::strdup(size_t from, ssize_t to) const { char * r; - r = Base::strdup(to_charp(from, to)); - + r = Base::strdup(to_charp(from, -1)); + to -= from; + if ((to >= 0) && (to < (siz - from))) + r[to + 1] = 0; return r; } @@ -386,9 +388,10 @@ const char & String::operator[](size_t i) const { } char & String::operator[](size_t i) throw (GeneralException) { - + static char zero; if (i >= siz) { - throw GeneralException("operator[] on String out of bounds"); + zero = 0; + return zero; } else { return str[i]; } |