diff options
author | Max Kellermann <max@duempel.org> | 2014-08-07 14:44:31 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-07 16:08:02 +0200 |
commit | f860a2fbd693cc9ce166cdba7491cdd5071ca34a (patch) | |
tree | 8295f561439bd87b1d8d39a356a93afa1fee4bd7 /src/util/StringUtil.cxx | |
parent | 87bcf739ee6a3e8ac5b400b35b61b72b9d8bd802 (diff) | |
download | mpd-f860a2fbd693cc9ce166cdba7491cdd5071ca34a.tar.gz mpd-f860a2fbd693cc9ce166cdba7491cdd5071ca34a.tar.xz mpd-f860a2fbd693cc9ce166cdba7491cdd5071ca34a.zip |
util/StringUtil: move code to StripRight()
Diffstat (limited to '')
-rw-r--r-- | src/util/StringUtil.cxx | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/util/StringUtil.cxx b/src/util/StringUtil.cxx index 153846e9b..e68c98444 100644 --- a/src/util/StringUtil.cxx +++ b/src/util/StringUtil.cxx @@ -35,17 +35,28 @@ StripLeft(const char *p) return p; } -char * -Strip(char *p) +size_t +StripRight(const char *p, size_t length) { - p = StripLeft(p); - - size_t length = strlen(p); while (length > 0 && IsWhitespaceNotNull(p[length - 1])) --length; - p[length] = 0; + return length; +} + +void +StripRight(char *p) +{ + size_t old_length = strlen(p); + size_t new_length = StripRight(p, old_length); + p[new_length] = 0; +} +char * +Strip(char *p) +{ + p = StripLeft(p); + StripRight(p); return p; } |