diff options
author | Pixel <pixel@nobis-crew.org> | 2011-10-18 08:59:58 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2011-10-18 08:59:58 -0700 |
commit | 56837535aeb1c7ae0fa2730d77dd718c334cf729 (patch) | |
tree | 12ac2be529bb633dd7a49c917f0601bd60f5c3b1 /src | |
parent | ea271d967c52892a61f2b2db754780912e0f7cef (diff) |
And so kids, this is why we have unit tests.
Diffstat (limited to 'src')
-rw-r--r-- | src/BString.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/BString.cc b/src/BString.cc index 74d033e..262a9fa 100644 --- a/src/BString.cc +++ b/src/BString.cc @@ -48,16 +48,19 @@ Balau::String & Balau::String::do_ltrim() { } Balau::String & Balau::String::do_rtrim() { - unsigned int l = length(), p = l; + unsigned int i, l = length(), p = l; const char * buffer = data(); - for (unsigned int i = l - 1; i >= 0; i--) + for (i = l - 1; i > 0; i--) if (isspace(buffer[i])) p--; else break; - erase(p); + if ((i == 0) && isspace(buffer[0])) + assign("", 0); + else + erase(p); return *this; } |