From 7dd6bccfac4b8307af1d012b326370acb99035ed Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 1 Nov 2002 20:48:36 +0000 Subject: [PATCH] fix --- stepmania/src/RageUtil.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index 8262886ad6..5749e454c7 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -774,9 +774,11 @@ void TrimLeft(string &str, const char *s) void TrimRight(string &str, const char *s) { - int n = str.size()-1; - while(n >= 0 && strchr(s, str[n-1])) + int n = str.size(); + while(n > 0 && strchr(s, str[n-1])) n--; + /* Delete from n to the end. If n == str.size(), nothing is deleted; + * if n == 0, the whole string is erased. */ str.erase(str.begin()+n, str.end()); }