util/StringUtil: add StripRight() overload with "end" argument

This commit is contained in:
Max Kellermann
2014-08-07 15:15:56 +02:00
parent 5c5c6a965c
commit 59d38f876a
6 changed files with 50 additions and 18 deletions

View File

@@ -22,7 +22,7 @@
#include "Partition.hxx"
#include "Instance.hxx"
#include "event/Loop.hxx"
#include "util/CharUtil.hxx"
#include "util/StringUtil.hxx"
#include <string.h>
@@ -39,11 +39,10 @@ Client::OnSocketInput(void *data, size_t length)
BufferedSocket::ConsumeInput(newline + 1 - p);
/* skip whitespace at the end of the line */
while (newline > p && IsWhitespaceFast(newline[-1]))
--newline;
char *end = StripRight(p, newline);
/* terminate the string at the end of the line */
*newline = 0;
*end = 0;
CommandResult result = client_process_line(*this, p);
switch (result) {