From 5c5c6a965cc3af4c8e725c7c9cc377e80f728279 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Thu, 7 Aug 2014 15:36:03 +0200
Subject: [PATCH] LogBackend: use StripRight()

Eliminate duplicate code.
---
 Makefile.am        | 3 +++
 src/LogBackend.cxx | 8 ++------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 212d198cf..038b8db9b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1796,6 +1796,7 @@ test_run_avahi_CPPFLAGS = $(AM_CPPFLAGS) \
 test_run_avahi_LDADD = \
 	libevent.a \
 	libsystem.a \
+	libutil.a \
 	$(GLIB_LIBS) \
 	$(AVAHI_LIBS)
 
@@ -1928,6 +1929,7 @@ test_test_mixramp_SOURCES = \
 test_test_mixramp_CPPFLAGS = $(AM_CPPFLAGS) $(CPPUNIT_CFLAGS) -DCPPUNIT_HAVE_RTTI=0
 test_test_mixramp_CXXFLAGS = $(AM_CXXFLAGS) -Wno-error=deprecated-declarations
 test_test_mixramp_LDADD = \
+	libutil.a \
 	$(GLIB_LIBS) \
 	$(CPPUNIT_LIBS)
 
@@ -1970,6 +1972,7 @@ test_test_archive_CPPFLAGS = $(AM_CPPFLAGS) $(CPPUNIT_CFLAGS) -DCPPUNIT_HAVE_RTT
 test_test_archive_CXXFLAGS = $(AM_CXXFLAGS) -Wno-error=deprecated-declarations
 test_test_archive_LDADD = \
 	libarchive.a \
+	libutil.a \
 	$(GLIB_LIBS) \
 	$(CPPUNIT_LIBS)
 
diff --git a/src/LogBackend.cxx b/src/LogBackend.cxx
index 6f1794521..6591fef2d 100644
--- a/src/LogBackend.cxx
+++ b/src/LogBackend.cxx
@@ -21,7 +21,7 @@
 #include "LogBackend.hxx"
 #include "Log.hxx"
 #include "util/Domain.hxx"
-#include "util/CharUtil.hxx"
+#include "util/StringUtil.hxx"
 
 #ifdef HAVE_GLIB
 #include <glib.h>
@@ -119,11 +119,7 @@ static int
 chomp_length(const char *p)
 {
 	size_t length = strlen(p);
-
-	while (length > 0 && IsWhitespaceFast(p[length - 1]))
-		--length;
-
-	return (int)length;
+	return StripRight(p, length);
 }
 
 #ifdef HAVE_SYSLOG